/* ============================================
   CSS Variables - Dynamically set via PHP in header
   ============================================ */
:root {
    --primary: #0a2b4e;
    --primary-dark: #051a30;
    --primary-light: #1e4a76;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-700: #374151;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.2, 0.9, 0.4, 1.1);
    --button-radius: 60px;
    --card-shadow: var(--shadow-md);
}

/* Dark mode (optional) */
body.dark-mode {
    background: #1e293b;
    color: #f1f5f9;
}
body.dark-mode .card {
    background: #334155;
    color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: #1e293b;
    line-height: 1.5;
    overflow-x: hidden;
}

/* App wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ========== SIDEBAR (Mobile First) ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: rgba(10, 43, 78, 0.98);
    backdrop-filter: blur(12px);
    color: white;
    transition: left var(--transition-smooth);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 20px rgba(0,0,0,0.2);
    overflow-y: auto;
}
.sidebar.open {
    left: 0;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
    font-size: 1.3rem;
    font-weight: 800;
}
.close-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1.5rem;
    color: #e2e8f0;
    text-decoration: none;
    transition: all 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    padding-left: 2rem;
}
.sidebar-footer {
    padding: 1rem;
    text-align: center;
    font-size: 0.7rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    display: none;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo-small {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}
.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary);
}
.content-container {
    padding: 1rem;
    flex: 1;
}

/* ========== DESKTOP LAYOUT - Centered and Uniform ========== */
@media (min-width: 768px) {
    .sidebar {
        left: 0;
        position: sticky;
        top: 0;
        height: 100vh;
        width: 260px;
    }
    .sidebar-overlay, .close-sidebar, .menu-toggle {
        display: none;
    }
    .main-content {
        margin-left: 100px;
        width: calc(100% - 260px);
    }
    .mobile-header {
        display: none;
    }
    .bottom-nav {
        display: none;
    }
    /* CENTER CONTENT and make uniform */
    .content-container {
        max-width: 1000px;
        width: 100%;
        margin: 0 auto;
        padding: 2rem 1.5rem;
    }
    /* Optional: for very wide screens, limit max-width further */
    @media (min-width: 1200px) {
        .content-container {
            max-width: 1100px;
        }
    }
    /* Ensure all page headers and grids are consistent */
    .page-header {
        margin-bottom: 1.5rem;
    }
    .dashboard-grid, .cases-grid, .client-list, .task-list, .instructions-list, .documents-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 1.5rem;
    }
    .card {
        margin-bottom: 0;
    }
}

/* ========== CARDS & UI COMPONENTS ========== */
.card {
    background: white;
    border-radius: 28px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
    border: 1px solid rgba(0,0,0,0.03);
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 40px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status.active { background: #e0f2fe; color: #0284c7; }
.status.urgent { background: #fee2e2; color: #b91c1c; animation: pulse 1.5s infinite; }
.status.pending { background: #fef3c7; color: #b45309; }
.status.completed { background: #dcfce7; color: #15803d; }
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* Buttons */
.btn-primary, .fab-btn, button[type="submit"] {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--button-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:active, .fab-btn:active {
    transform: scale(0.96);
}
.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 30px;
    background: var(--gray-200);
    border: none;
    cursor: pointer;
}
.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}
.btn-cancel {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 0.75rem 1.5rem;
    border-radius: 60px;
}

/* Forms */
input, select, textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 60px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #f8fafc;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(30,74,118,0.1);
    background: white;
}
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gray-700);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 1rem;
    z-index: 200;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.75rem;
    transition: var(--transition-fast);
}
.bottom-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
}
.bottom-nav-item.active, .bottom-nav-item:active {
    color: var(--primary);
    transform: translateY(-2px);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 0.8rem;
    font-size: 0.7rem;
    background: white;
    border-top: 1px solid var(--gray-200);
    margin-top: 1rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}
.alert.success {
    background: #dcfce7;
    color: #15803d;
    border-left: 4px solid #15803d;
}
.alert.error {
    background: #fee2e2;
    color: #b91c1c;
    border-left: 4px solid #b91c1c;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}
.page-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    overflow-y: auto;
    padding: 1rem;
}
.modal-content {
    background: white;
    border-radius: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: modalFadeIn 0.3s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.modal-content h3 {
    padding: 1.2rem 1.5rem 0.5rem 1.5rem;
    margin: 0;
    border-bottom: 1px solid var(--gray-200);
}
.modal-body {
    padding: 1.5rem;
}
.modal .close {
    float: right;
    font-size: 1.8rem;
    font-weight: 300;
    cursor: pointer;
    color: #94a3b8;
    margin-right: 1rem;
    margin-top: 0.5rem;
}
.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Utilities */
.empty-state {
    text-align: center;
    padding: 3rem;
}

.badge {
    background: var(--accent);
    color: white;
    border-radius: 20px;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    margin-left: auto;
}

/* ========== ADDITIONAL STATUS BADGES & TOASTS ========== */
.status-open { background: #e0f2fe; color: #0284c7; }
.status-pending { background: #fef3c7; color: #b45309; }
.status-adjourned { background: #fef9c3; color: #854d0e; }
.status-closed { background: #dcfce7; color: #15803d; }
.status-urgent { background: #fee2e2; color: #b91c1c; animation: pulse 1.5s infinite; }
.status-archived { background: #f1f5f9; color: #475569; }

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 40px;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }