/*
 * Aeza Lawyer Platform - Global Styles
 *
 * TABLE OF CONTENTS (search for === SECTION_NAME ===)
 * ─────────────────────────────────────────────────────
 * 1. === VARIABLES ===        CSS custom properties & brand palette
 * 2. === RESET & BASE ===     Box-model reset, body, links, typography
 * 3. === LAYOUT ===           App container, sidebar, main content
 * 4. === COMPONENTS ===       Logo, nav, buttons, cards, forms, badges
 * 5. === TABLES ===           Table styles, sortable headers
 * 6. === SEARCH & FILTER ===  Search bar, filter pills, pagination
 * 7. === QUILL EDITOR ===     Rich text editor dark/light overrides
 * 8. === LIGHT THEME ===      Light mode variable overrides
 * 9. === SIDEBAR TOGGLE ===   Sidebar toggle button positioning
 * 10. === RESPONSIVE ===      Mobile breakpoints, mobile menu
 * 11. === TOAST ===           Toast notification styles
 * 12. === MODALS ===          Modal dialog styles
 */

:root {
    /* Brand Palette */
    --bg-dark: #2D2A32;
    --text-light: #FAFDF6;
    --accent-orange: #FC9E4F;
    --accent-teal: #66999B;
    --accent-green: #D7F2BA;

    /* Semantic Variables */
    --bg-primary: var(--bg-dark);
    --bg-secondary: #3d3a43;
    /* Slightly lighter for cards */
    --bg-tertiary: #4d4a53;
    /* Inputs, hover states */

    --text-primary: var(--text-light);
    --text-secondary: #aaa8af;
    --text-muted: #78767d;

    --primary: var(--accent-teal);
    --primary-hover: #7baeb0;

    --action: var(--accent-orange);
    --action-hover: #fdae6f;

    --success: var(--accent-green);
    --danger: #ef4444;
    --border: #44414a;

    --font-main: 'Outfit', sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    font-size: 15px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-muted {
    color: var(--text-secondary);
}

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

.sidebar {
    width: 260px;
    height: 100vh;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    position: relative;
    /* For absolute positioning of toggle button */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    overflow: hidden;
    /* Hide text when collapsed */
    z-index: 50;
}

.sidebar.collapsed {
    width: 80px;
    padding: 1.5rem 0.75rem;
    /* Tighter padding */
    align-items: center;
}

.sidebar.collapsed .logo span,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .logout-text,
.sidebar.collapsed .toggle-separator {
    display: none;
}

.sidebar.collapsed .logo {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    text-align: center;
    width: 100%;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
    width: 44px;
    /* Fix width for centering */
    height: 44px;
    margin: 0 auto;
}

/* Theme Toggle in Collapsed Mode */
.sidebar.collapsed .theme-toggle-icons {
    margin: 0 auto 1rem auto;
    flex-direction: column;
    /* Stack icons */
    padding: 0.5rem;
    gap: 0.5rem;
    width: 40px;
}

.sidebar.collapsed .logout-btn {
    justify-content: center;
    padding: 0.75rem;
    width: 44px;
    margin: 0 auto;
}

/* Sidebar Toggle Arrow */
.sidebar-toggle-btn svg {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

/* Components */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
}

.logo span {
    color: var(--accent-orange);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent-teal);
    background-color: rgba(102, 153, 155, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
    gap: 0.5rem;
}

.template-lang-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.template-lang-btn.active {
    background: var(--action);
    color: #1a1a1a;
    border-color: var(--action);
}

.btn-primary {
    background-color: var(--action);
    color: #1a1a1a;
    /* Dark text on orange provides better contrast */
}

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-block {
    width: 100%;
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
}

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

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-new {
    background: rgba(85, 221, 224, 0.15);
    color: var(--accent-teal);
}

.badge-intake_sent {
    background: rgba(252, 158, 79, 0.15);
    color: var(--accent-orange);
}

.badge-review {
    background: rgba(215, 242, 186, 0.15);
    color: var(--accent-green);
}

.badge-closed {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

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

.table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Sortable Headers */
.table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.table th.sortable:hover {
    color: var(--text-primary);
}

.table th.sortable.active-sort {
    color: var(--accent-teal);
}

.table th .sort-icon {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    opacity: 0.7;
}

/* Search & Filter Bar */
.search-filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.search-wrapper:focus-within .search-icon {
    color: var(--primary);
}

.search-input {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 42px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    transition: all 0.25s;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 153, 155, 0.15);
    background: var(--bg-secondary);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.search-clear:hover {
    background: var(--border);
    color: var(--text-primary);
}

.filter-pills-container {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Filter Pills */
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.filter-pill.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    line-height: 1;
}

.filter-pill.active .pill-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Results Info */
.results-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding: 0.25rem 0;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg-secondary);
}

.btn-pagination {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.btn-pagination:disabled {
    display: none;
}

/* Delete Button */
.btn-icon-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-icon-delete:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
    opacity: 1;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background-color: var(--danger);
    color: white;
}

/* Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ===========================
   Quill Editor Dark Mode
   =========================== */
.ql-toolbar.ql-snow {
    border-color: var(--border);
    background: var(--bg-tertiary);
}

.ql-container.ql-snow {
    border-color: var(--border);
}

.ql-toolbar .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-toolbar .ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-toolbar .ql-picker-label {
    color: var(--text-secondary) !important;
}

.ql-toolbar .ql-picker-options {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar .ql-picker-label:hover .ql-stroke {
    stroke: var(--text-primary) !important;
}

.ql-toolbar button:hover .ql-fill,
.ql-toolbar .ql-picker-label:hover .ql-fill {
    fill: var(--text-primary) !important;
}

.ql-toolbar button:hover,
.ql-toolbar .ql-picker-label:hover {
    color: var(--text-primary) !important;
}

.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent-teal) !important;
}

.ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent-teal) !important;
}

.ql-editor {
    color: var(--text-primary);
}

.ql-editor.ql-blank::before {
    color: var(--text-muted);
}

/* Light mode: reset Quill to defaults */
[data-theme="light"] .ql-toolbar.ql-snow {
    border-color: #ccc;
    background: #fff;
}

[data-theme="light"] .ql-container.ql-snow {
    border-color: #ccc;
}

[data-theme="light"] .ql-toolbar .ql-stroke {
    stroke: #444 !important;
}

[data-theme="light"] .ql-toolbar .ql-fill {
    fill: #444 !important;
}

[data-theme="light"] .ql-toolbar .ql-picker-label {
    color: #444 !important;
}

[data-theme="light"] .ql-toolbar button:hover .ql-stroke,
[data-theme="light"] .ql-toolbar .ql-picker-label:hover .ql-stroke {
    stroke: #06c !important;
}

[data-theme="light"] .ql-toolbar button.ql-active .ql-stroke {
    stroke: #06c !important;
}

[data-theme="light"] .ql-editor {
    color: #1d1d1f;
}

/* ===========================
   Light Mode Theme
   =========================== */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8ed;

    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #aeaeb2;

    --primary: #4a8385;
    --primary-hover: #3d6e70;

    --action: #e88a3a;
    --action-hover: #d47a2d;

    --accent-orange: #e88a3a;
    --accent-teal: #4a8385;
    --accent-green: #3a7d2c;

    --success: #3a7d2c;
    --danger: #dc3545;
    --border: #d2d2d7;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Light mode badge adjustments for better contrast */
[data-theme="light"] .badge-new {
    background: rgba(74, 131, 133, 0.12);
    color: #3a6d6f;
}

[data-theme="light"] .badge-intake_sent {
    background: rgba(232, 138, 58, 0.12);
    color: #b06a20;
}

[data-theme="light"] .badge-review {
    background: rgba(58, 125, 44, 0.12);
    color: #2d6322;
}

[data-theme="light"] .badge-closed {
    background: #e8e8ed;
    color: #6e6e73;
}

/* Light mode table hover */
[data-theme="light"] .table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Light mode active nav */
[data-theme="light"] .nav-item.active {
    background-color: rgba(74, 131, 133, 0.08);
}

/* Smooth transitions for theme switching */
body,
.sidebar,
.card,
.main-content,
.form-input,
.form-textarea,
.form-select,
.badge,
.table th,
.table td,
.nav-item,
.btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===========================
   Logout Button
   =========================== */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.logout-btn:hover {
    background-color: rgba(252, 158, 79, 0.08);
    color: var(--accent-orange);
    border-color: rgba(252, 158, 79, 0.2);
}

