/*
 * Base Stylesheet — consolidated from legacy-call-scheduler/css/*.css
 * This file replaces <link href="legacy-call-scheduler/style.css">.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS / VARIABLES
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* --- Core Palette mapped from Landing Page --- */
  --color-white: #ffffff;
  --color-black: #0f172a;

  --color-brand-500: #3b82f6;
  --color-brand-600: #2563eb;
  --color-brand-700: #1d4ed8;

  --color-background: #f8fafc;
  --color-surface:    #ffffff;
  --color-text:       #1e293b;
  --color-text-secondary: #64748b;
  --header-bg:        rgba(255, 255, 255, 0.8);

  --color-primary:        var(--color-brand-500);
  --color-primary-hover:  var(--color-brand-600);
  --color-primary-active: var(--color-brand-700);

  --color-secondary:        #f1f5f9;
  --color-secondary-hover:  #e2e8f0;
  --color-secondary-active: #cbd5e1;

  --color-border:           #e2e8f0;
  --color-card-border:      #e2e8f0;
  --color-card-border-inner:#f1f5f9;

  /* Status Colors */
  --color-error:      #ef4444;
  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-info:       #3b82f6;

  /* Custom Schedule Shading */
  --color-protect:    rgba(239, 68, 68, 0.15);
  --color-request:    rgba(245, 158, 11, 0.15);
  --color-on-request: rgba(59, 130, 246, 0.15);
  --color-btn-primary-text: #ffffff;

  /* --- Typography --- */
  --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-family-mono: "JetBrains Mono", "Fira Code", monospace;

  /* Reduced Scale */
  --font-size-xs:   0.7rem;
  --font-size-sm:   0.8rem;
  --font-size-base: 0.875rem;
  --font-size-md:   0.875rem;
  --font-size-lg:   1rem;
  --font-size-xl:   1.125rem;
  --font-size-2xl:  1.25rem;
  --font-size-3xl:  1.5rem;
  --font-size-4xl:  1.875rem;

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

  --line-height-tight: 1.1;
  --line-height-normal: 1.6;
  --letter-spacing-tight: -0.02em;

  /* --- Spacing --- */
  --space-0: 0;
  --space-4: 0.25rem;
  --space-6: 0.35rem;
  --space-8: 0.5rem;
  --space-12: 0.75rem;
  --space-16: 1rem;
  --space-20: 1.25rem;
  --space-24: 1.5rem;
  --space-32: 2rem;

  --radius-sm:   3px;
  --radius-base: 6px;
  --radius-md:   8px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  /* --- Effects --- */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.05);

  --duration-fast:   150ms;
  --duration-normal: 300ms;
  --ease-standard:   cubic-bezier(0.4, 0, 0.2, 1);

  /* --- Layout --- */
  --container-xl: 1400px;
  --focus-ring: 0 0 0 2px rgba(59, 130, 246, 0.4);

  /* Background Opacities */
  --color-bg-1: #f1f5f9;
  --color-bg-2: #e2e8f0;
  --color-bg-3: rgba(16, 185, 129, 0.1);

  /* Extended palette */
  --color-bg-alt:         #f5f5f5;
  --color-surface-alt:    #f3f4f6;
  --color-border-light:   rgba(0,0,0,0.08);
  --color-text-tertiary:  #999;
  --color-bg-hover:       rgba(0,0,0,0.04);

  --select-caret-light: url("data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231e293b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Dark Mode Overrides */
[data-theme="dark"] {
  --color-background: #0f172a;
  --color-surface:    #1e293b;
  --color-text:       #f1f5f9;
  --color-text-secondary: #94a3b8;
  --header-bg:        rgba(15, 23, 42, 0.8);

  --color-primary:        #60a5fa;
  --color-primary-hover:  #93c5fd;
  --color-primary-active: #bfdbfe;

  --color-secondary:      #334155;
  --color-secondary-hover:#475569;
  --color-secondary-active: #1e293b;

  --color-border:         #334155;
  --color-card-border:    #334155;
  --color-card-border-inner: #0f172a;

  --color-bg-1: #1a2432;
  --color-bg-2: #334155;

  --color-bg-alt:         #162032;
  --color-surface-alt:    #283548;
  --color-border-light:   rgba(255,255,255,0.08);
  --color-text-tertiary:  #64748b;
  --color-bg-hover:       rgba(255,255,255,0.06);

  --select-caret-light: url("data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23f1f5f9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* --- Force Light Mode for Printing --- */
@media print {
  [data-theme="dark"] {
    --color-background: #f8fafc !important;
    --color-surface:    #ffffff !important;
    --color-text:       #1e293b !important;
    --color-text-secondary: #64748b !important;
    --color-border:     #e2e8f0 !important;
    --color-card-border:#e2e8f0 !important;
    --color-bg-1:       #f1f5f9 !important;
    --color-bg-2:       #e2e8f0 !important;
  }

  #theme-toggle,
  .theme-toggle-wrapper,
  .site-header {
    display: none !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   2. BASE HTML & BODY
   ═══════════════════════════════════════════════════════════════════════════ */

html {
  font-size: var(--font-size-base);
  font-family: var(--font-family-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

/* Info Icon Tooltip */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  font-size: 16px;
  color: var(--color-info);
  cursor: help;
  position: relative;
  opacity: 0.7;
  transition: opacity var(--duration-normal) var(--ease-standard);
  overflow: visible;
  z-index: 20;
}

.info-icon:hover {
  opacity: 1;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-text);
  color: var(--color-background);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  white-space: normal;
  width: auto;
  min-width: 320px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  box-sizing: border-box;
  word-break: break-word;
  overflow: auto;
  z-index: 21;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  display: none;
  top: 100%;
  margin-top: 8px;
}

.info-icon::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--color-text);
  z-index: 21;
  pointer-events: none;
  display: none;
  top: 100%;
  margin-top: 2px;
}

.info-icon:hover::after {
  display: block;
}

.info-icon:hover::before {
  display: block;
}


/* ═══════════════════════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════ */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
  letter-spacing: var(--letter-spacing-tight);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-md); }

p {
  margin: 0 0 var(--space-16) 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   4. BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-base);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  border: 1px solid transparent;
  text-decoration: none;
  gap: var(--space-8);
  background: var(--color-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

/* Primary (Solid Blue) */
.btn--primary {
  background: var(--color-primary);
  color: var(--color-btn-primary-text);
  border: 1px solid var(--color-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

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

/* Secondary (Slate/Grey) */
.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.btn--secondary:hover {
  background: var(--color-secondary);
  border-color: var(--color-secondary-hover);
  color: var(--color-text);
}

/* Outline (Transparent with border) */
.btn--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn--outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: transparent;
}

/* Danger (Red) */
.btn--danger {
  background: var(--color-protect);
  color: var(--color-error);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn--danger:hover {
  background: var(--color-error);
  color: var(--color-white);
}

/* Sizes */
.btn--sm {
  padding: var(--space-4) var(--space-12);
  font-size: var(--font-size-xs);
  height: 32px;
}

/* Match compact confirm/cancel controls to icon remove button height */
.btn--secondary.btn--sm,
.btn--danger.btn--sm {
  height: 26px;
  min-height: 26px;
  line-height: 1;
}

.btn--lg {
  padding: var(--space-12) var(--space-24);
  font-size: var(--font-size-base);
  height: 48px;
}

.btn--icon {
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dark Mode Buttons */
[data-theme="dark"] .btn {
  background: var(--color-secondary);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .btn:hover {
  background: var(--color-secondary-hover);
  border-color: var(--color-secondary-hover);
}

[data-theme="dark"] .btn--primary {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

[data-theme="dark"] .btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

[data-theme="dark"] .btn--primary:active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

[data-theme="dark"] .btn--secondary {
  background: var(--color-secondary);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .btn--secondary:hover {
  background: var(--color-secondary-hover);
  border-color: var(--color-secondary-hover);
}

[data-theme="dark"] .btn--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

[data-theme="dark"] .btn--outline:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

[data-theme="dark"] .btn--danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ff6b6b;
  border: 1px solid var(--color-error);
}

[data-theme="dark"] .btn--danger:hover {
  background: var(--color-error);
  color: var(--color-white);
  border-color: var(--color-error);
}

/* Delete Button (Special Variant) */
.btn-delete {
  background: var(--color-protect);
  color: var(--color-error);
  border: 1px solid transparent;
}

.btn-delete:hover {
  background: var(--color-error);
  color: var(--color-white);
}

[data-theme="dark"] .btn-delete {
  background: rgba(239, 68, 68, 0.2);
  color: #ff6b6b;
  border: 1px solid var(--color-error);
}

[data-theme="dark"] .btn-delete:hover {
  background: var(--color-error);
  color: var(--color-white);
  border-color: var(--color-error);
}


/* ═══════════════════════════════════════════════════════════════════════════
   5. FORMS
   ═══════════════════════════════════════════════════════════════════════════ */

.form-control {
  display: block;
  width: 100%;
  min-width: 0;
  padding: var(--space-8) var(--space-12);
  font-size: var(--font-size-md);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.form-control:focus {
  border-color: var(--color-primary);
  outline: var(--focus-outline);
}

select.form-control {
  padding: var(--space-8) var(--space-12);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--select-caret-light);
  background-repeat: no-repeat;
  background-position: right var(--space-12) center;
  background-size: 16px;
  padding-right: var(--space-32);
}

.form-label {
  display: block;
  margin-bottom: var(--space-8);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
}

.form-group {
  margin-bottom: var(--space-16);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-16);
  align-items: end;
}

.form-grid .form-group {
  min-width: 0;
}

.form-grid .form-group:last-child {
  display: block;
}

.form-grid--inline-button {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-12);
  align-items: end;
}

.form-grid--inline-button .form-group {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.form-grid--inline-button .form-group__action {
  flex-grow: 0;
  flex-shrink: 0;
  margin-bottom: 0;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-16);
  margin-top: var(--space-8);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--font-size-sm);
}

.form-grid--inline-button .form-group--checkbox {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-bottom: 0;
  align-self: center;
}

.form-grid--inline-button .form-group--checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.form-grid--inline-button .form-group--checkbox label {
  margin: 0;
  font-weight: normal;
  font-size: var(--font-size-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.form-select {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-6) var(--space-24) var(--space-6) var(--space-8);
  -webkit-appearance: none;
  appearance: none;
  background-image: var(--select-caret-light);
  background-repeat: no-repeat;
  background-position: right var(--space-8) center;
  background-size: 12px;
}

.form-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--focus-ring);
}

.form-select-sm {
  font-size: var(--font-size-xs);
  padding: var(--space-4) var(--space-20) var(--space-4) var(--space-8);
}


/* ═══════════════════════════════════════════════════════════════════════════
   6. CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-standard);
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card__body {
  padding: var(--space-16);
  overflow: hidden;
  flex: 1;
}

.card__header {
  padding: var(--space-16);
  border-bottom: 1px solid var(--color-card-border-inner);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.card__header h3 {
  margin: 0;
}

.card__header-content {
  display: flex;
  flex-direction: column;
}


/* ═══════════════════════════════════════════════════════════════════════════
   7. LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.site-header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: 0.9rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background var(--duration-normal) var(--ease-standard),
              border-color var(--duration-normal) var(--ease-standard);
}

.site-header__inner {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-header__logo {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

.site-header__logo:hover {
  color: var(--color-primary);
}

.site-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.site-header__app-name {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
}

.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: var(--space-16);
  padding-left: var(--space-16);
  padding-top: var(--space-24);
}

@media (min-width: 1280px) {
  .container {
    max-width: var(--container-xl);
  }
}

.mt-8 {
  margin-top: var(--space-8);
}

.mb-16 {
  margin-bottom: var(--space-16);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-32) 0 var(--space-24) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-24);
}

.header h1 {
  color: var(--color-text);
  font-size: var(--font-size-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-24);
}

.results-actions {
  display: flex;
  gap: var(--space-8);
}


/* ═══════════════════════════════════════════════════════════════════════════
   8. NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════ */

.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-24);
  gap: 0;
}

.nav-tab {
  background: none;
  border: none;
  padding: var(--space-12) var(--space-20);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family-base);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--color-text);
}

