/* ============================================================
   JuniorDoctor.net – Clinical Clerking Assistant
   style.css – Custom styles supplementing Tailwind CDN
   ============================================================ */

/* -----------------------------------------------
   CSS Variables & Design Tokens
   ----------------------------------------------- */
:root {
    --color-brand:        #2563eb;
    --color-brand-light:  #dbeafe;
    --color-critical:     #dc2626;
    --color-urgent:       #ea580c;
    --color-moderate:     #ca8a04;
    --color-low:          #16a34a;
    --radius-card:        0.75rem;
    --shadow-card:        0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
    --transition-fast:    150ms ease;
    --transition-normal:  250ms ease;
}

/* -----------------------------------------------
   Base Typography
   ----------------------------------------------- */
body {
    font-size: 15px;
    line-height: 1.6;
}

h1, h2, h3, h4 {
    letter-spacing: -0.01em;
}

/* -----------------------------------------------
   Category Filter Buttons
   ----------------------------------------------- */
.category-filter-btn {
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}
.category-filter-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}
.category-filter-btn.active {
    background: var(--color-brand);
    color: #ffffff;
    border-color: var(--color-brand);
}
.dark .category-filter-btn {
    color: #9ca3af;
    border-color: #374151;
}
.dark .category-filter-btn:hover {
    background: #1f2937;
    color: #e5e7eb;
}
.dark .category-filter-btn.active {
    background: var(--color-brand);
    color: #ffffff;
    border-color: var(--color-brand);
}

/* -----------------------------------------------
   Module Cards
   ----------------------------------------------- */
.module-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform var(--transition-fast),
                box-shadow var(--transition-fast),
                border-color var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-brand);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
}
.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
    border-color: #bfdbfe;
}
.module-card:hover::before {
    transform: scaleX(1);
}
.module-card:active {
    transform: translateY(0);
}
.dark .module-card {
    background: #111827;
    border-color: #1f2937;
}
.dark .module-card:hover {
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px 0 rgb(0 0 0 / 0.3);
}

/* -----------------------------------------------
   Sidebar Nav Links
   ----------------------------------------------- */
.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background var(--transition-fast),
                color var(--transition-fast);
    line-height: 1.4;
}
.sidebar-nav-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
}
.sidebar-nav-link.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}
.dark .sidebar-nav-link {
    color: #9ca3af;
}
.dark .sidebar-nav-link:hover {
    background: #1e3a5f;
    color: #93c5fd;
}
.dark .sidebar-nav-link.active {
    background: #1e3a5f;
    color: #60a5fa;
}

/* -----------------------------------------------
   Sidebar Scrollbar (custom thin)
   ----------------------------------------------- */
.sidebar-scrollbar::-webkit-scrollbar {
    width: 4px;
}
.sidebar-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-scrollbar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}
.dark .sidebar-scrollbar::-webkit-scrollbar-thumb {
    background: #374151;
}

/* -----------------------------------------------
   Accordion
   ----------------------------------------------- */
.accordion-body {
    animation: accordionOpen 0.2s ease-out;
}
.accordion-body.hidden {
    animation: none;
}
.accordion-chevron.rotated {
    transform: rotate(180deg);
}

@keyframes accordionOpen {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -----------------------------------------------
   Checklist Items
   ----------------------------------------------- */
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}
.checklist-item:hover {
    background: #f9fafb;
}
.dark .checklist-item:hover {
    background: #1f2937;
}
.checklist-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-top: 0.15rem;
    accent-color: var(--color-brand);
    cursor: pointer;
    flex-shrink: 0;
}
.checklist-item.checked .checklist-label {
    text-decoration: line-through;
    color: #9ca3af;
}
.dark .checklist-item.checked .checklist-label {
    color: #6b7280;
}
.checklist-label {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.5;
    transition: color var(--transition-fast), text-decoration var(--transition-fast);
}
.dark .checklist-label {
    color: #d1d5db;
}

/* -----------------------------------------------
   Priority Badges
   ----------------------------------------------- */