/* ===========================
   Theme Toggle Button (icon-only: ☀ / 🌙)
   =========================== */
.theme-toggle-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    margin: 0 auto 0.5rem auto;
    /* Center horizontally with bottom margin */
    width: fit-content;
    transition: background-color 0.2s, border-color 0.2s;
}

.theme-toggle-icons:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.theme-toggle-icons .icon-sun,
.theme-toggle-icons .icon-moon {
    width: 18px;
    height: 18px;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.toggle-separator {
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0.4;
    user-select: none;
}

/* Dark mode (default): moon highlighted, sun muted */
.theme-toggle-icons .icon-moon {
    color: var(--accent-teal);
    opacity: 1;
}

.theme-toggle-icons .icon-sun {
    color: var(--text-muted);
    opacity: 0.4;
}

/* Light mode: sun highlighted, moon muted */
[data-theme="light"] .theme-toggle-icons .icon-sun {
    color: var(--accent-orange);
    opacity: 1;
}

[data-theme="light"] .theme-toggle-icons .icon-moon {
    color: var(--text-muted);
    opacity: 0.4;
}

/* Login page mini toggle */
.theme-toggle-mini {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.3s;
    box-shadow: var(--shadow-sm);
}

.theme-toggle-mini:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.lang-selector-mini {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

.btn-lang {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 16px;
    transition: all 0.2s;
}

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

html[lang="nl"] #lang-nl,
html[lang="en"] #lang-en,
html[lang="bs"] #lang-bs {
    background: var(--primary);
    color: white;
}

.theme-toggle-mini .icon-sun {
    display: none;
}

.theme-toggle-mini .icon-moon {
    display: inline-block;
}

[data-theme="light"] .theme-toggle-mini .icon-sun {
    display: inline-block;
}

[data-theme="light"] .theme-toggle-mini .icon-moon {
    display: none;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: absolute;
    right: -12px;
    /* Hang outside the sidebar */
    top: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

/* Ensure padding adjustment for hanging button */
.sidebar {
    overflow: visible;
    /* Allow button to hang out */
}

/* In collapsed mode, maybe center it? */
.sidebar.collapsed .sidebar-toggle-btn {
    margin: 0 auto 1rem auto;
}

/* ===========================
   MOBILE RESPONSIVENESS
   =========================== */

/* Mobile Header (Hamburger Menu) - Hidden on Desktop */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
}

.mobile-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.hamburger-btn:hover {
    color: var(--primary);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Tablet + Mobile Breakpoint */
@media (max-width: 768px) {

    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Sidebar: off-screen by default, slides in when open */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        /* Off-screen */
        bottom: 0;
        width: 260px;
        z-index: 101;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        /* No display:none - just transform off-screen */
    }

    .sidebar.mobile-open {
        left: 0;
        /* Slide in */
    }

    /* Main content: full width, add top padding for fixed mobile header */
    .main-content {
        padding: 5rem 1rem 1rem 1rem;
        /* Top padding for mobile header */
    }

    /* Hide desktop sidebar toggle button on mobile */
    .sidebar-toggle-btn {
        display: none;
    }

    /* Grid-2: single column on tablets */
    .grid-2 {
        grid-template-columns: 1fr;
    }

    /* Dashboard Stats Grid: 2 columns on tablet */
    .grid-2[style*="repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Hide 5th stat card on tablets if it breaks layout */
    .grid-2[style*="repeat(5"] .card:nth-child(5) {
        display: none;
    }

    /* Table: hide less important columns */
    .table th:nth-child(1),
    /* Referentie */
    .table td:nth-child(1),
    .table th:nth-child(5),
    /* Advocaat */
    .table td:nth-child(5) {
        display: none;
    }

    /* Table: reduce padding */
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Search filter bar: stack vertically */
    .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        max-width: 100%;
    }

    /* Filter pills: horizontal scroll */
    .filter-pills-container {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .filter-pill {
        flex-shrink: 0;
    }

    /* Modals: full width with padding */
    #email-modal>div,
    #edit-user-modal>div,
    #fullscreen-editor-modal>div {
        width: 95%;
        max-width: 95%;
        margin: 1rem;
    }

    /* Case detail: stack 2fr 1fr grid */
    .grid-2[style*="2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Buttons: stack in header */
    .flex.justify-between.items-center {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .flex.justify-between.items-center .btn {
        width: 100%;
    }

    /* Settings: all nested grids single column */
    .grid-2[style*="gap: 1rem"] {
        grid-template-columns: 1fr !important;
    }

    /* Help page: full width sections */
    .grid-2[style*="span 2"] {
        grid-column: span 1;
    }
}

/* Small Phone Breakpoint */
@media (max-width: 480px) {

    /* Main content: less padding */
    .main-content {
        padding: 4.5rem 0.75rem 0.75rem 0.75rem;
    }

    /* Typography: smaller headers */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Dashboard: single column stats */
    .grid-2[style*="repeat(5"],
    .grid-2[style*="repeat(2"] {
        grid-template-columns: 1fr !important;
    }

    /* Show all 5 stat cards in single column */
    .grid-2[style*="repeat(5"] .card:nth-child(5) {
        display: block;
    }

    /* Table: even tighter */
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    /* Cards: less padding */
    .card {
        padding: 1rem;
    }

    /* Buttons: full width */
    .btn {
        width: 100%;
    }

    .flex.gap-2,
    .flex.gap-4 {
        flex-direction: column;
        width: 100%;
    }

    .flex.gap-2>.btn,
    .flex.gap-4>.btn {
        width: 100%;
    }

    /* Login page: remove max-width, full width card */
    .auth-container .card {
        max-width: 100% !important;
        padding: 2rem 1.5rem !important;
        margin: 0.5rem;
    }

    /* Search input: smaller */
    .search-input {
        font-size: 0.85rem;
        padding: 0.5rem 2rem 0.5rem 36px;
    }

    /* Intake chat: smaller padding */
    .chat-messages {
        padding: 1rem;
        gap: 1rem;
    }

    .bubble {
        padding: 0.75rem 1rem;
    }

    /* Email modal: adjust quill editor height */
    #editor-container,
    #fullscreen-editor-container {
        height: 150px !important;
    }
}

/* Very Small Phones */
@media (max-width: 375px) {
    .mobile-header {
        padding: 0 0.75rem;
    }

    .mobile-header .logo {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 4rem 0.5rem 0.5rem 0.5rem;
    }

    .card {
        padding: 0.75rem;
    }
}

/* Desktop Breakpoint - Hide Mobile Elements & Fix Layout */
@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }

    .mobile-overlay {
        display: none !important;
    }

    /* Sidebar is fixed, so main content needs left margin to avoid overlap */
    .main-content {
        margin-left: 260px;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 2rem 1rem;
    }

    .sidebar.collapsed~.main-content {
        margin-left: 80px;
    }

    /* Smooth sidebar collapse transition on desktop */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    }
}
/* Case Detail Mobile Layout Ordering */
@media (max-width: 768px) {
    .case-detail-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem;
    }

    /* Remove natural column flow and let flex items stack directly */
    .case-col-left, .case-col-right {
        display: contents; 
    }

    /* Flex ordering for Proposal 1: "Actie & Inzicht" */
    
    /* 1. Client Details & Link */
    .card-client {
        order: 1;
        margin-bottom: 0 !important;
    }
    
    /* 2. Status Timeline */
    .card-timeline {
        order: 2;
        margin-bottom: 0 !important;
    }
    
    /* 3. Case Summary */
    .card-summary {
        order: 3;
        margin-bottom: 0 !important;
    }
    
    /* 4. Uploaded Files */
    .card-files {
        order: 4;
        margin-bottom: 0 !important;
    }

    /* 5. Chat Log */
    .card-log {
        order: 5;
        margin-bottom: 0 !important;
    }
    
    /* 6. Legal Category */
    .card-category {
        order: 6;
        margin-bottom: 0 !important;
    }
    
    /* 7. Status Transaction (can sit near category as metadata) */
    .card-status {
        order: 7;
        margin-bottom: 0 !important;
    }

    /* 8. Delete Button (Always Bottom) */
    .card-delete {
        order: 99; 
        margin-top: 1rem !important;
    }
}