.nav-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
}

.nav-subtabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-16);
  flex-wrap: wrap;
  width: 100%;
  flex: 1 1 100%;
  gap: var(--space-4);
}

.nav-subtab {
  background: none;
  border: none;
  padding: var(--space-8) var(--space-16);
  font-size: var(--font-size-sm);
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-base);
  transition: color var(--duration-fast) var(--ease-standard),
              background-color var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}

.nav-subtab:hover {
  color: var(--color-text);
  background-color: var(--color-secondary);
}

.nav-subtab.active {
  color: var(--color-primary);
  background-color: var(--color-secondary);
  font-weight: var(--font-weight-semibold);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.subtab-content {
  display: none;
}

.subtab-content.active {
  display: block;
}

.results-content {
  display: none;
}

.results-content.active {
  display: block;
}

/* Save Indicator */
.save-indicator {
  font-size: 0.9rem;
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-normal) var(--ease-standard);
  line-height: 1.3;
}

.save-indicator--ready {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

.save-indicator--unsaved {
  color: #fff;
  background-color: #d97706;
  opacity: 1;
  font-weight: 600;
  animation: pulse-unsaved 2s ease-in-out infinite;
}

@keyframes pulse-unsaved {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.7);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.3);
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   9. TABLES
   ═══════════════════════════════════════════════════════════════════════════ */