.priority-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.priority-critical {
    background: #fee2e2;
    color: #991b1b;
}
.priority-urgent {
    background: #ffedd5;
    color: #9a3412;
}
.priority-moderate {
    background: #fef9c3;
    color: #854d0e;
}
.priority-low {
    background: #dcfce7;
    color: #166534;
}
.dark .priority-critical  { background: #450a0a; color: #fca5a5; }
.dark .priority-urgent    { background: #431407; color: #fdba74; }
.dark .priority-moderate  { background: #422006; color: #fde047; }
.dark .priority-low       { background: #052e16; color: #86efac; }

/* -----------------------------------------------
   Category Badges (module header)
   ----------------------------------------------- */
.badge-medical    { background: #dbeafe; color: #1d4ed8; }
.badge-surgical   { background: #dcfce7; color: #166534; }
.badge-examinations { background: #f3e8ff; color: #7e22ce; }
.dark .badge-medical       { background: #1e3a8a; color: #93c5fd; }
.dark .badge-surgical      { background: #052e16; color: #86efac; }
.dark .badge-examinations  { background: #3b0764; color: #d8b4fe; }

/* -----------------------------------------------
   Differentials Table
   ----------------------------------------------- */
.differentials-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.375rem;
}
.differentials-table tr td {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    background: #f9fafb;
    transition: background var(--transition-fast);
}
.dark .differentials-table tr td {
    background: #1f2937;
}
.differentials-table tr:hover td {
    background: #eff6ff;
}
.dark .differentials-table tr:hover td {
    background: #1e3a5f;
}
.differentials-table tr td:first-child {
    border-radius: 0.5rem 0 0 0.5rem;
    font-weight: 500;
    color: #111827;
}
.dark .differentials-table tr td:first-child {
    color: #f3f4f6;
}
.differentials-table tr td:last-child {
    border-radius: 0 0.5rem 0.5rem 0;
    color: #6b7280;
}
.dark .differentials-table tr td:last-child {
    color: #9ca3af;
}

/* -----------------------------------------------
   Investigations Table
   ----------------------------------------------- */
.investigations-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #f9fafb;
    margin-bottom: 0.375rem;
    transition: background var(--transition-fast);
}
.investigations-row:hover {
    background: #eff6ff;
}
.dark .investigations-row {
    background: #1f2937;
}
.dark .investigations-row:hover {
    background: #1e3a5f;
}
.investigations-test {
    font-weight: 600;
    color: #111827;
}
.dark .investigations-test {
    color: #f3f4f6;
}
.investigations-rationale {
    color: #6b7280;
}
.dark .investigations-rationale {
    color: #9ca3af;
}

/* -----------------------------------------------
   Red Flag / Senior Tip Items
   ----------------------------------------------- */
.red-flag-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: #b91c1c;
    border-bottom: 1px solid #fee2e2;
}
.dark .red-flag-item {
    color: #fca5a5;
    border-color: #450a0a;
}
.red-flag-item:last-child {
    border-bottom: none;
}

.senior-tip-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #78350f;
    line-height: 1.6;
}
.dark .senior-tip-item {
    background: #1c1407;
    border-color: #713f12;
    color: #fcd34d;
}

/* -----------------------------------------------
   OSCE Mode
   ----------------------------------------------- */
body.osce-mode .osce-reveal-target {
    background: #1e293b;
    color: transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    position: relative;
}
body.osce-mode .osce-reveal-target::after {
    content: 'Click to reveal';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
}
body.osce-mode .osce-reveal-target.revealed {
    background: transparent;
    color: inherit;
}
body.osce-mode .osce-reveal-target.revealed::after {
    display: none;
}

/* -----------------------------------------------
   Progress Bar
   ----------------------------------------------- */
.progress-bar-outer {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.dark .progress-bar-outer {
    background: #374151;
}
.progress-bar-inner {
    height: 100%;
    background: var(--color-brand);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* -----------------------------------------------
   Animations
   ----------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.3s ease-out both;
}
.fade-in-delay-1 { animation-delay: 0.05s; }
.fade-in-delay-2 { animation-delay: 0.1s; }
.fade-in-delay-3 { animation-delay: 0.15s; }
.fade-in-delay-4 { animation-delay: 0.2s; }

/* -----------------------------------------------
   Module section entry stagger
   ----------------------------------------------- */
.section-card {
    animation: fadeIn 0.25s ease-out both;
}
.section-card:nth-child(1) { animation-delay: 0.0s; }
.section-card:nth-child(2) { animation-delay: 0.06s; }
.section-card:nth-child(3) { animation-delay: 0.12s; }
.section-card:nth-child(4) { animation-delay: 0.18s; }

/* -----------------------------------------------
   Print Styles
   ----------------------------------------------- */
@media print {
    .no-print,
    #top-nav,
    #sidebar,
    #hero-section,
    #mobile-overlay,
    footer,
    #print-btn,
    #print-btn-module,
    #ai-input,
    .osce-mode-indicator {
        display: none !important;
    }

    body {
        background: white !important;
        font-size: 12pt;
        color: black !important;
    }

    #main-content {
        max-width: 100%;
        padding: 0;
    }

    #module-view {
        display: block !important;
    }

    .accordion-body {
        display: block !important;
    }

    .bg-white,
    .dark\:bg-gray-900 {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    h1, h2, h3 {
        color: black !important;
    }

    .priority-critical { background: #fee2e2 !important; color: #991b1b !important; }
    .priority-urgent   { background: #ffedd5 !important; color: #9a3412 !important; }
    .priority-moderate { background: #fef9c3 !important; color: #854d0e !important; }
    .priority-low      { background: #dcfce7 !important; color: #166534 !important; }

    .senior-tip-item {
        background: #fffbeb !important;
        border: 1px solid #fde68a !important;
        color: #78350f !important;
    }

    .module-card { break-inside: avoid; }

    @page {
        margin: 1.5cm;
    }

    /* Print header */
    #module-view::before {
        content: 'JuniorDoctor.net – Clinical Clerking Assistant | Educational Use Only';
        display: block;
        font-size: 9pt;
        color: #666;
        margin-bottom: 1cm;
        border-bottom: 1px solid #ccc;
        padding-bottom: 0.3cm;
    }
}

/* -----------------------------------------------
   Responsive: sidebar on mobile
   ----------------------------------------------- */
@media (max-width: 1023px) {
    #sidebar.open {
        transform: translateX(0) !important;
    }
}

/* -----------------------------------------------
   Utility: smooth transitions for dark mode
   ----------------------------------------------- */
*, *::before, *::after {
    transition-property: background-color, border-color, color;
    transition-duration: 200ms;
    transition-timing-function: ease;
}

/* Override transition for elements that shouldn't animate bg */
input, button, a, svg, path {
    transition-duration: 150ms;
}
