/**
 * MYPEAS Design System
 * Unified design language for all modals, components, and interfaces
 * Based on the unified auth modal aesthetic
 */

/* ============================================
   COLOR PALETTE
   ============================================ */
:root {
  /* Primary Colors */
  --primary-green: #1bb978;
  --primary-green-dark: #0e8856;
  --primary-green-light: #2dd68f;

  /* Neutral Colors */
  --neutral-900: #1a1a1a;
  --neutral-800: #2d2d2d;
  --neutral-700: #4a4a4a;
  --neutral-600: #666666;
  --neutral-500: #999999;
  --neutral-400: #b3b3b3;
  --neutral-300: #dddddd;
  --neutral-200: #eeeeee;
  --neutral-100: #f7f7f7;
  --neutral-white: #ffffff;

  /* Semantic Colors */
  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #86efac;

  --error-color: #e53e3e;
  --error-bg: #fff5f5;
  --error-border: #fca5a5;

  --warning-color: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --info-color: #3b82f6;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
  --shadow-2xl: 0 24px 72px rgba(0, 0, 0, 0.20);

  /* Green Shadows (for buttons/CTAs) */
  --shadow-green: 0 4px 12px rgba(27, 185, 120, 0.3);
  --shadow-green-lg: 0 8px 24px rgba(27, 185, 120, 0.4);

  /* Spacing Scale */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-modal-backdrop: 9998;
  --z-modal: 9999;
  --z-toast: 10000;
  --z-tooltip: 10001;
}

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  animation: fadeIn var(--transition-slow) ease-out;
  padding: var(--space-4);
}

.modal-overlay.closing {
  animation: fadeIn var(--transition-slow) ease-out reverse;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.modal-container {
  background: var(--neutral-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: scaleIn var(--transition-slow) ease-out;
}

.modal-container.large {
  max-width: 720px;
}

.modal-container.full {
  max-width: 95vw;
  max-height: 95vh;
}

/* Modal Header */
.modal-header {
  padding: var(--space-10);
  padding-bottom: var(--space-6);
  text-align: center;
  border-bottom: 1px solid var(--neutral-200);
}

.modal-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  display: block;
}

.modal-title {
  margin: 0;
  color: var(--neutral-900);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.modal-subtitle {
  margin-top: var(--space-2);
  color: var(--neutral-600);
  font-size: 14px;
  line-height: 1.5;
}

/* Modal Body */
.modal-body {
  padding: var(--space-8);
}

/* Modal Footer */
.modal-footer {
  padding: var(--space-6) var(--space-8);
  background: var(--neutral-100);
  border-top: 1px solid var(--neutral-200);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.modal-footer.center {
  justify-content: center;
}

/* Close Button */
.modal-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--neutral-500);
  cursor: pointer;
  padding: var(--space-1);
  width: 32px;
  height: 32px;
  line-height: 1;
  transition: color var(--transition-fast);
  z-index: 10;
}

.modal-close:hover {
  color: var(--neutral-900);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--neutral-900);
  font-size: 14px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-4);
  font-size: 14px;
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  transition: all var(--transition-fast);
  font-family: inherit;
  color: var(--neutral-900);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(27, 185, 120, 0.1);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--neutral-100);
  cursor: not-allowed;
  opacity: 0.6;
}

.form-input.error {
  border-color: var(--error-color);
}

.form-input.error:focus {
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.form-help {
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--neutral-600);
}

.form-error {
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--error-color);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  padding: var(--space-4) var(--space-6);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
  color: white;
  box-shadow: var(--shadow-green);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-green-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
  background: var(--neutral-white);
  color: var(--neutral-900);
  border: 2px solid var(--neutral-300);
}

.btn-secondary:hover {
  background: var(--neutral-100);
  border-color: var(--neutral-400);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--neutral-700);
  border: none;
  padding: var(--space-3) var(--space-4);
}

.btn-ghost:hover {
  background: var(--neutral-100);
}

/* Danger Button */
.btn-danger {
  background: var(--error-color);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: 14px;
}

.btn-lg {
  padding: var(--space-5) var(--space-8);
  font-size: 18px;
}

.btn-block {
  width: 100%;
}

/* Button with Icon */
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Loading State */
.btn-loading {
  opacity: 0.7;
  pointer-events: none;
}

.btn-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: var(--space-2);
}

/* ============================================
   ALERTS & MESSAGES
   ============================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border-left: 4px solid;
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-color);
  color: #065f46;
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-color);
  color: #991b1b;
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-color);
  color: #92400e;
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info-color);
  color: #1e40af;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--neutral-200);
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--neutral-900);
}

.card-body {
  color: var(--neutral-700);
  font-size: 14px;
  line-height: 1.6;
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--neutral-200);
}

/* Clickable Card */
.card-clickable {
  cursor: pointer;
}

.card-clickable:active {
  transform: translateY(0);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-color);
  border: 1px solid var(--success-border);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error-color);
  border: 1px solid var(--error-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-color);
  border: 1px solid var(--warning-border);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-color);
  border: 1px solid var(--info-border);
}

.badge-primary {
  background: rgba(27, 185, 120, 0.1);
  color: var(--primary-green-dark);
  border: 1px solid var(--primary-green-light);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  min-width: 300px;
  max-width: 500px;
  padding: var(--space-4) var(--space-5);
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-toast);
  animation: slideInRight var(--transition-slow) ease-out;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toast-success {
  border-left: 4px solid var(--success-color);
}

.toast-error {
  border-left: 4px solid var(--error-color);
}

.toast-warning {
  border-left: 4px solid var(--warning-color);
}

.toast-info {
  border-left: 4px solid var(--info-color);
}

.toast-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: var(--space-1);
  font-size: 14px;
}

.toast-message {
  font-size: 13px;
  color: var(--neutral-600);
}

.toast-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--neutral-500);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--neutral-900);
}

/* ============================================
   LOADING STATES
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-200) 25%,
    var(--neutral-100) 50%,
    var(--neutral-200) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* ============================================
   PROGRESS INDICATORS
   ============================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-green), var(--primary-green-light));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--neutral-300);
  border-top-color: var(--primary-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

.text-sm { font-size: 12px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.text-2xl { font-size: 24px; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }

.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  .modal-container {
    max-width: 100%;
    margin: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .modal-header {
    padding: var(--space-6);
  }

  .modal-body {
    padding: var(--space-4);
  }

  .modal-title {
    font-size: 20px;
  }

  .toast {
    min-width: 280px;
    right: var(--space-4);
    left: var(--space-4);
  }
}