.table-container {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
  margin-bottom: var(--space-16);
  position: relative;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
}

.data-table th,
.data-table td {
  padding: var(--space-8) var(--space-12);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background-color: var(--color-background);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 1;
  height: 32px;
}

/* Schedule Table (The Main Grid) */
.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-xs);
  table-layout: fixed;
}

.schedule-table th,
.schedule-table td {
  padding: 4px 6px;
  text-align: center;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  width: 65px;
  min-width: 65px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 28px;
}

.schedule-table th {
  background-color: var(--color-secondary);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  position: sticky;
  top: 0;
  z-index: 5;
  border-top: 1px solid var(--color-border);
  height: 34px;
}

/* Date Column (Sticky Left) */
.schedule-table th:first-child,
.schedule-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 6;
  background-color: var(--color-surface);
  font-weight: var(--font-weight-medium);
  text-align: center;
  padding: 4px 3px;
  border-left: 1px solid var(--color-border);
  box-shadow: 1px 0 3px rgba(0,0,0,0.05);
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

.schedule-table th:first-child {
  z-index: 7;
  background-color: var(--color-secondary);
}

/* Visual States */
.weekend-row, .weekend-row td:first-child { background-color: var(--color-bg-1) !important; }
.holiday-row, .holiday-row td:first-child { background-color: var(--color-bg-2) !important; }

