@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;1,9..40,400&family=JetBrains+Mono:wght@500&family=Sora:wght@600;700&display=swap');

:root {
    --fcs-primary: #0D9488;
    --fcs-primary-light: color-mix(in srgb, var(--fcs-primary) 80%, white);
    --fcs-primary-dark: color-mix(in srgb, var(--fcs-primary) 80%, black);
    --fcs-secondary: #6366F1;
    --fcs-accent: #F59E0B;
    --fcs-text: #1e293b;
    --fcs-text-light: #64748b;
    --fcs-background: #ffffff;
    --fcs-surface: #f8fafc;
    --fcs-border: #e2e8f0;
    --fcs-success: #16a34a;
    --fcs-warning: #d97706;
    --fcs-danger: #dc2626;
}

[data-theme="dark"] {
    --fcs-text: #f1f5f9;
    --fcs-text-light: #94a3b8;
    --fcs-background: #0f172a;
    --fcs-surface: #1e293b;
    --fcs-border: #334155;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --fcs-text: #f1f5f9;
        --fcs-text-light: #94a3b8;
        --fcs-background: #0f172a;
        --fcs-surface: #1e293b;
        --fcs-border: #334155;
    }
}

/* ============================================ */
/* BASE — shared by all templates               */
/* ============================================ */
body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--fcs-background);
    color: var(--fcs-text);
}
h1, h2, h3, h4, h5, h6 {
    font-family: 'Sora', sans-serif;
}
.card {
    background-color: var(--fcs-surface);
    border-radius: 12px;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn {
    min-height: 44px;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
    background: var(--fcs-primary);
    color: #fff;
    border: 1px solid var(--fcs-primary);
}
.btn-secondary {
    border: 1px solid var(--fcs-primary);
    color: var(--fcs-primary);
    background: transparent;
}
.btn-ghost {
    color: var(--fcs-text-light);
    background: transparent;
    border: 1px solid transparent;
}
.btn-ghost:hover {
    background: var(--fcs-surface);
}
.btn-danger {
    background: var(--fcs-danger);
    color: #fff;
    border: 1px solid var(--fcs-danger);
}
.badge-active,
.badge-confirmed {
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
}
.badge-pending,
.badge-partial {
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
}
.badge-inactive,
.badge-cancelled {
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
}
.fcs-skeleton {
    animation: fcs-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background: var(--fcs-border);
    border-radius: 8px;
}
@keyframes fcs-pulse {
    50% { opacity: 0.5; }
}

/* ============================================ */
/* Layout templates (after dark mode per spec) */
/* ============================================ */
[data-layout="modern"] .card {
    padding: 20px;
    border: 1px solid var(--fcs-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
[data-layout="modern"] .card:hover {
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
[data-layout="modern"] .dashboard-stats-grid {
    gap: 24px;
}
[data-layout="modern"] table.data-table td,
[data-layout="modern"] table.data-table th {
    padding: 12px 16px;
}
[data-layout="modern"] .dashboard-widget {
    padding: 20px;
}

[data-layout="compact"] {
    font-size: 14px;
}
[data-layout="compact"] .card {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--fcs-border);
    box-shadow: none;
}
[data-layout="compact"] .dashboard-stats-grid {
    gap: 12px;
}
[data-layout="compact"] table.data-table td,
[data-layout="compact"] table.data-table th {
    padding: 8px 12px;
}
[data-layout="compact"] .dashboard-widget {
    padding: 12px;
}
[data-layout="compact"] .btn {
    min-height: 36px;
    padding: 6px 12px;
}

[data-layout="clinical"] {
    font-size: 16px;
}
[data-layout="clinical"] h1 { font-size: 28px; font-weight: 700; }
[data-layout="clinical"] h2 { font-size: 22px; font-weight: 600; }
[data-layout="clinical"] .card {
    border-left: 4px solid var(--fcs-primary);
    border-radius: 4px;
    padding: 16px;
    box-shadow: none;
}
[data-layout="clinical"] .clinical-value {
    font-size: 18px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--fcs-text);
}
[data-layout="clinical"] .badge { font-weight: 700; }
[data-layout="clinical"] table.data-table td { font-size: 15px; }

[data-layout="minimal"] .card {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 12px 8px;
}
[data-layout="minimal"] .card:hover {
    background-color: var(--fcs-surface);
}
[data-layout="minimal"] .btn {
    border: 1px solid var(--fcs-border);
    background: transparent;
    color: var(--fcs-text);
}
[data-layout="minimal"] .btn-primary {
    background: var(--fcs-primary);
    color: white;
    border-color: var(--fcs-primary);
}
[data-layout="minimal"] .btn-danger {
    background: var(--fcs-danger);
    color: white;
    border-color: var(--fcs-danger);
}
[data-layout="minimal"] .sidebar-nav-label {
    display: none;
}
[data-layout="minimal"] .dashboard-stats-grid { gap: 8px; }
[data-layout="minimal"] table.data-table {
    border-collapse: collapse;
}
[data-layout="minimal"] table.data-table td,
[data-layout="minimal"] table.data-table th {
    padding: 8px;
    border-bottom: 1px solid var(--fcs-border);
}

/* Form focus / validation (Section 5) */
input:not([type="checkbox"]):not([type="radio"]),
textarea, select {
    color: var(--fcs-text) !important;
    background-color: var(--fcs-background) !important;
    border-color: var(--fcs-border) !important;
    min-height: 44px;
    border-radius: 8px;
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--fcs-primary);
    outline-offset: 1px;
}
.field-error input,
.field-error textarea,
.field-error select {
    border-color: var(--fcs-danger) !important;
}
input::placeholder, textarea::placeholder {
    color: var(--fcs-text-light) !important;
}

/* ============================================================
   Critical app shell — keeps layout usable if Tailwind/Vite fails
   (sidebar column, main flex, mobile bottom bar). Safe with Vite on.
   ============================================================ */
.fcs-app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
@media (min-width: 768px) {
    .fcs-app-shell {
        flex-direction: row;
        align-items: stretch;
    }
}

aside.fcs-sidebar {
    display: none;
}
@media (min-width: 768px) {
    aside.fcs-sidebar {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        width: 14rem;
        max-width: 16rem;
        min-height: 100vh;
        border-right: 1px solid var(--fcs-border);
        background: var(--fcs-surface);
    }
}

.fcs-main-column {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

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

header.fcs-top-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
}
@media (min-width: 768px) {
    header.fcs-top-nav {
        gap: 1rem;
    }
}

@media (min-width: 768px) {
    .fcs-mobile-drawer {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
    }
}

nav.fcs-mobile-nav {
    display: flex;
}
@media (min-width: 768px) {
    nav.fcs-mobile-nav {
        display: none !important;
    }
}

.fcs-mobile-nav-active {
    font-weight: 600;
}

/* Drawer: never block desktop clicks */
.fcs-mobile-drawer {
    pointer-events: none;
}
.fcs-mobile-drawer > * {
    pointer-events: auto;
}

/* Buttons stay clickable */
button.btn,
a.btn,
.fcs-nav-link {
    cursor: pointer;
    touch-action: manipulation;
}
