/* ==============================================================================
   TheModelSuite.com: Design System (Seline Analytics Warm Stone Aesthetic)
   Quiet Analyst's Desk, Warm Paper #fafaf9, Hairline Borders, Cyan Signal, Zero Emojis
   ============================================================================== */

:root {
  /* Seline Chromatic Voice */
  --brand-blue: #3ba6f1;
  --brand-blue-hover: #3398e1;
  --brand-blue-light: #c1e1f7;
  --brand-blue-border: #3398e1;

  /* Stone Neutrals & Surfaces */
  --bg-app: #fafaf9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f5f5f4;
  --bg-input: #ffffff;
  --text-primary: #0c0a09;
  --text-secondary: #78716c;
  --text-muted: #71717a;
  --border-light: #e8e6e5;
  --border-medium: #d6d3d1;
  --border-focus: #3ba6f1;

  /* Compatibility Color Aliases */
  --color-primary: var(--brand-blue);
  --color-primary-hover: var(--brand-blue-hover);
  --color-primary-light: var(--brand-blue-light);
  --color-primary-border: var(--brand-blue-border);
  --color-text: var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --color-text-muted: var(--text-muted);
  --color-border: var(--border-light);
  --color-bg: var(--bg-app);
  --color-bg-subtle: var(--bg-card-subtle);
  --color-bg-surface: var(--bg-card);

  /* Status Indicators */
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-accent: #3ba6f1;

  /* Seline Radii & Hairline Elevation */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;
  
  --shadow-sm: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
  --shadow-card: rgba(0, 0, 0, 0.05) 0px 4px 16px 0px;
  --shadow-hover: rgba(17, 12, 46, 0.08) 0px 8px 24px 0px;
  --shadow-modal: rgba(17, 12, 46, 0.12) 0px 12px 45px 0px;

/* Seline Typography: Whispered 400 Weight Display */
  --font-heading: 'Inter Tight', 'Roobert', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==============================================================================
   Atmospheric Dark Mode System (Seline Obsidian & Slate Luxury Aesthetic)
   ============================================================================== */
body.dark-mode,
[data-theme="dark"],
:root[data-theme="dark"] {
  /* Chromatic Signal */
  --brand-blue: #38bdf8;
  --brand-blue-hover: #0ea5e9;
  --brand-blue-light: rgba(56, 189, 248, 0.14);
  --brand-blue-border: rgba(56, 189, 248, 0.35);

  /* Deep Atmospheric Surfaces */
  --bg-app: #090d16;
  --bg-card: #111827;
  --bg-card-subtle: #1a2233;
  --bg-input: #151d2d;
  --bg-hover: #1f2a3d;

  /* Typography Contrast */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #94a3b8;

  /* Hairline Borders */
  --border-light: #1e293b;
  --border-medium: #334155;
  --border-focus: #38bdf8;

  /* Compatibility Color Aliases in Dark Mode */
  --color-primary: var(--brand-blue);
  --color-primary-hover: var(--brand-blue-hover);
  --color-primary-light: var(--brand-blue-light);
  --color-primary-border: var(--brand-blue-border);
  --color-text: var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --color-text-muted: var(--text-muted);
  --color-border: var(--border-light);
  --color-bg: var(--bg-app);
  --color-bg-subtle: var(--bg-card-subtle);
  --color-bg-surface: var(--bg-card);

  /* Status Colors in Dark Mode */
  --color-success: #34d399;
  --color-success-bg: rgba(16, 185, 129, 0.14);
  --color-success-border: rgba(16, 185, 129, 0.3);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(245, 158, 11, 0.14);
  --color-warning-border: rgba(245, 158, 11, 0.3);
  --color-danger: #f87171;
  --color-danger-bg: rgba(239, 68, 68, 0.14);
  --color-danger-border: rgba(239, 68, 68, 0.3);
  --color-accent: #38bdf8;

  /* Deep Shadows */
  --shadow-sm: rgba(0, 0, 0, 0.35) 0px 1px 2px 0px;
  --shadow-card: rgba(0, 0, 0, 0.45) 0px 4px 16px 0px;
  --shadow-hover: rgba(0, 0, 0, 0.6) 0px 8px 24px 0px;
  --shadow-modal: rgba(0, 0, 0, 0.8) 0px 16px 48px 0px;
}

/* Keyframes: Universal Spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 3px;
}

html, body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  position: relative;
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.64;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, canvas, svg, iframe {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}

h1 {
  font-size: 2.75rem;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

h2 {
  font-size: 2rem;
  letter-spacing: -0.022em;
  line-height: 1.2;
}

h3 {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.018em;
}

.text-highlight {
  color: #3398e1;
  background: #c1e1f7;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-weight: 400;
  display: inline-block;
}

p, span, li, a, div {
  overflow-wrap: break-word;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--brand-blue-hover);
}

/* Clean SVG Icon Helper */
.icon {
  display: inline-block;
  vertical-align: middle;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Standard Containers */
.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .container {
    padding: 0 1rem;
  }
}

/* Card Component (MyFitnessPal Clean White Block) */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--border-medium);
}
.card-subtle {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  max-width: 100%;
  box-sizing: border-box;
}
.btn-primary {
  background: #09090b;
  color: #ffffff;
  border-color: #09090b;
}
.btn-primary:hover {
  background: #27272a;
  border-color: #27272a;
  color: #ffffff;
}
body.dark-mode .btn-primary,
[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary {
  background: #38bdf8;
  color: #09090b;
  border-color: #38bdf8;
  font-weight: 700;
}
body.dark-mode .btn-primary:hover,
[data-theme="dark"] .btn-primary:hover,
:root[data-theme="dark"] .btn-primary:hover {
  background: #7dd3fc;
  border-color: #7dd3fc;
  color: #09090b;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-card-subtle);
  border-color: var(--text-muted);
}
.btn-outline {
  background: transparent;
  color: #0369a1;
  border-color: #0284c7;
}
.btn-outline:hover {
  background: rgba(2, 132, 199, 0.08);
  border-color: #0369a1;
}
body.dark-mode .btn-outline,
[data-theme="dark"] .btn-outline,
:root[data-theme="dark"] .btn-outline {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.45);
}
body.dark-mode .btn-outline:hover,
[data-theme="dark"] .btn-outline:hover,
:root[data-theme="dark"] .btn-outline:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: #38bdf8;
}
.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}
.btn-pill {
  border-radius: var(--radius-pill);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.9rem;
  font-size: 0.92rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 102, 238, 0.15);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap !important;
  line-height: 1.2;
}
.badge-blue {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border: 1px solid var(--brand-blue-border);
}
.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}
.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}
.badge-subtle {
  background: var(--bg-card-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* Scroll lock for body when modal is active */
body.modal-open {
  overflow: hidden !important;
  touch-action: none !important;
}

/* Clean Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  transition: all 0.2s ease;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  max-width: 650px;
  width: 100%;
  box-sizing: border-box;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-modal);
  padding: 2rem;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}
@media (max-width: 600px) {
  .modal-overlay {
    padding: 0.65rem;
  }
  .modal-box {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-lg);
    max-height: 92vh;
  }
}
.modal-overlay.active .modal-box {
  transform: scale(1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
}
.modal-close {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.18s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.modal-close svg {
  stroke: #0f172a;
  stroke-width: 2.5px;
}
.modal-close:hover {
  background: #e2e8f0;
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  transform: scale(1.08);
}
.modal-close:hover svg {
  stroke: var(--brand-blue);
}
body.dark-mode .modal-close,
[data-theme="dark"] .modal-close {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}
body.dark-mode .modal-close svg,
[data-theme="dark"] .modal-close svg {
  stroke: #f8fafc;
}
body.dark-mode .modal-close:hover,
[data-theme="dark"] .modal-close:hover {
  background: #334155;
  border-color: #38bdf8;
  color: #38bdf8;
}
body.dark-mode .modal-close:hover svg,
[data-theme="dark"] .modal-close:hover svg {
  stroke: #38bdf8;
}

/* Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.data-table th {
  padding: 0.75rem 1rem;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card-subtle);
}
.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.data-table tr:hover td {
  background: var(--bg-card-subtle);
}

@media (max-width: 640px) {
  .data-table th, .data-table td {
    padding: 0.5rem 0.55rem;
    font-size: 0.74rem;
  }
}

/* Accessible Skip Link */
.skip-link {
  position: absolute;
  top: -120px;
  left: 1rem;
  background: #09090b;
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  z-index: 99999;
  text-decoration: none;
  border: 2px solid var(--brand-blue);
  transition: top 0.15s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 1rem;
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}
body.dark-mode .skip-link,
[data-theme="dark"] .skip-link,
:root[data-theme="dark"] .skip-link {
  background: #111827;
  color: #f8fafc;
}

/* Web Interface Guidelines: prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