.schedule-table td.protected-call {
  background-color: var(--color-protect) !important;
  color: var(--color-error);
  background-image: repeating-linear-gradient(45deg, rgba(239,68,68,0.05), rgba(239,68,68,0.05) 5px, rgba(239,68,68,0.1) 5px, rgba(239,68,68,0.1) 10px) !important;
}

.schedule-table td.requested-on-call {
  background-color: var(--color-on-request) !important;
  color: var(--color-info);
  font-weight: 600;
}

.schedule-table td.requested-no-call {
  background-color: var(--color-request) !important;
  color: var(--color-warning);
  text-decoration: line-through;
}

.schedule-table td.drag-over {
  background-color: rgba(16, 185, 129, 0.15) !important;
  box-shadow: inset 0 0 0 2px var(--color-success);
}

.schedule-table td.highlighted-cell {
  background-color: var(--color-on-request) !important;
  box-shadow: inset 0 0 0 2px var(--color-primary) !important;
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}


/* ═══════════════════════════════════════════════════════════════════════════
   10. MODALS
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100002;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-16);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: color var(--duration-fast) var(--ease-standard);
}

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

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-8);
  padding: var(--space-16);
  border-top: 1px solid var(--color-border);
}

.flatpickr-calendar {
  z-index: 100003 !important;
}


/* ═══════════════════════════════════════════════════════════════════════════
   11. MESSAGES & STATUS
   ═══════════════════════════════════════════════════════════════════════════ */

