/* ============================================================================
   PROFESSIONAL UI/UX ENHANCEMENTS - OPTIMIZED & MERGED
   Toast notifications, form validation, animations, accessibility
   
   Combines: ui-enhancements.css + ux-enhancements.css
   Optimized: Removed duplicates, merged similar rules, improved performance
   ============================================================================ */

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 420px;
}

.toast {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid currentColor;
  min-width: 320px;
  max-width: 420px;
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-hide {
  opacity: 0;
  transform: translateX(400px);
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 14px;
  line-height: 1.5;
  color: #1e293b;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #64748b;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toast-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.toast-close:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.toast-close svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Toast Type Colors */
.toast-success { color: #10b981; border-left-color: #10b981; }
.toast-error { color: #ef4444; border-left-color: #ef4444; }
.toast-warning { color: #f59e0b; border-left-color: #f59e0b; }
.toast-info { color: #3b82f6; border-left-color: #3b82f6; }

/* ============================================================================
   CARD & ELEMENT SHADOWS - Soft shadows for depth
   ============================================================================ */

.dash-card,
.neu-card,
.profile-banner,
.freemium-banner,
.kpi-card {
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.dash-card:hover,
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================================================
   BUTTON ENHANCEMENTS - Smooth interactions & loading states
   ============================================================================ */

button,
.btn,
.primary,
.secondary {
  transition: all 0.2s ease;
  cursor: pointer;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button Loading State */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: not-allowed;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

button.secondary.btn-loading::after {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: rgba(0, 0, 0, 0.6);
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================================================
   FOCUS STATES - Better accessibility
   ============================================================================ */

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================================
   INPUT & FORM ENHANCEMENTS
   ============================================================================ */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-size: 15px;
  padding: 12px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  color: #1e293b;
  width: 100%;
}

input:hover:not(:disabled),
textarea:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: #cbd5e1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

input:disabled,
textarea:disabled,
select:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Placeholder Enhancement */
input::placeholder,
textarea::placeholder {
  color: #94a3b8;
  opacity: 1;
  transition: opacity 0.2s ease, color 0.2s ease;
}

input:focus::placeholder,
textarea:focus::placeholder {
  opacity: 0.4;
  color: #cbd5e1;
}

input.input-has-value::placeholder,
textarea.input-has-value::placeholder {
  opacity: 0;
}

/* ============================================================================
   FORM VALIDATION & ERROR STATES
   ============================================================================ */

.field-error {
  display: none;
  color: #ef4444;
  font-size: 13px;
  margin-top: 6px;
  font-weight: 500;
  animation: slideDown 0.2s ease;
}

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

.input-error {
  border-color: #ef4444 !important;
  background-color: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.input-error:focus {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.input-success {
  border-color: #10b981;
  background-color: #f0fdf4;
}

/* Required Field Indicator */
.required-indicator {
  color: #ef4444;
  font-weight: 600;
  font-size: 16px;
}

.required-indicator span {
  display: inline-block;
  margin-left: 2px;
}

/* ============================================================================
   LABELS & HINTS
   ============================================================================ */

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  transition: color 0.2s ease;
}

.hint {
  font-size: 13px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.5;
}

.hint code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* ============================================================================
   MODAL ANIMATIONS
   ============================================================================ */

.modal-dialog,
.clientModal,
.confirm-modal {
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================================================
   TABLE ENHANCEMENTS
   ============================================================================ */

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ============================================================================
   LOADING & SKELETON STATES
   ============================================================================ */

.loading,
.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.form-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 12px;
}

.form-loading-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================================
   SCROLLBAR STYLING (webkit only)
   ============================================================================ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* ============================================================================
   PAGE TRANSITIONS
   ============================================================================ */

.page-shell {
  animation: fadeIn 0.3s ease;
}

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

/* ============================================================================
   BADGES & NOTIFICATIONS
   ============================================================================ */

.badge,
.status-badge {
  transition: all 0.2s ease;
}

.badge:hover {
  transform: scale(1.05);
}

/* ============================================================================
   DROPDOWN ANIMATIONS
   ============================================================================ */

.dropdown-menu,
.client-dropdown {
  animation: dropdownFade 0.2s ease;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================================
   ACCESSIBILITY - SKIP LINK
   ============================================================================ */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #1e293b;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  font-weight: 600;
  z-index: 10000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

/* ============================================================================
   RESPONSIVE - MOBILE OPTIMIZATIONS
   ============================================================================ */

@media (max-width: 768px) {
  /* Remove hover effects on mobile */
  .dash-card:hover,
  .kpi-card:hover,
  button:hover {
    transform: none;
  }
  
  /* Larger touch targets */
  button,
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 640px) {
  #toastContainer {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
  
  /* Prevent iOS zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px;
  }
  
  label {
    font-size: 13px;
  }
  
  .hint {
    font-size: 12px;
  }
}

/* ============================================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .no-print,
  .sidebar,
  button,
  .btn,
  #toastContainer,
  .toast,
  .field-error,
  .skip-link {
    display: none !important;
  }
  
  * {
    box-shadow: none !important;
  }
}
