:root {
    --primary-color: #3b82f6;
    /* Modern Blue */
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --background-bg: #f1f5f9;
    --sidebar-bg: #1e293b;
    /* Slate 900 */
    --text-main: #334155;
    --text-light: #94a3b8;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.2);
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;

    /* Status Colors */
    --status-pending: #f59e0b;
    /* Amber */
    --status-progress: #3b82f6;
    /* Blue */
    --status-rep-pend: #8b5cf6;
    /* Violet */
    --status-qc: #ec4899;
    /* Pink */
    --status-sub: #10b981;
    /* Emerald */
    --status-closed: #64748b;
    /* Slate */
    --status-withdrawn: #ef4444;
    /* Red */

    --font-family: 'Outfit', sans-serif;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overscroll-behavior-y: none;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-bg);
    color: var(--text-main);
    overflow-x: hidden;
    height: 100vh;
}

/* ================= UTILITIES ================= */
.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* ================= AUTH ================= */
.auth-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-box {
    background: var(--glass-bg);
    padding: 2.5rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    text-align: center;
}

.logo-area h1 {
    font-weight: 700;
    color: var(--sidebar-bg);
    margin-bottom: 0.2rem;
}

.logo-area p {
    color: var(--secondary-color);
    margin-bottom: 2rem;
    font-weight: 300;
}

.input-group {
    position: relative;
    margin-bottom: 1.25rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}

.input-group input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 1rem;
    min-height: 1.25rem;
}

/* ================= APP LAYOUT ================= */
.app-container {
    display: flex;
    height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.badg-role {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    padding: 0.85rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: #94a3b8;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#logout-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

#logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #f8fafc;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #0f172a;
}


/* VIEW SWITCHING LOGIC */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* DASHBOARD CARDS */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.status-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid #ccc;
    transition: transform 0.2s;
}

.status-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-card h3 {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.status-card .count {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
}

/* Card Accent Colors */
.c-pending {
    border-left-color: var(--status-pending);
}

.c-progress {
    border-left-color: var(--status-progress);
}

.c-rep-pending {
    border-left-color: var(--status-rep-pend);
}

.c-qc {
    border-left-color: var(--status-qc);
}

.c-submitted {
    border-left-color: var(--status-sub);
}

.c-closed {
    border-left-color: var(--status-closed);
}

.c-withdrawn {
    border-left-color: var(--status-withdrawn);
}

/* TABLES & PANELS */
.glass-panel {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
}

select {
    padding: 0.6rem 2rem 0.6rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
    background-color: white;
    cursor: pointer;
}

.btn-icon {
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    color: #64748b;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tbody tr:hover {
    background-color: #facc151a;
    /* slight yellow tint on hover for tracking rows */
}

/* FORMS */
.form-wrapper {
    max-width: 800px;
}

.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label,
.col label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
}

.form-group input,
.form-group select,
.col input,
.col select,
.col textarea {
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
    transition: 0.2s;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
}

.ref-preview {
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 6px;
    font-family: monospace;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: 1px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #cbd5e1;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: #64748b;
}

/* MODALS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
}

.row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.col {
    flex: 1;
}

hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 1.5rem 0;
}

.small-form {
    max-width: 450px;
    margin: 0 auto;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .sidebar-nav {
        display: none;
    }

    /* Mobile Menu interaction can be added later */
    .form-row,
    .row {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Reduced Font Size for Cases Table */
#cases-table th,
#cases-table td {
    padding: 0.6rem;
    font-size: 0.8rem;
}

#cases-table .btn-icon {
    padding: 0.4rem;
    font-size: 0.8rem;
}

/* Detail View Grids */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.detail-grid p {
    font-size: 0.95rem;
    color: #334155;
    margin-bottom: 0.5rem;
}

.detail-grid strong {
    color: #64748b;
    font-weight: 500;
}

.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
    transition: 0.2s;
    width: 100%;
}

.form-group textarea:focus {
    border-color: var(--primary-color);
}

.small-form {
    padding: 2.5rem !important;
    margin: 2rem auto;
}

/* INSURED VISIT GALLERY FORM STYLES */
.iv-gallery-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    width: 100%;
}

.iv-upload-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 0;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iv-upload-box:hover {
    border-color: #94a3b8;
    background-color: #f1f5f9;
    cursor: pointer;
}

.iv-upload-placeholder {
    color: #475569;
    font-size: 0.9rem;
    padding: 10px;
    width: 100%;
}

.iv-upload-placeholder i {
    font-size: 1.5rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.iv-upload-placeholder small {
    display: block;
    margin-top: 0.5rem;
    font-weight: normal;
    color: #94a3b8;
}

.plus-icon {
    font-size: 1.5rem;
    color: #cbd5e1;
    margin-bottom: 0.2rem;
    display: block;
    line-height: 1;
}

.iv-image-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 10;
    box-sizing: border-box;
    overflow: hidden;
    display: block;
}

.iv-image-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Gallery Labels */
.iv-gallery-label {
    text-align: left;
}

.iv-title {
    font-size: 1rem;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.iv-subtitle {
    font-size: 0.85rem;
    color: #64748b;
}

.iv-btn-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

.iv-btn-delete:hover {
    background: rgba(185, 28, 28, 1);
}

.iv-preview-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.8rem;
    padding: 5px;
    text-align: center;
}
.iv-upload-box.iv-portrait { aspect-ratio: 3 / 4; }
.iv-upload-success-dot { position: absolute; top: 6px; left: 6px; background: #22c55e; color: white; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 10;}

.iv-upload-box.iv-landscape { aspect-ratio: 4 / 3; }