.status-message {
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-base);
  margin: var(--space-16) 0;
}

.status-message--success {
  background-color: rgba(var(--color-success-rgb), 0.1);
  border: 1px solid rgba(var(--color-success-rgb), 0.2);
  color: var(--color-success);
}

.status-message--error {
  background-color: rgba(var(--color-error-rgb), 0.1);
  border: 1px solid rgba(var(--color-error-rgb), 0.2);
  color: var(--color-error);
}

.status-message--info {
  background-color: rgba(var(--color-info-rgb), 0.1);
  border: 1px solid rgba(var(--color-info-rgb), 0.2);
  color: var(--color-info);
}

.status-message--warning {
  background-color: rgba(var(--color-warning-rgb), 0.1);
  border: 1px solid rgba(var(--color-warning-rgb), 0.2);
  color: var(--color-warning);
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 1s ease-in-out infinite;
  margin-right: var(--space-8);
}

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

.text-secondary { color: var(--color-text-secondary); }
.text-success   { color: var(--color-success); }
.text-error     { color: var(--color-error); }
.text-warning   { color: var(--color-warning); }
.text-info      { color: var(--color-info); }


/* ═══════════════════════════════════════════════════════════════════════════
   12. LEGEND
   ═══════════════════════════════════════════════════════════════════════════ */

.schedule-legend {
  padding: var(--space-16);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  margin-bottom: 1.25rem;
}

.schedule-legend h4 {
  margin-top: 0;
  margin-bottom: var(--space-12);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}

.legend-items-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.legend-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 160px;
  font-size: var(--font-size-xs);
  color: var(--color-text);
}

.legend-swatch {
  height: 1.5rem;
  width: 1.5rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   13. TIMELINE
   ═══════════════════════════════════════════════════════════════════════════ */

.timeline-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-12);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-16);
}

.timeline-container {
  overflow-x: auto;
  position: relative;
  min-height: 150px;
  padding-top: var(--space-8);
}

.timeline-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  height: 32px;
}

.timeline-row:last-child {
  border-bottom: none;
}

.timeline-label {
  width: 140px;
  min-width: 140px;
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-xs);
  padding-right: var(--space-12);
  border-right: 1px solid var(--color-border);
  color: var(--color-text);
  background: var(--color-surface);
  position: sticky;
  left: 0;
  z-index: 20;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-track {
  flex-grow: 1;
  position: relative;
  height: 100%;
  background-color: var(--color-background);
  min-width: 600px;
}

.timeline-bar {
  position: absolute;
  height: 20px;
  top: 6px;
  color: white;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  padding: 0 var(--space-4);
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  font-weight: 600;
  z-index: 5;
  cursor: pointer;
  letter-spacing: -0.01em;
}

