/*
 * EDSS - Enterprise Decision Support System
 * Tailwind is loaded via CDN in the HTML shell.
 * This file holds custom overrides & EDSS-specific styles.
 */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  --edss-primary:   #1e3a5f;
  --edss-secondary: #2d6a9f;
  --edss-accent:    #4ecdc4;
  --edss-bg:        #f8fafc;
  --edss-surface:   #ffffff;
  --edss-text:      #1e293b;
  --edss-muted:     #64748b;
  --edss-border:    #e2e8f0;
  --edss-radius:    0.75rem;
  --edss-shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Base Reset ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--edss-bg);
  color: var(--edss-text);
  margin: 0;
  min-height: 100vh;
}

/* ── Layout Shell ───────────────────────────────────────── */
.edss-shell {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Card ───────────────────────────────────────────────── */
.edss-card {
  background: var(--edss-surface);
  border: 1px solid var(--edss-border);
  border-radius: var(--edss-radius);
  box-shadow: var(--edss-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── Phase Badge ────────────────────────────────────────── */
.edss-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.edss-badge--awaiting   { background: #fef3c7; color: #92400e; }
.edss-badge--generated  { background: #dbeafe; color: #1e40af; }
.edss-badge--complete   { background: #d1fae5; color: #065f46; }

/* ── Buttons ────────────────────────────────────────────── */
.edss-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--edss-radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.edss-btn--primary {
  background: var(--edss-primary);
  color: #fff;
}
.edss-btn--primary:hover {
  background: var(--edss-secondary);
  box-shadow: 0 2px 8px rgba(30,58,95,.25);
}
.edss-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Form Controls ──────────────────────────────────────── */
.edss-textarea {
  width: 100%;
  min-height: 6rem;
  padding: 0.75rem;
  border: 1px solid var(--edss-border);
  border-radius: var(--edss-radius);
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 150ms ease;
}
.edss-textarea:focus {
  outline: none;
  border-color: var(--edss-secondary);
  box-shadow: 0 0 0 3px rgba(45,106,159,.15);
}

/* ── Option Tags ─────────────────────────────────────────── */
.edss-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid var(--edss-border);
  border-radius: 9999px;
  font-size: 0.8125rem;
}
.edss-tag-remove {
  cursor: pointer;
  color: var(--edss-muted);
  font-weight: 700;
}
.edss-tag-remove:hover { color: #dc2626; }

/* ── Loading Spinner ────────────────────────────────────── */
.edss-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--edss-border);
  border-top-color: var(--edss-primary);
  border-radius: 50%;
  animation: edss-spin 0.6s linear infinite;
}
@keyframes edss-spin {
  to { transform: rotate(360deg); }
}

/* ── Inline Banner (replaces alert()) ───────────────────── */
.edss-inline-banner {
  animation: edss-slide-down 0.25s ease-out;
}
@keyframes edss-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Status Messages ───────────────────────────────────── */
.edss-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--edss-radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.edss-alert--error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.edss-alert--success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* ══════════════════════════════════════════════════════════
   PRINT STYLES — PDF Export
   ══════════════════════════════════════════════════════════ */
@media print {
  /* Hide everything except the report */
  header,
  footer,
  #state-context,
  #state-loading,
  #state-questionnaire,
  #state-deep-analysis,
  .edss-inline-banner,
  .edss-report-actions {
    display: none !important;
  }

  /* Show the report state */
  #state-report {
    display: block !important;
  }

  /* Reset page */
  body {
    background: white;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #main-content-wrapper {
    max-width: 100% !important;
    margin: 0;
    padding: 0;
  }

  main {
    padding: 0 !important;
  }

  /* Flatten cards for print */
  #state-report > div {
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 1rem;
  }

  /* A4 margins */
  @page {
    size: A4;
    margin: 1.5cm 2cm;
  }

  /* Force background colors to print (diagnostic circles, badges) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}