/**
 * response_handler.css
 * 
 * Styles for API response handling, custom notifications, and field validation
 */

/* ============================================================================
   CUSTOM NOTIFICATION MODAL (Replaces browser alert)
   ============================================================================ */

.fullrmc-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease-out;
}

.fullrmc-modal-dialog {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
  min-width: 480px;
  max-width: 600px;
  max-height: 90vh;  /* Increased from 80vh to use more screen space */
  display: flex;
  flex-direction: column;  /* Stack header, body, footer vertically */
  overflow: hidden;  /* Hide overflow on container */
  animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fullrmc-modal-header {
  background: var(--fullrmc-bg, #2c3e50);
  padding: 20px 24px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* All modal types use the same FullRMC brand background */
.fullrmc-modal-success .fullrmc-modal-header,
.fullrmc-modal-error .fullrmc-modal-header,
.fullrmc-modal-warning .fullrmc-modal-header,
.fullrmc-modal-info .fullrmc-modal-header {
  background: var(--fullrmc-bg, #2c3e50);
}

.fullrmc-modal-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.3px;
}

.fullrmc-modal-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Color-coded status badges */
.fullrmc-modal-status-success {
  background: rgba(16, 185, 129, 0.9);  /* Green */
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-error {
  background: rgba(239, 68, 68, 0.9);  /* Red */
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-warning {
  background: rgba(245, 158, 11, 0.9);  /* Amber/Orange */
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-info {
  background: rgba(59, 130, 246, 0.9);  /* Blue */
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  animation: pulse 2s infinite;
  filter: brightness(0) invert(1);  /* Make logo white for dark header */
  flex-shrink: 0;  /* Prevent logo from shrinking */
  background: rgba(255, 255, 255, 0.1);  /* Subtle background */
  border-radius: 4px;
  padding: 2px;
}

/* Fallback for broken image */
.fullrmc-modal-logo:not([src]),
.fullrmc-modal-logo[src=""] {
  display: none;
}

.fullrmc-modal-logo::before {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
}

.fullrmc-modal-body {
  padding: 32px 24px;
  min-height: 80px;
  max-height: calc(90vh - 180px);  /* Viewport height minus header and footer */
  overflow-y: auto;  /* Enable vertical scrolling */
  overflow-x: hidden;  /* Hide horizontal overflow */
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;  /* Allow body to grow and take available space */
}

/* Custom scrollbar styling for modal body */
.fullrmc-modal-body::-webkit-scrollbar {
  width: 8px;
}

.fullrmc-modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.fullrmc-modal-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.fullrmc-modal-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.fullrmc-modal-message {
  font-size: 15px;
  line-height: 1.7;
  color: #2c3e50;
  word-wrap: break-word;
  word-break: break-word;  /* Break long words if needed */
  text-align: center;
  max-width: 100%;
  font-weight: 400;
  white-space: pre-wrap;  /* Preserve line breaks and wrap text */
}

.fullrmc-modal-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: center;
  gap: 10px;
  background: #fafafa;
}

/* Footer with multiple buttons (confirmation dialogs) */
.fullrmc-modal-footer-buttons {
  justify-content: flex-end;
  gap: 12px;
}

.fullrmc-modal-button {
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  min-width: 120px;
  letter-spacing: 0.5px;
}

.fullrmc-modal-button:hover {
  transform: translateY(-1px);
}

.fullrmc-modal-button:active {
  transform: translateY(0);
}

.fullrmc-modal-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Secondary button (Cancel) */
.fullrmc-modal-button-secondary {
  background: #e0e0e0;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fullrmc-modal-button-secondary:hover {
  background: #d0d0d0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.fullrmc-modal-button-secondary:focus {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* Primary button (default) */
.fullrmc-modal-button-primary {
  background: linear-gradient(135deg, var(--fullrmc-accent, #667eea) 0%, var(--fullrmc-accent-dark, #764ba2) 100%);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.fullrmc-modal-button-primary:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Danger button (Delete, destructive actions) */
.fullrmc-modal-button-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.fullrmc-modal-button-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.fullrmc-modal-button-danger:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* Success button (Confirm, positive actions) */
.fullrmc-modal-button-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.fullrmc-modal-button-success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.fullrmc-modal-button-success:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* All modal buttons use FullRMC brand accent gradient */
.fullrmc-modal-button {
  background: linear-gradient(135deg, var(--fullrmc-accent, #667eea) 0%, var(--fullrmc-accent-dark, #764ba2) 100%);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.fullrmc-modal-button:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-30px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
}

/* Responsive design */
@media (max-width: 600px) {
  .fullrmc-modal-dialog {
    min-width: 90vw;
    max-width: 95vw;
    margin: 20px;
    max-height: 95vh;  /* Use more screen space on mobile */
  }
  
  .fullrmc-modal-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .fullrmc-modal-body {
    padding: 24px 20px;
    max-height: calc(95vh - 200px);  /* Adjusted for mobile */
  }
  
  .fullrmc-modal-message {
    font-size: 14px;
  }
  
  /* Smaller scrollbar on mobile */
  .fullrmc-modal-body::-webkit-scrollbar {
    width: 4px;
  }
}

/* ============================================================================
   FIELD VALIDATION ERRORS
   ============================================================================ */

/* Field validation error state */
.field-error,
input.field-error,
select.field-error,
textarea.field-error {
  border-color: #f44336 !important;
  border-width: 2px !important;
  background-color: rgba(244, 67, 54, 0.05) !important;
  transition: border-color 0.3s, background-color 0.3s;
}

.field-error:focus,
input.field-error:focus,
select.field-error:focus,
textarea.field-error:focus {
  border-color: #f44336 !important;
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1) !important;
  outline: none;
}

/* Shake animation for error fields */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.field-error {
  animation: shake 0.5s;
}

/* Future: Toast notification styles for non-blocking notifications */
/* TODO: Add toast notification system for info messages */