.timeline-bar:hover {
  transform: scaleY(1.1);
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.timeline-bar--excluded {
  border: 2px dashed var(--color-border);
  opacity: 0.7;
}

.timeline-bar--excluded:hover {
  opacity: 0.9;
  border-color: var(--color-text-secondary);
}

.timeline-bar--service-roster {
  border: 2px dotted var(--color-primary);
}

.timeline-bar--service-roster:hover {
  border-style: solid;
}

.timeline-bar[data-type="ER"]       { background-color: var(--color-error); }
.timeline-bar[data-type="IM"]       { background-color: var(--color-primary); }
.timeline-bar[data-type="FM"]       { background-color: var(--color-success); }
.timeline-bar[data-type="Elective"] { background-color: var(--color-warning); }

.timeline-header {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  padding-left: 140px;
  height: 24px;
  font-size: 10px;
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  position: relative;
  min-width: 740px;
}

.timeline-month {
  position: absolute;
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-4);
  height: 100%;
  display: flex;
  align-items: center;
}

/* Call Protection Overlays on Timeline */
.timeline-bar.timeline-bar--overlay {
  background-color: var(--color-surface) !important;
  color: var(--color-error) !important;
  border: 1.5px dashed var(--color-error);
  font-weight: var(--font-weight-bold);
  z-index: 5 !important;
  box-shadow: var(--shadow-sm);
}

.timeline-bar.timeline-bar--overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--color-protect);
  pointer-events: none;
  z-index: -1;
}

.timeline-bar.timeline-bar--overlay:hover {
  background-color: var(--color-secondary) !important;
  border-style: solid;
  z-index: 10 !important;
}


/* ═══════════════════════════════════════════════════════════════════════════
   14. SCHEDULE LAYOUT (sidebar + main)
   ═══════════════════════════════════════════════════════════════════════════ */

.schedule-layout {
  display: flex;
  gap: 1.5rem;
  min-height: calc(100vh - 300px);
}

.schedule-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overflow-x: visible;
}

.schedule-sidebar-content {
  background-color: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.schedule-sidebar-content h3 {
  color: var(--color-text);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.schedule-sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.stats-detail-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background-color: var(--color-bg-1);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  line-height: 1.1;
  font-size: 0.9rem;
  gap: 0.35rem;
  z-index: 12001;
}

.stats-detail-trigger:hover {
  background-color: var(--color-bg-2);
}

.stats-detail-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.stats-detail-popover {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, 92vw);
  max-height: 70vh;
  background-color: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), var(--shadow-lg);
  padding: 0.75rem;
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
  z-index: 12000;
}

.stats-detail-trigger.is-open .stats-detail-popover,
.stats-detail-trigger:focus-within .stats-detail-popover,
.stats-detail-popover:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.stats-detail-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--color-text);
}

.stats-detail-popover__hint {
  color: var(--color-text-secondary);
  font-weight: 400;
  font-size: 0.85rem;
}

.stats-detail-popover__body {
  width: 100%;
}

.schedule-main {
  flex: 1;
  min-width: 0;
}

#sidebarStats {
  font-size: 0.9rem;
  line-height: 1.6;
}

#sidebarStats table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#sidebarStats th,
#sidebarStats td {
  padding: 0.5rem 0;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

#sidebarStats th {
  font-weight: 600;
  color: var(--color-text-secondary);
  padding-top: 0.75rem;
}

#sidebarStats td {
  color: var(--color-text);
}

#sidebarStats tr:last-child td {
  border-bottom: none;
}

.schedule-sidebar::-webkit-scrollbar { width: 6px; }
.schedule-sidebar::-webkit-scrollbar-track { background: transparent; }
.schedule-sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
.schedule-sidebar::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

@media (max-width: 1400px) {
  .schedule-layout {
    flex-direction: column;
    min-height: auto;
  }

  .schedule-sidebar {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
    margin-bottom: 1.5rem;
  }

  .schedule-main {
    min-width: auto;
  }
}
