:root {
    --primary-color: #2c3e50;
    --primary-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --secondary-color: #3498db;
    --secondary-gradient: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    --success-color: #2ecc71;
    --success-gradient: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    --accent-red: #e74c3c;
    --bg-color: #f4f6f9;
    /* Slightly darker than white for contrast */
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 8px;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding-bottom: 60px;
    line-height: 1.6;
}

h1,
h2,
h3,
h4 {
    color: var(--primary-color);
    margin-top: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* --- Cards & Layout --- */
.page-container,
fieldset,
.login-card,
.setup-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
}

header {
    background: var(--primary-gradient);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

header h1 {
    color: white;
    margin-bottom: 0.5rem;
}

header p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--input-bg);
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--secondary-color);
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

fieldset {
    border: 1px solid var(--border-color);
    /* Reset default fieldset border */
    background: white;
}

legend {
    font-weight: 700;
    color: var(--primary-color);
    padding: 0 10px;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Buttons (Page Wide Modern Style) --- */
button,
.btn,
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

button:active,
.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-primary {
    background: var(--secondary-gradient);
    color: white;
}

.btn-primary:hover {
    filter: brightness(110%);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* Action Buttons (Table) */
.action-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    margin-right: 5px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-pdf {
    background: #e0f2f1;
    color: #00695c;
}

.btn-pdf:hover {
    background: #b2dfdb;
}

.btn-edit {
    background: #f3e5f5;
    color: #7b1fa2;
}

.btn-edit:hover {
    background: #e1bee7;
}


/* Navigation */
.nav-bar {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-bar .logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-logo {
    height: 40px;
    width: auto;
}

.nav-bar h3 {
    margin: 0;
    font-size: 1.2rem;
    color: white;
    color: white;
    font-weight: 800;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping if needed */
}

.nav-links a {
    color: white !important;
    margin-left: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
    position: relative;
    opacity: 0.9;
}

.nav-links a:hover {
    color: white;
    opacity: 1;
    text-decoration: underline;
}

/* --- Tables --- */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    margin-top: 1rem;
    min-width: 800px;
    /* Force scroll on small screens */
}

th {
    text-align: left;
    padding: 15px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

td {
    background: white;
    padding: 15px;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

tr td:first-child {
    border-left: 1px solid var(--border-color);
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

tr td:last-child {
    border-right: 1px solid var(--border-color);
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

tr:hover td {
    background-color: #fafbfc;
}

/* Mobile Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}



/* --- Edgewater Logo & Branding --- */
.header-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Login Header Centering */
.login-header {
    text-align: center;
}

/* Ensure Header Title is White */
header h1 {
    color: white !important;
    margin-bottom: 0.5rem;
}

/* --- Complex Components --- */

/* Badge Styles */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge.admin {
    background: #fed7d7;
    color: #c53030;
}

.badge.counselor {
    background: #feebc8;
    color: #c05621;
}

.badge.crss {
    background: #c6f6d5;
    color: #2f855a;
}

/* Section Borders */
.risk-section {
    border-left: 4px solid var(--accent-red);
}

.outcome-section {
    border-left: 4px solid var(--success-color);
}

/* Utility Classes */
.radio-group label {
    display: inline-block;
    margin-right: 15px;
    font-weight: normal;
    cursor: pointer;
}

/* Checkbox Card Style */
.checkbox-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.checkbox-card:hover {
    background: #f8fafc;
    border-color: var(--secondary-color);
}

.checkbox-card input[type="checkbox"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
}

.checkbox-wrapper {
    background-color: #fff3cd;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ffeeba;
}

/* Complex Tables (Medication, Substance Use) */
.complex-table {
    width: 100%;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.complex-table th {
    background-color: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-color);
    font-size: 0.85rem;
    padding: 10px;
}

.complex-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.complex-table input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 0.95rem;
}

.complex-table input:focus {
    border: 2px solid var(--secondary-color);
    background: white;
}

/* Mental Status Exam Grid */
.mse-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 15px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.mse-grid label {
    margin: 0;
    color: var(--primary-color);
    font-weight: 600;
}

/* Hamburger Button - Desktop Default */
.hamburger-btn {
    display: none;
    /* Hidden by default on desktop */
    font-size: 1.8rem;
    color: white;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    margin-right: 15px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- Wizard Styles --- */
.wizard-nav {
    display: flex;
    justify-content: flex-start;
    /* Changed from space-between to allow alignment with gap */
    gap: 15px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 15px;
    /* More space for scrollbar */
    width: 100%;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    /* Rigorous spacing */
    flex: 0 0 100px;
    /* Don't grow, don't shrink, fixed base width */
    width: 100px;
    opacity: 0.6;
    transition: opacity 0.3s;
    position: relative;
    /* Context */
}

.step-indicator:hover {
    opacity: 1;
}

.step-indicator.active {
    opacity: 1;
    font-weight: bold;
}

.step-indicator.active .step-circle {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.step-indicator.completed .step-circle {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #bdc3c7;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    font-weight: bold;
    background: white;
    color: #7f8c8d;
    font-size: 0.9rem;
    z-index: 2;
    /* Ensure on top */
}

.step-title {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
    width: 100%;
    /* Fill the 100px container */
    word-break: break-word;
    /* Prevent overflow */
    padding: 0 5px;
    /* Padding inside the 100px */
}

.wizard-progress-bar {
    height: 6px;
    background-color: #e2e8f0;
    border-radius: 3px;
    margin-bottom: 30px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--secondary-gradient);
    width: 0%;
    transition: width 0.4s ease;
}

.wizard-step {
    display: none;
    /* JS will toggle this */
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-controls {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Modern Radio Cards */
.radio-card-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-card-label {
    flex: 1;
    min-width: 120px;
    position: relative;
    cursor: pointer;
}

.radio-card-label input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.2s;
    height: 100%;
}

.radio-card-label input:checked+.radio-card-content {
    background: #ebf8ff;
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.btn-submit {
    background: var(--success-gradient) !important;
}

/* --- Responsive (Must be last to override) --- */
@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .nav-bar {
        position: relative;
        flex-wrap: wrap;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: 10px;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        margin: 0;
        padding: 15px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        display: block;
        width: 100%;
    }

    .hamburger-btn {
        display: block;
    }

    input[type="text"],
    input[type="number"],
    select,
    textarea,
    button,
    .btn {
        min-height: 48px;
    }

    .complex-table {
        display: block;
        overflow-x: auto;
    }

    .radio-card-group {
        flex-direction: column;
    }
}

/* PWA Install Button */
.install-btn {
    background: linear-gradient(135deg, #00b09b, #96c93d);
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 176, 155, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 15px;
    margin-left: auto;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 176, 155, 0.6);
    filter: brightness(1.1);
}

.install-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 176, 155, 0.4);
}

@media (max-width: 768px) {
    .install-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        margin-right: 10px;
    }
}

/* --- User Management Page --- */
.split-view {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.user-list {
    flex: 2;
    overflow-x: auto;
    /* Handle table overflow */
}

.user-create {
    flex: 1;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
    border: 1px solid var(--border-color);
}

.btn-delete {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-delete:hover {
    background: #c0392b;
}

.btn-create {
    width: 100%;
    padding: 10px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
    margin-bottom: 10px;
}

.btn-create:hover {
    background: #27ae60;
}


/* --- Password Strength Meter --- */
.password-strength-container {
    margin-top: 5px;
    margin-bottom: 15px;
}

.meter-bg {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.strength-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-red);
    transition: width 0.3s ease, background 0.3s ease;
}

.strength-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Strength Colors */
.strength-weak {
    background: var(--accent-red);
}

.strength-medium {
    background: #f39c12;
}

.strength-strong {
    background: var(--success-color);
}

/* --- Password Validation Checklist --- */
.validation-list {
    list-style: none;
    padding: 0;
    margin: 5px 0 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.validation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.validation-item::before {
    content: "•";
    color: #cbd5e0;
    font-size: 1.2em;
    line-height: 1;
}

.validation-item.valid {
    color: var(--success-color);
}

.validation-item.valid::before {
    content: "✓";
    color: var(--success-color);
}

.validation-item.invalid {
    color: var(--text-muted);
}

/* Responsive adjustment for User Management */
@media (max-width: 768px) {
    .split-view {
        flex-direction: column;
    }

    .user-create {
        width: 100%;
        box-sizing: border-box;
        margin-top: 20px;
    }
}

/* --- Form Validation Summary --- */
.form-validation-summary {
    background-color: #feebc8;
    border: 1px solid #fbd38d;
    color: #c05621;
    padding: 1rem;
    margin-bottom: 2rem;
    border-radius: var(--radius);
    display: none;
    /* JS toggles this */
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 5px solid #e74c3c;
}

.form-validation-summary h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #9c4221;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-validation-summary ul {
    margin: 0;
    padding-left: 1.5rem;
}

.form-validation-summary li {
    margin-bottom: 0.25rem;
    color: #a04000;
}