/* ==========================================================
   Cynomy Clinical — Provenance Design System
   Exact Provenance SaaS Aesthetic with #EAEEF8 Sidebar
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

:root {
  /* Provenance Palette */
  --bg-sidebar: #EAEEF8;
  --bg-sidebar-hover: #DFE5F3;
  --bg-sidebar-active: #D4DEF0;
  --bg-app: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #F7F9FC;
  --bg-chip: #F1F4F9;

  --border-subtle: #E2E7F1;
  --border-strong: #D1D9E7;
  --border-light: #EEF2F8;

  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;

  --color-brand-black: #0F172A;
  --color-accent: #111827;
  --color-accent-hover: #1F2937;

  /* Semantic status colors */
  --status-critical: #EF4444;
  --status-urgent: #F59E0B;
  --status-moderate: #3B82F6;
  --status-mild: #10B981;
  --status-minor: #6B7280;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  /* Dimensions */
  --sidebar-width: 250px;
  --topbar-height: 52px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-input: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-app);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ══════════════════════════════════════════════
   PROVENANCE LAYOUT & SIDEBAR
   ══════════════════════════════════════════════ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

.app-layout__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-app);
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border-subtle);
  padding: 0.75rem 0.5rem;
}

.sidebar__header {
  padding: 0.5rem 0.75rem 1rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__brand-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__brand-text {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.sidebar__brand-sub {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.sidebar__body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0 0.25rem;
}

.sidebar__section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 0.5rem 0.35rem 0.5rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.45rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar__nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-primary);
}

.sidebar__nav-item--active {
  background: var(--bg-sidebar-active);
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar__nav-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar__nav-item--active svg {
  color: var(--text-primary);
}

.sidebar__nav-badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sidebar__footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__footer-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.12s ease;
}

.sidebar__footer-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-primary);
}

.sidebar__footer-item svg {
  width: 14px;
  height: 14px;
}

/* ══════════════════════════════════════════════
   PROVENANCE TOPBAR
   ══════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  flex-shrink: 0;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.topbar__btn-ghost:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ══════════════════════════════════════════════
   PROVENANCE HERO & INTAKE CHAT
   ══════════════════════════════════════════════ */
.provenance-hero-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem 2rem 1.5rem;
  text-align: center;
}

.provenance-hero-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.provenance-hero-sub {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-top: 0.35rem;
  margin-bottom: 2rem;
}

.provenance-input-box {
  width: 100%;
  max-width: 680px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-input);
  padding: 1rem 1.25rem 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.provenance-input-box:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 6px 24px -2px rgba(0, 0, 0, 0.08);
}

.provenance-textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.9375rem;
  color: var(--text-primary);
  resize: none;
  min-height: 48px;
  line-height: 1.5;
}

.provenance-textarea::placeholder {
  color: var(--text-muted);
}

.provenance-input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.provenance-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.provenance-chip-btn:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.provenance-send-btn {
  width: 28px;
  height: 28px;
  background: var(--color-brand-black);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.provenance-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.provenance-send-btn svg {
  width: 14px;
  height: 14px;
}

.provenance-suggested-prompts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  max-width: 680px;
  width: 100%;
}

.provenance-prompt-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.provenance-prompt-pill:hover {
  background: var(--bg-surface-secondary);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════
   CHAT STREAM CONTAINER
   ══════════════════════════════════════════════ */
.chat-stream-container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chat-bubble {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 85%;
}

.chat-bubble--ai {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.chat-bubble--user {
  align-self: flex-end;
  background: var(--color-brand-black);
  color: #FFFFFF;
}

/* ══════════════════════════════════════════════
   DATA TABLE & DASHBOARD
   ══════════════════════════════════════════════ */
.dash-content {
  padding: 1.5rem 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.dash-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dash-table {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-collapse: collapse;
}

.dash-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
}

.dash-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  vertical-align: middle;
}

.dash-table tr:hover {
  background: var(--bg-surface-secondary);
  cursor: pointer;
}

.badge-defcon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-defcon-1 { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.badge-defcon-2 { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.badge-defcon-3 { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.badge-defcon-4 { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.badge-defcon-5 { background: #F3F4F6; color: #4B5563; border: 1px solid #E5E7EB; }

/* ══════════════════════════════════════════════
   MODALS & DRAWER
   ══════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-modal);
  box-sizing: border-box;
  position: relative;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

.btn-solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background: var(--color-brand-black);
  color: #FFFFFF;
  border: 1px solid var(--color-brand-black);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}

.btn-solid:hover {
  background: var(--color-accent-hover);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover {
  background: var(--bg-surface-secondary);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
}

.btn-ghost:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.form-group {
  margin-bottom: 1.125rem;
  width: 100%;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: block;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-sans);
}

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

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════
   COOKIE CONSENT BANNER
   ══════════════════════════════════════════════ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
  z-index: 9999;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  .cookie-banner {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
    gap: 1rem;
  }
  .cookie-banner button {
    width: 100%;
  }
}

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVENESS
   ══════════════════════════════════════════════ */
@media (max-width: 860px) {
  .provenance-main-layout, .app-layout, .admin-layout {
    flex-direction: column;
    height: 100vh;
    overflow: auto;
  }
  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar__body {
    flex-direction: row;
    overflow-x: auto;
    padding: 0.5rem;
  }
  .sidebar__nav {
    flex-direction: row;
  }
  .sidebar__footer {
    flex-direction: row;
    padding: 0.5rem;
    border-top: none;
    flex-wrap: wrap;
  }
  .dash-content, .conversation-container, .admin-content {
    padding: 1rem;
  }
  .topbar {
    padding: 0.75rem 1rem;
    height: auto;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .filter-tabs-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
  .tabs-group {
    flex-wrap: wrap;
  }
  .drawer {
    width: 100%;
    right: -100%;
  }
  .hpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Language Picker ── */
.lang-picker {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  justify-content: center;
}

.lang-picker__btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-picker__btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.lang-picker__btn--active {
  background: var(--border-subtle);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* ══════════════════════════════════════════════
   MOBILE WARNING SCREEN & LABEL
   ══════════════════════════════════════════════ */
.mobile-warning-overlay {
  display: none !important;
}

@media (max-width: 860px) {
  .mobile-warning-overlay {
    display: flex !important;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
  }

  .mobile-warning-overlay.is-dismissed {
    display: none !important;
  }

  .mobile-warning-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 100%;
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-modal);
    text-align: center;
    box-sizing: border-box;
    position: relative;
    animation: mobileWarningPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes mobileWarningPop {
    from {
      opacity: 0;
      transform: scale(0.95) translateY(8px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .mobile-warning-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
  }

  .mobile-warning-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-secondary);
  }

  .mobile-warning-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
  }

  .mobile-warning-device-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #F8FAFC;
    border: 1px solid var(--border-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 1.25rem auto 0.75rem auto;
    color: var(--color-brand-black);
  }

  .mobile-warning-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
  }

  .mobile-warning-desc {
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
  }

  .mobile-warning-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-md);
    background: var(--color-brand-black);
    color: #FFFFFF;
    border: 1px solid var(--color-brand-black);
    transition: background 0.15s ease, transform 0.1s ease;
  }

  .mobile-warning-btn:active {
    transform: scale(0.98);
  }
}
