/* ==========================================================================
   Ehsaas AI - Premium Design System (Vanilla CSS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Tokens (HSL based for easy variations) */
    --color-primary-h: 172;
    --color-primary-s: 66%;
    --color-primary-l: 37%; /* Calming Medical Teal */
    
    --color-primary: hsl(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l));
    --color-primary-hover: hsl(var(--color-primary-h), var(--color-primary-s), calc(var(--color-primary-l) - 8%));
    --color-primary-light: hsl(var(--color-primary-h), var(--color-primary-s), 96%);
    --color-primary-glow: hsla(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l), 0.15);

    --color-secondary-h: 215;
    --color-secondary-s: 28%;
    --color-secondary-l: 17%; /* Elegant Charcoal/Slate */
    --color-secondary: hsl(var(--color-secondary-h), var(--color-secondary-s), var(--color-secondary-l));
    
    /* Neutral Shades */
    --bg-main: #f4f7f6;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --border-color: #e2e8f0;
    
    /* Text Colors */
    --color-text-primary: #0f172a;
    --color-text-secondary: #334155;
    --color-text-muted: #64748b;
    --color-text-light: #ffffff;
    
    /* Feedback States */
    --color-success: #10b981;
    --color-success-light: #ecfdf5;
    --color-warning: #f59e0b;
    --color-warning-light: #fffbeb;
    --color-error: #ef4444;
    --color-error-light: #fef2f2;
    --color-info: #3b82f6;
    --color-info-light: #eff6ff;

    /* Theme constants */
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-premium: 0 20px 25px -5px rgba(42, 157, 143, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    color: var(--color-primary-hover);
}

/* Layout Wrapper */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Layout */
.app-sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--color-text-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--color-primary), #48cae4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #a5f3fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex-grow: 1;
    padding: 1.5rem 1rem;
}

.sidebar-menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: #94a3b8;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition-smooth);
}

.sidebar-menu-item a:hover,
.sidebar-menu-item.active a {
    color: var(--color-text-light);
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-menu-item.active a {
    background-color: var(--color-primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.profile-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.profile-role {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main Content Area */
.app-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 2rem 2.5rem;
}

/* Top Navbar (when layout doesn't use sidebar, e.g. login or client) */
.client-navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.client-container {
    max-width: 760px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text-light);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    color: var(--color-text-light);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--color-text-secondary);
}

.btn-secondary:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-danger {
    background-color: var(--color-error);
    color: var(--color-text-light);
}

.btn-danger:hover {
    background-color: #dc2626;
    color: var(--color-text-light);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), #48cae4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-secondary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--color-text-primary);
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Login Page Layout */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    box-shadow: var(--shadow-premium);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-text {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin-top: -1.5rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Alert States */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

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

.alert-success {
    background-color: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background-color: var(--color-error-light);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: #f8fafc;
    color: var(--color-text-secondary);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50px;
    text-transform: capitalize;
}

.badge-pending {
    background-color: var(--color-warning-light);
    color: var(--color-warning);
}

.badge-completed {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

/* Grid Systems */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

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

@media (max-width: 768px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    .app-container {
        flex-direction: column;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }
    
    /* Responsive Horizontal Sidebar Toolbar for Mobile */
    .app-sidebar {
        width: 100% !important;
        height: auto;
        padding: 0;
    }
    .sidebar-header {
        padding: 1rem;
        justify-content: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .sidebar-nav {
        padding: 0.75rem 1rem;
    }
    .sidebar-menu-list {
        flex-direction: row;
        justify-content: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    .sidebar-menu-item a {
        padding: 0.5rem 0.85rem;
        font-size: 0.9rem;
    }
    .sidebar-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        background-color: rgba(0, 0, 0, 0.15);
    }
    .user-profile-info {
        margin-bottom: 0;
        flex-direction: row;
        gap: 0.5rem;
        align-items: center;
    }
    .profile-role {
        font-size: 0.7rem;
    }
    .sidebar-footer .btn {
        width: auto !important;
        padding: 0.35rem 0.75rem;
    }
    .app-content {
        padding: 1.5rem 1rem;
    }
    
    /* Responsive patient options to stack on smaller viewports */
    .patient-options {
        grid-template-columns: 1fr !important;
    }
}

/* Client Test Questionnaire Cards */
.question-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
}

.question-item:last-child {
    border-bottom: none;
}

.question-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1.25rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Touch-friendly radio buttons for patients */
.patient-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.patient-option-card {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background-color: #ffffff;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    user-select: none;
}

.patient-option-card:hover {
    border-color: var(--color-primary);
    background-color: var(--color-primary-light);
}

/* Hide standard radio but keep it accessible */
.patient-option-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Selected state */
.patient-option-card.selected {
    border-color: var(--color-primary);
    background-color: var(--color-primary-glow);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.patient-option-card.selected span {
    color: var(--color-primary-hover);
    font-weight: 600;
}

/* Severity indicators for results mapping */
.severity-pill {
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    display: inline-block;
}

.severity-minimal { background-color: #e2e8f0; color: #475569; }
.severity-mild { background-color: #d1fae5; color: #065f46; }
.severity-moderate { background-color: #fef3c7; color: #92400e; }
.severity-severe { background-color: #fee2e2; color: #991b1b; }

/* Dashboard Cards and Stats */
.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.stat-val {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-secondary);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Interactive elements */
.pulse-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-warning);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* 404/Error styling details */
.error-badge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #f1f5f9;
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* Centered Layout for Login Page */
.login-page-layout {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-body);
}

.login-page-layout .app-content {
    flex-grow: 0;
    width: 100%;
    max-width: 460px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
}

.login-page-layout .login-wrapper {
    min-height: auto;
    padding: 0;
}
