:root {
    --primary-color: #0ea5e9;
    /* Sky 500 */
    --primary-dark: #0284c7;
    /* Sky 600 */
    --secondary-color: #22c55e;
    /* Green 500 */
    --bg-color: #f8fafc;
    /* Lighter blue-grey for modern feel */
    --sidebar-bg: #1e293b;
    /* Slate 800 */
    --sidebar-width: 280px;
    --header-height: 70px;
    --ai-color: #8b5cf6;
    /* Violet */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: #1f2937;
    -webkit-tap-highlight-color: transparent;
}

/* Layout Structure */
.app-container {
    display: flex;
    /* Hidden by default via JS if not logged in */
    min-height: 100vh;
}

/* --- Login Screen Styles --- */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f1f5f9;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
}

/* --- Industry Standard Sidebar (Desktop) --- */
#main-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid #334155;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the logo */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-menu {
    padding: 24px 16px;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
    color: #94a3b8;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.2);
}

.nav-item i {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
}

/* --- Main Content Area --- */
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s, width 0.3s;
}

/* Modern Header */
.top-header {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
}

.main-content {
    padding: 32px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* --- Cards & Visuals --- */
.view-section {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 24px;
    transition: transform 0.2s;
}

.metric-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover,
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 4px;
    font-weight: 500;
}

/* Tables */
.table-container {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#patient-table th,
#followup-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

#patient-table td,
#followup-table td {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.95rem;
}

#patient-table tr:last-child td,
#followup-table tr:last-child td {
    border-bottom: none;
}

#patient-table tbody tr:hover,
#followup-table tbody tr:hover {
    background-color: #f8fafc;
    cursor: pointer;
}

/* Detail View Grid */
.detail-item {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-value {
    font-size: 1rem;
    color: #0f172a;
    font-weight: 500;
}

/* Filter Controls */
.filter-select {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    min-width: 120px;
    transition: all 0.2s;
}

.filter-select:focus {
    box-shadow: 0 0 0 2px var(--primary-color);
    border-color: var(--primary-color);
}

/* --- LOADING SHIMMER ANIMATION --- */
.shimmer-wrapper {
    width: 100%;
}

.shimmer-row {
    display: flex;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    gap: 16px;
}

.shimmer-cell {
    height: 20px;
    background: #f1f5f9;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.shimmer-cell::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0,
            rgba(255, 255, 255, 0.4) 20%,
            rgba(255, 255, 255, 0.7) 60%,
            rgba(255, 255, 255, 0));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* --- MODAL STYLES (Shared) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content-box {
    background: white;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

/* Onboarding Modal Specifics */
.onboarding-content {
    max-width: 600px;
    text-align: center;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #cbd5e1;
    transition: all 0.3s;
}

.step-dot.active {
    background-color: var(--primary-color);
    width: 24px;
    border-radius: 12px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- AI STYLES --- */
.ai-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-body {
    padding: 24px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
}

/* Markdown Formatting within AI Body */
.ai-body h1,
.ai-body h2,
.ai-body h3,
.ai-body h4 {
    font-weight: 700;
    color: #1e293b;
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

.ai-body h1 {
    font-size: 1.5em;
}

.ai-body h2 {
    font-size: 1.25em;
}

.ai-body h3 {
    font-size: 1.1em;
}

.ai-body p {
    margin-bottom: 1em;
}

.ai-body ul,
.ai-body ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.ai-body ul {
    list-style-type: disc;
}

.ai-body ol {
    list-style-type: decimal;
}

.ai-body strong {
    color: #6d28d9;
    font-weight: 600;
}

.ai-body blockquote {
    border-left: 4px solid #ddd6fe;
    padding-left: 1rem;
    font-style: italic;
    color: #6b7280;
    margin-bottom: 1em;
}

.ai-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
}

.ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(139, 92, 246, 0.4);
}

.ai-btn:active {
    transform: translateY(0);
}

/* Loading Spinner */
.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #8b5cf6;
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
    margin-right: 4px;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* --- STEPPER STYLES --- */
.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s;
    cursor: pointer;
    /* Clickable */
}

.step-circle.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 4px #e0f2fe;
}

.step-circle.inactive {
    background-color: #e2e8f0;
    color: #64748b;
}

.step-line {
    height: 2px;
    flex: 1;
    background-color: #e2e8f0;
    margin: 0 10px;
}

.step-line.active {
    background-color: var(--primary-color);
}

/* Mobile Adjustments */
#mobile-nav-toggle {
    display: none;
}

#nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 1024px) {
    #main-sidebar {
        transform: translateX(-100%);
    }

    #main-sidebar.open {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0;
        width: 100%;
    }

    #mobile-nav-toggle {
        display: block;
    }

    .top-header {
        padding: 0 16px;
        justify-content: space-between;
    }

    .main-content {
        padding: 16px;
    }

    /* Analytics Grid on Mobile */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* UI Fix for Dashboard Buttons on Mobile */
    #dashboard-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #dashboard-filters {
        width: 100%;
        flex-wrap: wrap;
    }
}
