/* General Body and Container Styles */

:root {
    --bg-body: #e0e0e0;
    --bg-app-shell: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #2c3e50;
    --text-main: #333333;
    --text-header: #2c3e50;
    --text-secondary: #555555;
    --text-muted: #777777;
    --border-color: #c0c0c0;
    --border-light: #e0e0e0;
    --input-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --accent: #007bff;
    --accent-hover: #0062cc;
    --accent-fg: #ffffff;
}

body.dark-mode {
    --bg-body: #121212;
    --bg-app-shell: #1a1a1a;
    --bg-card: #242424;
    --bg-sidebar: #0f172a;
    --text-main: #e0e0e0;
    --text-header: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-muted: #9ca3af;
    --border-color: #404040;
    --border-light: #333333;
    --input-bg: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --accent: #3b9eff;
    --accent-hover: #1a8fff;
    --accent-fg: #ffffff;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    display: block;
    min-height: 100vh;
    background-color: var(--bg-body);
    margin: 0;
    color: var(--text-main);
    line-height: 1.6;
}

/* Main app container (for dashboard) */
#app {
    width: 100%;
}


/* Common form/card container styles */
.form-card {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 12px; /* More rounded corners */
    box-shadow: 0 8px 25px var(--shadow-color); /* Stronger, softer shadow */
    width: 100%;
    max-width: 400px; /* Max width for forms */
    text-align: center;
    margin: 20px; /* Add some margin for spacing */
}

/* Headers */
h1, h2, h3 {
    color: var(--text-header);
    margin-bottom: 20px;
    font-weight: 600;
}
h1 { font-size: 2.2em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.4em; }

/* Form Group Layout */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}
label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95em;
}
input[type="text"],
input[type="password"],
input[type="email"],
select.input { /* Added select.input for consistent styling */
    width: calc(100% - 24px); /* Adjust for padding */
    padding: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
input[type="text"]:focus,
input[type="password"]:focus,
select.input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Messages */
.error-message {
    color: #dc3545;
    margin-top: 15px;
    font-weight: 500;
    font-size: 0.9em;
}
.success-message {
    color: #28a745;
    margin-top: 15px;
    font-weight: 500;
    font-size: 0.9em;
}
.status { /* For upload status */
    margin-top: 15px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Link Text */
.link-text {
    margin-top: 25px;
    font-size: 0.9em;
}
.link-text a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}
.link-text a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    margin-top: 10px; /* Add some spacing above buttons */
}

/* Common styles for pill-shaped buttons */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning {
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
}

.btn-primary {
    background: #0056b3;
}
.btn-success {
    background-color: #28a745;
}
.btn-success:hover {
    background-color: #218838;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.2);
}
.btn-danger {
    background-color: #dc3545;
}
.btn-danger:hover {
    background-color: #c82333;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.2);
}
.btn-secondary {
    background-color: #6c757d;
}
.btn-primary:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}
.btn-secondary:hover {
    background-color: #5a6268;
    box-shadow: 0 4px 10px rgba(108, 117, 125, 0.2);
}

.btn:disabled,
.btn:disabled:hover {
    background-color: #a0aec0; /* A neutral gray */
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.65;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85em;
    width: auto;
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-warning {
    background-color: #ffc107;
    color: #212529;
}
.btn-warning:hover {
    background-color: #e0a800;
}

.btn-sm img.icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
}
/* Invert icon color for primary and danger buttons (white text) */
.btn-primary img.icon, .btn-danger img.icon {
    filter: brightness(0) invert(1);
}
.btn-icon-only {
    padding: 6px;
}
.btn-icon-only img.icon {
    margin-right: 0;
}

/* Register Button Specific Styles */
#btn-register {
    background-color: #0056b3;
}

#btn-register:hover {
    background-color: #0056b3;
}

#btn-register:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

/* =========================== */
/* LOGIN / AUTH PAGE STYLES    */
/* =========================== */

.login-layout {
    display: flex;
    height: 100vh;
    max-height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.hero-section {
    flex: 1;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 18px;
    box-sizing: border-box;
}

.hero-section img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 16px;
    border: 4px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.4);
    box-sizing: border-box;
}

.hero-overlay {
    position: absolute;
    top: calc(18px + 1.5rem);
    left: calc(18px + 1.5rem);
    width: calc(48% - 18px);
    max-width: 440px;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-sizing: border-box;
    text-align: left;
    z-index: 1;
}

.hero-overlay h1 {
    color: white;/* Override generic h2 color */
    margin-bottom: 10px;
}

.hero-overlay h2 {
    color: white;
    margin-bottom: 8px;
    font-size: clamp(1rem, 2vw, 1.5rem);
    line-height: 1.3;
}

.hero-overlay p {
    color: white;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    line-height: 1.4;
    margin: 0;
}

.pn-logo {
    width: 100%;
    max-width: 240px;
    height: auto;
    margin-bottom: 10px;
}

.auth-section {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 500px;
    /* Overlay auth section */
    position: absolute;
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    max-height: 96vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.8);
    z-index: 2;
}

.auth-logo {
    width: 200px;
    height: auto;
    margin-bottom: 20px;
    display: block;
}

.tabs { display: none; margin-bottom: 2rem; border-bottom: 1px solid #ccc; }
.tab { padding: 1rem; cursor: pointer; border: none; background: none; font-size: 1rem; }
.tab.active { border-bottom: 2px solid #007bff; font-weight: bold; color: #007bff; }

.form-container { display: none; }
.form-container.active { display: block; }

.field { margin-bottom: 1rem; }
.field input { width: 100%; padding: 0.8rem; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; }

/* Specific button styling for auth section */
.auth-section .btn {
    width: 100%; padding: 0.8rem; background: #007bff; color: white; border: none; border-radius: 50px; cursor: pointer; font-size: 1rem;
}
.auth-section .btn:hover { background: #0056b3; }

.error { color: red; margin-bottom: 1rem; }
.success { color: green; margin-bottom: 1rem; }


/* Auth / login page: always neutral — never inherits dark-mode */
body.dark-mode #hero-guest-content .auth-section {
    background: rgba(255, 255, 255, 0.95);
}
body.dark-mode #hero-guest-content h1,
body.dark-mode #hero-guest-content h2,
body.dark-mode #hero-guest-content h3 {
    color: #2c3e50;
}
body.dark-mode #hero-guest-content .field input,
body.dark-mode #hero-guest-content input {
    background: #ffffff;
    color: #333333;
    border-color: #c0c0c0;
}
body.dark-mode #hero-guest-content .tab { color: #555555; }
body.dark-mode #hero-guest-content .tab.active { color: #007bff; }
body.dark-mode #hero-guest-content .small-text { color: #777777; }
body.dark-mode #hero-guest-content .link-text,
body.dark-mode #hero-guest-content .link-text a { color: #007bff; }
body.dark-mode #hero-guest-content .instruction-text { color: #555555; }
body.dark-mode #hero-guest-content .error { color: #dc3545; }
body.dark-mode #hero-guest-content .success { color: #16a34a; }

/* =========================== */
/* DASHBOARD LAYOUT & STYLES   */
/* =========================== */

.app-shell {
    display: flex;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-app-shell); /* Light background for the overall shell */
}

/* Sidebar */
.sidebar {
    width: auto;
    flex-shrink: 0;
    background-color: var(--bg-sidebar); /* Darker primary color */
    color: #ecf0f1; /* Light text */
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 0 20px 20px;
    border-bottom: 1px solid #3b5167; /* Divider */
    margin-bottom: 20px;
}
.sidebar-logo {
    width: 260px;
    max-width: 100%;
    height: auto;
    display: flex;
}
.sidebar-logo-collapsed {
    display: none;
    width: 60px;
    height: 60px;
    object-fit: contain;
}
/* Explicitly hide the icon logo when the sidebar is expanded */
.sidebar:not(.collapsed) .sidebar-logo-collapsed {
    display: none;
}

.sidebar-section-label {
    font-size: 0.8em;
    color: #a0a0a0;
    padding: 10px 20px 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-section-label-more {
    margin-top: auto; /* Pushes "MORE" section to the bottom */
    padding-top: 20px;
    border-top: 1px solid #3b5167;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}
.sidebar-nav-bottom {
    margin-bottom: 0;
}
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #ecf0f1;
    background: none;
    border: none;
    text-align: left;
    width: calc(100% - 20px);
    margin: 2px 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 1em;
    border-radius: 8px;
    outline: none;
    white-space: nowrap;
}
.sidebar-item:hover {
    background-color: #3b5167; /* Lighter shade on hover */
    color: white;
}
.sidebar-item-active {
    background-color: #007bff; /* Highlight active item */
    color: white;
    font-weight: bold;
}
.sidebar-item-active:hover {
    background-color: #007bff; /* Keep active color on hover */
}
.sidebar-item-icon {
    margin-right: 10px;
    display: flex; /* To center SVG/Image */
    align-items: center;
    justify-content: center;
}
.sidebar-item-icon img.icon {
    width: 28px;
    height: 28px;
    filter: invert(100%) saturate(0%) brightness(100%); /* Make SVG white */
}
.sidebar-item-danger {
    color: #dc3545; /* Red for danger action like logout */
}
.sidebar-item-danger:hover {
    background-color: #dc3545;
    color: white;
}

/* Nav badge (count bubble on sidebar items) */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1;
}
.nav-badge.hidden { display: none; }


/* Sidebar inline + collapse/expand at large screens */
@media (min-width: 1200px) {
    .sidebar {
        position: relative;
        left: auto;
        width: auto;
        flex-shrink: 0;
        height: auto;
        z-index: auto;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-x: hidden;
        overflow-y: auto;
    }

    /* Collapsed: icon-only 80px strip */
    .sidebar.collapsed {
        width: 80px;
        overflow-x: visible;
        overflow-y: visible;
    }
    .sidebar.collapsed .sidebar-header {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
    .sidebar.collapsed .sidebar-logo { display: none; }
    .sidebar.collapsed .sidebar-logo-collapsed { display: block; }
    .sidebar.collapsed .sidebar-section-label { display: none; }
    .sidebar.collapsed .nav-badge { display: none; }

    .sidebar.collapsed .sidebar-item {
        justify-content: center;
        padding: 15px 0;
        position: relative;
    }
    .sidebar.collapsed .sidebar-item-icon { margin-right: 0; }
    .sidebar.collapsed .sidebar-item span:not(.sidebar-item-icon) { display: none; }

    /* Tooltip on hover */
    .sidebar.collapsed .sidebar-item:hover span:not(.sidebar-item-icon) {
        display: block;
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        background-color: #2c3e50;
        color: #fff;
        padding: 8px 12px;
        border-radius: 4px;
        white-space: nowrap;
        z-index: 1000;
        margin-left: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        font-weight: 500;
    }
    .sidebar.collapsed .sidebar-item:hover span:not(.sidebar-item-icon)::before {
        content: "";
        position: absolute;
        top: 50%;
        right: 100%;
        margin-top: -6px;
        border-width: 6px;
        border-style: solid;
        border-color: transparent #2c3e50 transparent transparent;
    }

    .sidebar.collapsed .sidebar-nav-bottom {
        margin-top: auto;
        border-top: 1px solid #3b5167;
        padding-top: 10px;
    }
}


/* Main Content Area */
.main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-app-shell); /* Light background for content */
}

/* Topbar */
.topbar {
    background-color: var(--bg-card);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow-color);
    border-bottom: 1px solid var(--border-light);
}
.topbar-menu-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    margin-right: 16px;
    flex-shrink: 0;
    transition: background-color 0.15s, border-color 0.15s;
}
.topbar-menu-btn:hover {
    background-color: var(--border-light);
    border-color: #6366f1;
    color: #6366f1;
}
.topbar-spacer {
    flex-grow: 1;
}
.topbar-user {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.topbar-user-avatar {
    background-color: #007bff;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1em;
    font-weight: bold;
    margin-right: 10px;
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    margin-right: 10px;
}
.topbar-user-name {
    font-weight: 600;
    color: var(--text-main);
}
.topbar-user-meta {
    font-size: 0.8em;
    color: #777;
}
.topbar-user-caret {
    color: #777;
}

/* ── Notification Bell ───────────────────────────────────────────────── */
.topbar-notif-wrapper {
    position: relative;
    margin-right: 6px;
}
.topbar-notif-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    position: relative;
    transition: background-color 0.15s, color 0.15s;
}
.topbar-notif-btn:hover {
    background-color: var(--border-light);
    color: #6366f1;
}
.notif-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    background: #e53935;
    color: #fff;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    font-size: 0.65em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
    line-height: 1;
}
.notif-badge.hidden { display: none; }

@keyframes bell-shake {
    0%,100% { transform: rotate(0); }
    10%,50% { transform: rotate(-18deg); }
    20%,40% { transform: rotate(18deg); }
    30%     { transform: rotate(-22deg); }
    60%     { transform: rotate(12deg); }
    70%     { transform: rotate(-8deg); }
    80%     { transform: rotate(5deg); }
    90%     { transform: rotate(-3deg); }
}
.bell-has-notif svg {
    animation: bell-shake 2s ease 0s infinite;
    transform-origin: 50% 2px;
}

/* Dropdown panel */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 28px var(--shadow-color);
    z-index: 1100;
    overflow: hidden;
}
.notif-dropdown.hidden { display: none; }
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-main);
}
.notif-clear-btn {
    font-size: 0.78em;
    color: #6366f1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 5px;
    transition: background 0.15s;
}
.notif-clear-btn:hover { background: var(--border-light); }
.notif-list {
    max-height: 380px;
    overflow-y: auto;
}
.notif-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary);
    font-size: 0.88em;
}
.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--border-light); }
.notif-item.unread { background: rgba(99,102,241,0.06); }
.notif-item-title {
    font-weight: 600;
    font-size: 0.84em;
    color: var(--text-main);
    margin-bottom: 3px;
}
.notif-item-msg {
    font-size: 0.8em;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 5px;
}
.notif-item-time {
    font-size: 0.74em;
    color: #999;
}

/* Dashboard Main Content */
.dashboard-main {
    flex-grow: 1;
    padding: 25px;
    overflow-y: auto; /* Enable scrolling for main content */
}

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(to right, #007bff, #0056b3); /* Blue gradient */
    color: white;
    padding: 25px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}
.welcome-title {
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 5px;
}
.welcome-subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}
.welcome-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.8;
}
.welcome-close:hover {
    opacity: 1;
}

/* Metric Cards */
.cards-row {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: nowrap;
}
.metric-card {
    background-color: var(--bg-card);
    padding: 14px 10px;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.metric-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 4px;
    white-space: nowrap;
}
.metric-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
}
.metric-card-live .metric-value {
    color: #1d4ed8;
}

/* Live Recording Card (in My Cases list) */
.live-stream-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.live-rec-status-badge {
    background: #dc3545 !important;
    color: #fff !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.rec-dot-inline {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    margin-right: 4px;
    animation: rec-pulse 1.2s ease-in-out infinite;
    vertical-align: middle;
}
.live-recording-row {
    background: #fff5f5;
}
/* Compact icon buttons for live recording controls */
.live-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    background: #e9ecef;
    color: #495057;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.live-action-btn:hover {
    background: #dee2e6;
}
.live-action-btn--stop {
    background: #f8d7da;
    color: #dc3545;
}
.live-action-btn--stop:hover {
    background: #dc3545;
    color: #fff;
}
.live-action-btn.btn-warning {
    background: #fff3cd;
    color: #856404;
}
.live-action-btn.btn-warning:hover {
    background: #ffc107;
    color: #212529;
}
.live-action-btn.btn-success {
    background: #d1e7dd;
    color: #0f5132;
}
.live-action-btn.btn-success:hover {
    background: #198754;
    color: #fff;
}
.live-rec-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
/* Stop recording button — red border on hover */
.stop-rec-btn.icon-button:hover {
    border-color: #dc3545;
}
/* Mute button — amber border when audio is muted (btn-warning toggled by JS) */
.mute-rec-btn.icon-button.btn-warning {
    border-color: #d97706;
}
body.dark-mode .stop-rec-btn.icon-button:hover {
    border-color: #dc3545;
}
body.dark-mode .mute-rec-btn.icon-button.btn-warning {
    border-color: #d97706;
}
.live-recording-card .case-actions {
    gap: 4px;
    margin-top: 8px;
}
.live-rec-status-badge.paused-rec {
    background: #d97706 !important;
    animation: none;
}


/* Dashboard Live Cases Section */
.dashboard-live-cases,
.dashboard-scheduled-sessions {
    background-color: var(--bg-card);
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    padding: 20px;
    margin-bottom: 25px;
}

/* Scheduled session tiles */
.sched-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.sched-tile {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-app-shell);
    transition: box-shadow 0.15s;
}
.sched-tile:hover {
    box-shadow: 0 4px 14px var(--shadow-color);
}

.sched-tile-top {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sched-tile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-header);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sched-tile-datetime {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.sched-tile-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sched-meta-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    gap: 8px;
}
.sched-meta-label {
    color: var(--text-muted);
    flex-shrink: 0;
}
.sched-meta-value {
    color: var(--text-main);
    text-align: right;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sched-tile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}
.dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.dashboard-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-header);
}
.live-indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #1d4ed8;
    display: inline-block;
    flex-shrink: 0;
    animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.45; transform: scale(0.8); }
}

/* Panel (Video Cases / My Cases List) */
.panel {
    background-color: var(--bg-card);
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    margin-bottom: 25px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-light);
}
.panel-title {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-header);
}
.panel-body {
    padding: 25px;
}
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.panel-stat {
    text-align: center;
}
.panel-stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #007bff;
}
.panel-stat-label {
    font-size: 0.9em;
    color: var(--text-muted);
}

/* My Cases Specific Styles */
#view-my-cases .mycases-header,
#view-my-summaries .mycases-header,
#view-shared-with-me .mycases-header,
#view-shared-with-others .mycases-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
#view-my-cases .mycases-title,
#view-my-summaries .mycases-title,
#view-shared-with-me .mycases-title,
#view-shared-with-others .mycases-title {
    font-size: 2em;
    font-weight: 600;
    color: var(--text-header);
}
#view-my-cases .mycases-actions,
#view-my-summaries .mycases-actions,
#view-shared-with-me .mycases-actions,
#view-shared-with-others .mycases-actions {
    display: flex;
    gap: 10px;
}

/* ── My Cases action bar ─────────────────────────────────── */
.mycases-actionbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.88rem;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.toolbar-btn:hover {
    background: var(--border-light);
    border-color: #0056b3;
}
.toolbar-btn-primary {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    font-weight: 600;
}
.toolbar-btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: #fff;
}
.toolbar-btn-toggle {
    padding: 5px 8px;
}
.toolbar-btn-toggle.active {
    background: #007bff;
    border-color: #007bff;
}
.toolbar-btn-toggle.active img.icon {
    filter: invert(1);
}
.toolbar-btn .icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    filter: var(--icon-filter, none);
}
.toolbar-sep {
    display: inline-block;
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin: 0 4px;
    flex-shrink: 0;
}
.mycases-actionbar .mycases-search {
    margin-left: auto;
    width: 220px;
}
#btn-live-record .rec-dot {
    color: #e74c3c;
    font-size: 0.75rem;
    animation: none;
}
#btn-live-record.is-live-active .rec-dot {
    animation: rec-pulse 1s ease-in-out infinite;
}
body.dark-mode .toolbar-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
body.dark-mode .toolbar-btn:hover {
    background: var(--bg-hover);
}
@media (max-width: 768px) {
    .mycases-actionbar { gap: 4px; padding: 6px 8px; }
    .mycases-actionbar .mycases-search { margin-left: 0; width: 100%; order: 10; }
    .toolbar-sep { display: none; }
}
#view-dashboard .icon-button,
#view-my-cases .icon-button,
#view-my-summaries .icon-button,
#view-shared-with-me .icon-button,
#view-shared-with-others .icon-button,
#view-annotation-editor .icon-button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
#view-dashboard .icon-button:hover,
#view-my-cases .icon-button:hover,
#view-my-summaries .icon-button:hover,
#view-shared-with-me .icon-button:hover,
#view-shared-with-others .icon-button:hover,
#view-annotation-editor .icon-button:hover {
    background-color: var(--border-light);
    border-color: #0056b3;
}
.icon-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Live record button: no animation when idle, red pulse when recording is active */
#btn-live-record.is-live-active {
    border-color: #dc3545 !important;
    animation: btn-red-pulse 1.2s ease-in-out infinite;
}
@keyframes btn-red-pulse {
    0%, 100% { border-color: #dc3545; box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
    50%       { border-color: #dc3545; box-shadow: 0 0 0 5px rgba(220, 53, 69, 0.3); }
}

body.dark-mode #btn-live-record.is-live-active {
    animation: btn-red-pulse 1.2s ease-in-out infinite;
}

/* Scheduled session "Start Recording" labeled button */
.btn-start-rec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.btn-start-rec:hover:not(:disabled) { background: #15803d; }
.btn-start-rec:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-start-rec .rec-dot-sm {
    background: #fff;
    animation: rec-pulse 1s ease-in-out infinite;
}
#view-my-cases .icon-button img.icon,
#view-shared-with-me .icon-button img.icon,
#view-shared-with-others .icon-button img.icon,
#view-annotation-editor .icon-button img.icon {
    width: 20px;
    height: 20px;
    vertical-align: middle; /* Align icons nicely */
    filter: var(--icon-filter, none);
}
body.dark-mode .icon-button img.icon {
    filter: invert(1);
}
/* Toolbar icon buttons: white background in dark mode */
body.dark-mode #view-my-cases .icon-button,
body.dark-mode #view-my-summaries .icon-button,
body.dark-mode #view-shared-with-me .icon-button,
body.dark-mode #view-shared-with-others .icon-button {
    background: rgba(255, 255, 255, 0.9);
    border-color: #c0c0c0;
    color: #333333;
}
body.dark-mode #view-my-cases .icon-button:hover,
body.dark-mode #view-my-summaries .icon-button:hover,
body.dark-mode #view-shared-with-me .icon-button:hover,
body.dark-mode #view-shared-with-others .icon-button:hover {
    background: #ffffff;
    border-color: #0056b3;
}
/* Annotation editor header buttons (back ← and rename ✎) adapt to the dark
   theme instead of inheriting the white-circle treatment used by toolbar buttons. */
body.dark-mode #view-annotation-editor .icon-button {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
body.dark-mode #view-annotation-editor .icon-button:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: #0056b3;
    color: var(--text-header);
}
/* Fix missing icon filter for my-summaries (was getting invert(1) in dark mode) */
body.dark-mode #view-my-summaries .icon-button img.icon {
    filter: none;
}

.mycases-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background-color: var(--bg-card);
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    margin-bottom: 25px;
}
.mycases-filter-selects {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}
.mycases-search {
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 0.95em;
}
.mycases-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mycases-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}
.mycases-select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--text-main);
}
.filter-select {
    font-size: 0.85rem;
    padding: 6px 10px;
    max-width: 160px;
}

.mycases-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Responsive grid */
    gap: 20px;
}

/* List view — table layout */
.mycases-list.list-view {
    display: block;
    overflow-x: auto;
    min-width: 0;
}

.cases-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px var(--shadow-color);
}
.cases-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}
.cases-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}
.cases-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-main);
    font-size: 0.9em;
}
.cases-table tbody tr:last-child td {
    border-bottom: none;
}
.cases-table tbody tr:hover td {
    background: var(--bg-hover, rgba(99, 102, 241, 0.04));
}
.cases-table .table-name {
    font-weight: 600;
    color: var(--text-header);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cases-table .table-muted {
    color: var(--text-muted);
}
.cases-table .table-group-header {
    padding: 8px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
}
.table-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}
.cases-table .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
}
.cases-table .action-btn:hover {
    background: var(--bg-hover, rgba(99, 102, 241, 0.1));
    border-color: #0056b3;
}
.cases-table .action-btn.btn-delete:hover {
    border-color: #dc3545;
}
.cases-table .action-btn .icon {
    width: 15px;
    height: 15px;
}
/* Dark mode: invert list-view table action-button icons (black SVGs → white) */
body.dark-mode .cases-table .action-btn .icon {
    filter: invert(1);
}

/* Table name cell with thumbnail */
.table-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}
.table-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 38px;
    border-radius: 5px;
    overflow: hidden;
    background: #1a1a2e;
}
.table-thumb-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: opacity 0.18s;
}
.table-thumb-video:hover {
    opacity: 0.75;
}
.table-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: var(--bg-main);
}

/* Summary status badges */
.summary-status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.summary-status-badge.status-done {
    background: #d1fae5;
    color: #065f46;
}
.summary-status-badge.status-processing {
    background: #fef3c7;
    color: #92400e;
}
.summary-status-badge.status-error {
    background: #fee2e2;
    color: #991b1b;
}
.summary-status-badge.status-pending {
    background: #e5e7eb;
    color: #6b7280;
}
.summary-status-badge.status-ready {
    background: #d1fae5;
    color: #065f46;
}

.case-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-color);
    padding: 0; /* Remove padding so thumbnail fits edge-to-edge */
    display: flex;
    flex-direction: column;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden; /* Ensure thumbnail respects border radius */
}
.case-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background-color: #000;
    position: relative;
    cursor: pointer;
}
/* Hover overlay — subtle darkening hints the thumbnail is clickable.
   pointer-events: none keeps child elements (status badge) fully interactive. */
.case-thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background 0.18s;
    pointer-events: none;
    z-index: 2;
}
.case-thumbnail:hover::after {
    background: rgba(0, 0, 0, 0.18);
}

.case-status-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: #22c55e;
  color: white;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
}

#mycases-list .case-status-badge {
  cursor: pointer;
}

/* Review status badges for shared-with-me cases */
.review-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  user-select: none;
}
.review-status-badge.status-pending {
  background: #e5e7eb;
  color: #6b7280;
}
.review-status-badge.status-in_review {
  background: #dbeafe;
  color: #1d4ed8;
}
.review-status-badge.status-reviewed {
  background: #d1fae5;
  color: #065f46;
}

/* ── Shared-with recipients row on cards ── */
.shared-recipients-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0 2px;
  flex-wrap: wrap;
}
.shared-recipients-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 3px;
}
.shared-recipients-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.shared-recipient-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  white-space: nowrap;
}
body.dark-mode .shared-recipient-badge {
  background: #1e3a5f;
  color: #93c5fd;
}
.shared-owner-badge {
  background: #d1fae5;
  color: #065f46;
}
body.dark-mode .shared-owner-badge {
  background: #064e3b;
  color: #6ee7b7;
}

/* ── Video type badges (Upload / Live Stream / Summary) ── */
.video-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.type-upload  { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.type-live    { background: rgba(34, 197, 94,  0.15); color: #16a34a; }
.type-summary { background: rgba(139, 92, 246, 0.15); color: #7c3aed; }
body.dark-mode .type-upload  { background: rgba(59, 130, 246, 0.25); color: #93c5fd; }
body.dark-mode .type-live    { background: rgba(34, 197, 94,  0.25); color: #86efac; }
body.dark-mode .type-summary { background: rgba(139, 92, 246, 0.25); color: #c4b5fd; }

/* ── Type filter pills ── */
.type-filter-pills {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.type-pill {
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.type-pill:hover {
  background: var(--bg-card);
  color: var(--text-main);
}
.type-pill.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

/* ── Inline video preview play overlay ── */
.thumbnail-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  z-index: 4;
}
.case-thumbnail:hover .thumbnail-play-overlay {
  opacity: 1;
  pointer-events: auto;
}
.thumbnail-play-overlay svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  transition: transform 0.15s;
}
.thumbnail-play-overlay:hover svg {
  transform: scale(1.12);
}
/* Hide play overlay while video is playing */
.case-thumbnail.is-playing .thumbnail-play-overlay {
  opacity: 0 !important;
  pointer-events: none !important;
}
/* Expand thumbnail height while video plays for a better viewing area */
.case-thumbnail.is-playing {
  height: 220px;
}

.case-duration-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: #ffffffe8; /* Contrasting Amber/Yellow */
  color: #000; /* Black text */
  font-size: 12px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.case-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.case-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}
/* Don't lift the card while a video is actively playing */
.case-item:has(.case-thumbnail.is-playing):hover {
    transform: none;
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.case-header .case-title {
    font-weight: 600;
    font-size: 1.1em;
    color: var(--text-header);
    margin-right: 10px;
    flex-grow: 1;
    word-break: break-word;
}
.edit-name-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    color: #999;
    padding: 0;
    line-height: 1;
}
.edit-name-btn:hover {
    color: #007bff;
}
.case-item .case-meta {
    font-size: 0.85em;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.case-item .case-meta a {
    color: #007bff;
    text-decoration: none;
}
.case-item .case-meta a:hover {
    text-decoration: underline;
}

.case-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.meta-date {
    display: flex;
    align-items: center;
    gap: 6px;
}
.meta-date .icon {
    width: 16px;
    height: 16px;
}

.edit-name-input {
    width: 100%;
    padding: 5px;
    font-size: 1.1em;
    font-weight: 600;
    border: 1px solid #007bff;
    border-radius: 4px;
    font-family: inherit;
}

/* Action Buttons (View / Delete) */
.case-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.case-item .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: solid 1px var(--border-color);
    background-color: #ffffffe8; 
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    font-size: 0.9em;
    overflow: hidden;
    white-space: nowrap;
}
/* Action button hover: blue outline by default, red for delete */
.action-btn:hover { border-color: #0056b3; }
.btn-delete:hover,
.cases-table .action-btn.btn-delete:hover { border-color: #dc3545 !important; }

/* Edit Case button (card header) — no box at rest, blue highlight on hover */
.edit-case-btn {
    border: none;
    background: transparent;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}
.edit-case-btn:hover {
    background-color: rgba(0, 86, 179, 0.12);
}
.edit-case-btn:hover .icon {
    filter: invert(24%) sepia(97%) saturate(600%) hue-rotate(200deg) brightness(90%);
}
/* Dark mode: invert the edit icon at rest so it shows white on dark card backgrounds.
   The :hover rule below has higher specificity so it still overrides on hover. */
body.dark-mode .edit-case-btn .icon {
    filter: invert(1);
}
body.dark-mode .edit-case-btn:hover .icon {
    filter: invert(60%) sepia(80%) saturate(400%) hue-rotate(190deg) brightness(110%);
}

/* Dark mode: card/grid action buttons — replace jarring white circles with
   a subtle translucent surface and invert the icons to white */
body.dark-mode .case-item .action-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color);
}
body.dark-mode .case-item .action-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}
body.dark-mode .case-item .action-btn .icon {
    filter: invert(1);
}

/* Modal Action Buttons */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.mycases-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding: 15px 0;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.9em;
}
.mycases-paging {
    display: flex;
}
.mycases-paging .icon-button {
    margin: 0 5px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Override default padding to ensure circular shape */
    font-size: 1.5em;
}
body.dark-mode .mycases-paging .icon-button {
    color: #333333;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 20px 0;
    z-index: 1000;
}
.modal {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-color);
    width: 90%;
    max-width: 600px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    margin: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}
.modal-title {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-header);
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-close:hover {
    color: var(--text-main);
}
.modal-body {
    flex-grow: 1;
    overflow-y: auto; /* Allow scrolling for modal content if tall */
}
.modal-body .field {
    margin-bottom: 15px;
}
.modal-body .input {
    width: calc(100% - 24px); /* Full width for inputs */
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 1em; /* Ensure consistent font size for all modal inputs */
}
.modal-body .btn-primary {
    width: auto; /* Adjust button width in modal */
    padding: 10px 20px;
}
.modal-body .btn {
    width: auto;
    margin-top: 0;
}

/* Utility Class */
.hidden {
    display: none !important;
}

/* Sidebar backdrop (mobile only) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
}
.sidebar-backdrop.visible {
    display: block;
}

/* Responsive Adjustments */
@media (max-width: 1199px) {
    .app-shell {
        flex-direction: row;
    }

    /* Sidebar is a fixed overlay drawer — hidden until hamburger opens it */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 300px;
        height: 100%;
        z-index: 200;
        transition: left 0.25s ease;
        flex-direction: column;
        flex-wrap: nowrap;
        justify-content: flex-start;
        border-bottom: none;
        padding: 20px 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar-header {
        width: auto;
        border-bottom: 1px solid #3b5167;
        margin-bottom: 20px;
        padding-bottom: 20px;
    }
    .sidebar-section-label {
        display: block;
    }
    .sidebar-nav {
        flex-direction: column;
        flex-wrap: nowrap;
        margin-bottom: 0;
        width: 100%;
        justify-content: flex-start;
    }
    .sidebar-nav-bottom {
        margin-top: auto;
        border-top: 1px solid #3b5167;
    }
    .sidebar-item {
        padding: 12px 20px;
        font-size: 0.95em;
        width: 100%;
        justify-content: flex-start;
    }
    .topbar {
        padding: 10px 15px;
    }
    .welcome-banner {
        flex-direction: column;
        text-align: center;
    }
    .welcome-close {
        margin-top: 15px;
    }
    .cards-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .metric-card {
        flex: 1 1 calc(33% - 8px);
        min-width: 0;
    }
    .mycases-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    .mycases-list {
        grid-template-columns: 1fr; /* Single column on small screens */
    }
    .form-card, .hero-section {
        margin: 10px;
        padding: 20px;
    }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1.2rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px;
    background-color: var(--bg-card);
    border-radius: 10px 10px 0 0;
    padding: 0 20px;
}

.settings-tab {
    padding: 15px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.settings-tab:hover {
    color: #007bff;
}

.settings-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.settings-content {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Generic section used within settings tabs */
.settings-section {
    border: 1px solid var(--border-light);
    padding: 20px;
    border-radius: 10px;
}

.settings-section h3, .settings-section h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.settings-section p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0;
    margin-bottom: 16px;
}

/* Notification preference rows */
.notif-pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}
.notif-pref-row:last-of-type { border-bottom: none; }
.notif-pref-label { font-weight: 500; color: var(--text-main); margin-bottom: 2px; }
.notif-pref-desc  { font-size: 0.85rem; color: var(--text-muted); }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border-color);
    border-radius: 24px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff;
    border-radius: 50%; transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #0056b3; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Theme Picker (Appearance tab) */
.theme-options {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.theme-option input[type="radio"] { display: none; }
.theme-preview {
    width: 80px;
    height: 56px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
}
.theme-option input:checked + .theme-preview { border-color: #0056b3; }
.theme-preview-bar  { height: 14px; }
.theme-preview-body { flex: 1; }
.theme-preview-light .theme-preview-bar  { background: #2c3e50; }
.theme-preview-light .theme-preview-body { background: #f8f9fa; }
.theme-preview-dark .theme-preview-bar   { background: #0f172a; }
.theme-preview-dark .theme-preview-body  { background: #1a1a1a; }
.theme-preview-system .theme-preview-bar  { background: linear-gradient(to right, #2c3e50 50%, #0f172a 50%); }
.theme-preview-system .theme-preview-body { background: linear-gradient(to right, #f8f9fa 50%, #1a1a1a 50%); }
.theme-option span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Annotation Editor Styles */
#view-annotation-editor #editor-back-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.2em;
    color: var(--text-main);
}

#view-annotation-editor .mycases-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.editor-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    height: calc(100vh - 150px); /* Fit screen height roughly */
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: var(--bg-app-shell);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--text-main);
    transition: all 0.2s;
}

.tool-btn:hover {
    background-color: var(--border-light);
}

.tool-btn .icon {
    width: 20px;
    height: 20px;
}

#editor-clear-btn .icon {
    width: 28px;
    height: 28px;
}

.tool-btn.active {
    background-color: #0056b3;
    color: white;
    border-color: #0056b3;
}

.tool-btn.is-recording {
    background-color: #dc3545;
    color: white;
    border-color: #c82333;
    animation: pulse 1.5s infinite;
}

/* Dark mode: invert tool-btn SVG icons so they are visible on dark backgrounds */
body.dark-mode .tool-btn img.icon {
    filter: invert(1);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.editor-main-area {
    display: flex;
    flex: 1;
    gap: 15px;
    overflow: hidden; /* Contain scroll within children */
    min-height: 0; /* Required for nested flex scrolling */
}

.resize-handle {
    width: 12px;
    cursor: col-resize;
    background-color: var(--bg-app-shell);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
    position: relative; /* For absolute positioning of toggle button */
}

.resize-handle:hover, .resize-handle.active {
    background-color: var(--border-light);
}

.resize-handle::after {
    content: "";
    width: 4px;
    height: 20px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.sidebar-toggle-btn {
    position: absolute;
    width: 20px;
    height: 40px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: var(--text-secondary);
    z-index: 10;
    padding: 0;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-toggle-btn:hover {
    background-color: var(--border-light);
    color: var(--text-main);
}

.video-wrapper {
    position: relative;
    flex: 1;
    background: black;
    border-radius: 8px;
    width: auto; /* Let flex handle width */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.media-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-wrapper:hover .media-controls {
    opacity: 1;
}

.seek-bar-wrapper {
    display: flex;
    width: 95%;
    align-items: center;
    gap: 15px;
}

.media-time {
    color: white;
    font-size: 0.9em;
    min-width: 45px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.seek-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: height 0.2s ease;
}

.seek-bar:hover {
    height: 8px;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

.seek-bar::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.media-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.media-btn.active {
    background-color: #0056b3;
}

.media-buttons-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.media-btn img.icon {
    width: 24px;
    height: 24px;
    filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(93deg) brightness(103%) contrast(103%); /* Make icons white */
}

.annotations-sidebar {
    width: 350px;
    background-color: var(--bg-app-shell);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, padding 0.3s ease;
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    transition: flex 0.3s ease;
}

.sidebar-panel.collapsed {
    flex: 0 0 auto;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
}

.sidebar-panel.collapsed .panel-content {
    display: none;
}

.sidebar-separator {
    height: 1px;
    background-color: var(--border-color);
    flex-shrink: 0;
    margin: 10px 0;
}

.annotations-sidebar.collapsed {
    width: 0 !important;
    padding: 0;
    border: none;
    overflow: hidden;
}

.annotations-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding: 10px 15px;
    background-color: var(--bg-app-shell);
    flex-shrink: 0;
}

.panel-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em;
    padding: 4px;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-panel.collapsed .panel-toggle-btn {
    transform: rotate(-90deg);
}

.annotations-sidebar-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.annotations-sidebar-header .button-group {
    display: flex;
    gap: 8px;
}

.annotation-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.annotation-item:hover:not(.is-editing) {
    border-color: #007bff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.annotation-item.is-editing {
    border-color: #007bff;
    background-color: #e7f1ff;
}

.annotation-item.is-summary-selected {
    background-color: #d4edda; /* Light green for summary selection */
    border-color: #28a745;
}

body.dark-mode .annotation-item.is-summary-selected {
    background-color: #1c3b23;
    border-color: #28a745;
}

/* Dark mode: annotation sidebar icons & text */
body.dark-mode .annotation-meta {
    color: var(--text-muted);
}
body.dark-mode .annotation-author {
    background: var(--bg-card);
    color: var(--text-secondary);
}
body.dark-mode .delete-annotation-btn img {
    filter: invert(1);
}
body.dark-mode .annotation-title img {
    filter: invert(1);
}
.annotation-timestamp {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-left: auto; /* Pushes timestamp to the right */
    padding-left: 10px;
}

.annotation-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.annotation-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
}
.annotation-icon svg {
    vertical-align: middle;
}

.annotation-author {
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-secondary, #f3f4f6);
    padding: 2px 6px;
    border-radius: 999px;
    white-space: nowrap;
    margin-left: auto;
}

.annotation-title {
    font-weight: 500;
    font-size: 0.95em;
    flex-grow: 1;
}

.annotation-details {
    display: none;
    padding-left: 20px; /* Indent details */
    margin-top: 8px;
}

.annotation-item.is-editing .annotation-details {
    display: block;
}

.annotation-audio {
    width: 100%;
    margin-top: 8px;
}

.annotation-comment {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 6px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
    min-height: 40px;
    background-color: var(--input-bg);
    color: var(--text-main);
}

.annotation-comment:focus {
    border-color: #007bff;
    outline: none;
}

.annotation-timing {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85em;
    align-items: center;
}

.annotation-timing input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 4px;
}

.annotation-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.delete-annotation-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    padding: 2px;
}
.delete-annotation-btn:hover {
    color: #dc3545;
}

/* Custom Voice Player */
.voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-app-shell);
    border-radius: 6px;
}
.voice-player .icon {
    width: 16px;
    height: 16px;
    filter: var(--icon-filter, none);
}
body.dark-mode .voice-player .icon {
    filter: invert(1);
}
.voice-play-btn, .voice-rerecord-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.voice-play-btn:hover, .voice-rerecord-btn:hover {
    background-color: var(--border-light);
}
.voice-time-display {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.voice-volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

/* Settings Page Styles */

/* Lookup Lists (Case Settings) */
.searchable-lookup-container {
    position: relative;
}

.lookup-field-row {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
}

.lookup-input {
    flex-grow: 1;
    padding: 10px;
}

.lookup-list-dropdown {
    display: none;
    position: absolute;
    z-index: 10;
    width: 100%;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 4px;
    background: var(--bg-app-shell);
}

.lookup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
}

.lookup-item-name {
    font-size: 1.1em;
}

.lookup-item-default {
    color: #888;
    font-size: 0.85em;
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
}

.lookup-item-delete {
    color: #dc3545;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.2em;
    padding: 0;
}

/* User Management */
.user-management-invite-row {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.user-management-label {
    font-size: 0.85em;
    display: block;
    margin-bottom: 5px;
}

.user-management-input {
    padding: 10px;
    width: 100%;
}

.user-management-btn {
    width: auto;
    margin-bottom: 2px;
}

.user-table-container {
    overflow-x: auto;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.user-table-header {
    background: var(--bg-app-shell);
    text-align: left;
}

.user-table-th {
    padding: 10px;
    border-bottom: 2px solid var(--border-color);
}

.user-table-row {
    border-bottom: 1px solid var(--border-light);
}

.user-table-td {
    padding: 10px;
}

.user-role-badge {
    background: var(--bg-app-shell);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.user-actions-cell {
    display: flex;
    gap: 5px;
}

.settings-2col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    align-items: start;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #007bff;
}
input:checked + .slider:before {
  transform: translateX(26px);
}

.annotation-audio {
    width: 100%;
    height: 40px;
    margin-top: 8px;
}

.annotation-meta {
    font-size: 0.85em;
    color: var(--text-muted, #666);
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

#editor-video {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

#editor-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
    pointer-events: auto; /* Ensure canvas captures mouse events */
}

.annotation-comment {
    width: 100%;
    margin-top: 8px;
    font-size: 0.9em;
    border: 1px solid #e0e0e0;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 6px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
    min-height: 40px;
    background-color: var(--input-bg);
    color: var(--text-main);
}

.annotation-comment:focus {
    border-color: #007bff;
    outline: none;
}

.annotation-timing {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85em;
    align-items: center;
}

.annotation-timing input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #c0c0c0;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 4px;
}

.annotation-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.delete-annotation-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    padding: 2px;
}
.delete-annotation-btn:hover {
    color: #dc3545;
}

/* Custom Voice Player */
.voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-app-shell);
    border-radius: 6px;
}
.voice-player .icon {
    width: 16px;
    height: 16px;
    filter: var(--icon-filter, none);
}
body.dark-mode .voice-player .icon {
    filter: invert(1);
}
.voice-play-btn, .voice-rerecord-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.voice-play-btn:hover, .voice-rerecord-btn:hover {
    background-color: var(--border-light);
}
.voice-time-display {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.voice-volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

/* Settings Page Styles */

/* Lookup Lists (Case Settings) */
.searchable-lookup-container {
    position: relative;
}

.lookup-field-row {
    display: flex;
    margin-bottom: 5px;
}

.lookup-input {
    flex-grow: 1;
    padding: 10px;
}

.lookup-add-btn {
    width: auto;
    margin-left: 10px;
    padding: 0 20px;
}

.lookup-list-dropdown {
    display: none;
    position: absolute;
    z-index: 10;
    width: 100%;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 4px;
    background: #f9f9f9;
    background: var(--bg-app-shell);
}

.lookup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    background: white;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
}

.lookup-item-name {
    font-size: 1.1em;
}

.lookup-item-default {
    color: #888;
    font-size: 0.85em;
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
}

.lookup-item-delete {
    color: #dc3545;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.2em;
    padding: 0;
}

/* User Management */
.user-management-invite-row {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.user-management-label {
    font-size: 0.85em;
    display: block;
    margin-bottom: 5px;
}

.user-management-input {
    padding: 10px;
    width: 100%;
}

.user-management-btn {
    width: auto;
    margin-bottom: 2px;
}

.user-table-container {
    overflow-x: auto;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.user-table-header {
    background: #f8f9fa;
    background: var(--bg-app-shell);
    text-align: left;
}

.user-table-th {
    padding: 10px;
    border-bottom: 2px solid #dee2e6;
    border-bottom: 2px solid var(--border-color);
}

.user-table-row {
    border-bottom: 1px solid #eee;
    border-bottom: 1px solid var(--border-light);
}

.user-table-td {
    padding: 10px;
}

.user-role-badge {
    background: #e9ecef;
    background: var(--bg-app-shell);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.user-actions-cell {
    display: flex;
    gap: 5px;
}

/* Inline edit row inputs */
.edit-input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-main);
    font-size: 0.875em;
    min-width: 0;
}
.edit-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.25);
    outline: none;
}
.edit-name-wrap {
    display: flex;
    gap: 6px;
}
.edit-name-wrap .edit-input {
    flex: 1;
    min-width: 0;
}
.user-edit-actions {
    white-space: nowrap;
    vertical-align: middle;
}
.user-edit-actions .btn {
    width: auto;
    margin-right: 4px;
}
.edit-user-status {
    font-size: 0.82em;
    vertical-align: middle;
}
.edit-user-status.error-message { color: #dc3545; }

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #007bff;
}
input:checked + .slider:before {
  transform: translateX(26px);
}

/* ================================= */
/* DASHBOARD.JS COMPONENT STYLES     */
/* ================================= */

/* Settings View */
.settings-panel-body {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 30px;
}

.settings-profile-layout {
    display: flex;
    gap: 40px;
}

.settings-profile-col {
    flex: 1;
}

.instruction-text {
    font-size: 0.8em;
    margin-top: 5px;
    color: #6c757d;
    display: block;
}

.btn-auto-width {
    width: auto;
}

/* Annotation Editor */
#view-annotation-editor .mycases-header > div {
    display: flex;
    align-items: center;
    gap: 15px;
}

#editor-title {
    margin-bottom: 4px;
    font-size: 1.5em;
    line-height: 1.1;
}

#editor-summary {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: var(--text-secondary);
    align-items: center;
}

.editor-toolbar .toolbar-main-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-icon-sm {
    width: 16px;
    height: 16px;
}

.toolbar-color-input {
    height: 30px;
    width: 40px;
    padding: 0;
    border: none;
    background: transparent;
}

#editor-text-tools,
#editor-shape-tools {
    display: none;
    border-left: 1px solid var(--border-light);
    padding-left: 10px;
}

.toolbar-opacity-slider {
    width: 40px;
}

/* Modals */
/* ── Share modal ── */
.modal-share {
    max-width: 480px;
}
.share-video-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}
.share-video-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-header);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-input-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.share-input-row .input {
    flex: 1;
    width: auto;
}
.share-add-btn {
    width: 38px !important;
    padding: 0 !important;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.share-divider {
    border: 0;
    border-top: 1px solid var(--border-light);
    margin: 16px 0 10px;
}
.share-list-heading {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.share-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}
.share-list-empty {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 8px 0;
}
.share-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-app-shell);
    border-radius: 6px;
}
.share-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.share-list-item-info {
    flex: 1;
    min-width: 0;
}
.share-list-item-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-list-item-email {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-revoke-btn {
    font-size: 0.78rem;
    padding: 3px 10px !important;
    color: var(--color-danger, #dc3545) !important;
    border: 1px solid var(--color-danger, #dc3545) !important;
    background: transparent !important;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.share-revoke-btn:hover {
    background: rgba(220,53,69,0.08) !important;
}
.share-note {
    margin-top: 14px;
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #7a5c00;
    line-height: 1.5;
}
.dark-mode .share-note {
    background: rgba(245,158,11,0.12);
    border-color: rgba(245,158,11,0.3);
    color: #fcd34d;
}

/* Share modal autocomplete dropdown */
.share-autocomplete {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 2000;
    max-height: 240px;
    overflow-y: auto;
}
.share-ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}
.share-ac-item:hover,
.share-ac-item.share-ac-active {
    background: var(--bg-app-shell);
}
.share-ac-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary, #007bff);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.share-ac-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.share-ac-name {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-ac-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Multi-file upload modal ── */
.modal-upload {
    max-width: 720px;
}

.upload-defaults-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.upload-defaults-row .field { margin-bottom: 0; }
.upload-defaults-row .input { width: 100%; box-sizing: border-box; }

.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-main);
}
.upload-browse-link {
    color: #6366f1;
    cursor: pointer;
    text-decoration: underline;
}

/* Queue */
.upload-queue {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 14px;
}
.upload-queue-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.15s;
}
.upload-queue-item.queue-item-done  { border-color: #22c55e; }
.upload-queue-item.queue-item-error { border-color: #ef4444; }

.queue-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.queue-file-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.queue-file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.queue-remove-btn {
    font-size: 0.8rem;
    padding: 2px 6px;
    color: var(--text-muted);
}
.queue-remove-btn:hover { color: #ef4444; }

.queue-item-meta {
    display: flex;
    gap: 8px;
}
.queue-item-meta .input {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.82rem;
    width: auto;
    box-sizing: border-box;
}

.queue-item-progress {
    margin-top: 8px;
}
.queue-status-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}
.queue-progress-bar {
    background: #6366f1;
    height: 4px;
    border-radius: 4px;
    width: 0%;
    transition: width 0.2s ease;
}
.queue-item-done  .queue-progress-bar { background: #22c55e; }
.queue-item-error .queue-progress-bar { background: #ef4444; }

/* Overall progress */
#upload-progress-container {
    margin-top: 12px;
}
.upload-overall-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.upload-progress-bg {
    background: #e5e7eb;
    border-radius: 4px;
    height: 8px;
    width: 100%;
}

#upload-progress-bar {
    background: #6366f1;
    height: 8px;
    border-radius: 4px;
    width: 0%;
    transition: width 0.2s ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
}

#share-modal-description,
#delete-modal-text,
#confirmation-modal-text {
    margin-bottom: 20px;
}

#video-viewer-player {
    width: 100%;
    max-height: 60vh;
}

/* ── Live Recording Modal ───────────────────────────────────── */
.live-record-modal {
    max-width: 560px;
    width: 100%;
    padding: 0;
}
.live-record-modal .modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light, #e0e0e0);
    display: flex;
    align-items: center;
}
.live-preview-wrap {
    position: relative;
    background: #000;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.live-preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.rec-indicator {
    position: absolute;
    top: 10px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 999px;
}
.rec-indicator.hidden { display: none; }
.rec-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #dc3545;
    display: inline-block;
    animation: rec-pulse 1s ease-in-out infinite;
}
.rec-dot-sm {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}
@keyframes rec-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}
.live-record-modal .modal-body {
    padding: 16px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.live-form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.live-form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #555);
}
.live-form-row .form-control {
    padding: 7px 10px;
    border: 1px solid var(--border-color, #c0c0c0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--input-bg, #fff);
    color: var(--text-main, #333);
    width: 100%;
}
.live-form-row .form-control:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0,86,179,0.15);
}
.live-record-status {
    font-size: 0.82rem;
    min-height: 18px;
    color: var(--text-muted);
}
.live-record-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border-light, #e0e0e0);
}

/* ── Tag pills ──────────────────────────────────────────────── */
.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #e0e7ff;
    color: #4338ca;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}
.tag-pill .remove-tag {
    background: none;
    border: none;
    cursor: pointer;
    color: #6366f1;
    font-size: 0.65rem;
    padding: 0;
    line-height: 1;
}
.tag-pill .remove-tag:hover { color: #3730a3; }
.table-tags { display: flex; flex-wrap: wrap; gap: 3px; }

/* ── Tag modal ──────────────────────────────────────────────── */
.tag-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.tag-input-row .tag-text-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border-color, #c0c0c0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--input-bg, #fff);
    color: var(--text-main, #333);
}
.tag-modal-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 36px;
    padding: 6px;
    border: 1px solid var(--border-light, #e0e0e0);
    border-radius: 6px;
    margin-bottom: 16px;
    background: var(--bg-app-shell, #f8f9fa);
}
/* ── Topbar Mic Button (Voice Commands) ─────────────────────── */
.topbar-mic-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 10px;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.topbar-mic-btn:hover:not(:disabled) {
    background-color: var(--border-light);
    border-color: #0056b3;
}
.topbar-mic-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.topbar-mic-btn img.icon {
    filter: var(--icon-filter, none);
}
/* Active: mic on, waiting for speech */
.topbar-mic-btn.mic-active {
    border-color: #0056b3;
    background-color: rgba(0, 86, 179, 0.1);
}
.topbar-mic-btn.mic-active img.icon {
    filter: invert(27%) sepia(90%) saturate(1200%) hue-rotate(200deg) brightness(90%);
}
/* Listening: speech is being detected */
.topbar-mic-btn.mic-active.mic-listening {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
    animation: mic-ring 1.4s ease-in-out infinite;
}
.topbar-mic-btn.mic-active.mic-listening img.icon {
    filter: invert(20%) sepia(85%) saturate(3000%) hue-rotate(340deg) brightness(80%);
}
/* Denied: microphone permission refused */
.topbar-mic-btn.mic-denied {
    border-color: #ffc107;
}
.topbar-mic-btn.mic-unsupported {
    opacity: 0.3;
    cursor: not-allowed;
}
@keyframes mic-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
}
body.dark-mode .topbar-mic-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: #c0c0c0;
}
body.dark-mode .topbar-mic-btn:hover:not(:disabled) {
    background: #ffffff;
    border-color: #0056b3;
}

/* ── Topbar theme toggle button ── */
.topbar-theme-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 10px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.topbar-theme-btn:hover {
    background-color: var(--border-light);
    border-color: #6366f1;
    color: #6366f1;
}
body.dark-mode .topbar-theme-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: #c0c0c0;
    color: #333;
}
body.dark-mode .topbar-theme-btn:hover {
    background: #ffffff;
    border-color: #6366f1;
    color: #6366f1;
}

/* ── Toast Notifications ────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 320px;
}
.toast {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    font-size: 0.875rem;
    line-height: 1.4;
    border-left: 4px solid #6c757d;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: auto;
}
.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}
.toast.toast-exit {
    opacity: 0;
    transform: translateX(20px);
}
.toast.toast-success { border-left-color: #28a745; }
.toast.toast-error   { border-left-color: #dc3545; }
.toast.toast-warning { border-left-color: #ffc107; }
.toast.toast-info    { border-left-color: #007bff; }
body.dark-mode .toast {
    box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

/* ── Help & Support ─────────────────────────────────────────── */
.help-content { max-width: 860px; }
.help-section { line-height: 1.7; color: var(--text-main); }
.help-section h4 { margin: 18px 0 6px; font-size: 0.95rem; font-weight: 600; color: var(--text-header); }
.help-section p, .help-section li { font-size: 0.9rem; margin-bottom: 6px; }
.help-section ul, .help-section ol { padding-left: 22px; margin-bottom: 12px; }
.help-tip {
    margin-top: 14px; padding: 10px 14px;
    background: rgba(0, 86, 179, 0.08); border-left: 3px solid #0056b3;
    border-radius: 4px; font-size: 0.85rem; color: var(--text-secondary);
}
.help-warning {
    margin-top: 14px; padding: 10px 14px;
    background: rgba(220, 53, 69, 0.08); border-left: 3px solid #dc3545;
    border-radius: 4px; font-size: 0.85rem; color: var(--text-secondary);
}
.faq-item { border-bottom: 1px solid var(--border-light); padding: 12px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
    cursor: pointer; font-weight: 500; font-size: 0.9rem;
    color: var(--text-main); list-style: none; display: flex;
    justify-content: space-between; align-items: center; user-select: none;
}
.faq-item summary::after { content: '+'; font-size: 1.1rem; color: var(--text-muted); }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p { margin-top: 8px; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; }

/* Strapi-rendered markdown styles */
.help-loading { color: var(--text-muted); font-style: italic; padding: 20px 0; }
.help-article { margin-bottom: 32px; }
.help-markdown h2 { font-size: 1rem; font-weight: 600; margin: 18px 0 6px; color: var(--text-header); }
.help-markdown h3 { font-size: 0.95rem; font-weight: 600; margin: 14px 0 4px; color: var(--text-header); }
.help-markdown ul,
.help-markdown ol { padding-left: 22px; margin-bottom: 10px; }
.help-markdown li { font-size: 0.9rem; margin-bottom: 4px; }
.help-markdown p  { font-size: 0.9rem; margin-bottom: 8px; }
.help-markdown blockquote {
    margin: 12px 0; padding: 8px 14px;
    background: rgba(0, 86, 179, 0.07); border-left: 3px solid #0056b3;
    border-radius: 4px; font-size: 0.85rem; color: var(--text-secondary);
}
.help-markdown strong { font-weight: 600; }
.help-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 16px;
    font-size: 0.875rem;
}
.help-markdown th,
.help-markdown td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
    color: var(--text-main);
}
.help-markdown th {
    background: var(--bg-secondary, var(--bg-body));
    font-weight: 600;
    color: var(--text-header);
}
.help-markdown tr:nth-child(even) td {
    background: var(--bg-secondary, var(--bg-body));
}
.help-markdown img {
    display: block;
    max-width: 100%;
    margin: 16px 0 4px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.help-markdown img + em {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ── Advanced Filter Row ──────────────────────────────────────── */
.mycases-toolbar { flex-wrap: wrap; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}
.filter-date {
    font-size: 0.82rem;
    padding: 5px 8px;
    max-width: 145px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
body.dark-mode .filter-date {
    color-scheme: dark;
}
.filter-row-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
}
.btn-reset-filters {
    margin-left: auto;
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-reset-filters:hover {
    background: var(--bg-card);
    color: var(--text-main);
}

/* AI Settings Component */
.ai-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#ai-settings-form .form-actions {
    margin-top: 24px;
}

.field-hint {
    margin: 4px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── First-Run Setup Wizard ───────────────────────────────────── */
#setup-wizard {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main, #f5f5f5);
    padding: 2rem 1rem;
}

.setup-wizard-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.setup-logo {
    width: 120px;
    margin-bottom: 1rem;
}

.setup-wizard-card h1 {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
}

.setup-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.setup-row {
    display: flex;
    gap: 12px;
}

.setup-row .field {
    flex: 1;
}

.setup-footer-note {
    margin-top: 1rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Topbar User Wrapper & Profile Dropdown ───────────────────── */
.topbar-user-wrapper {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.topbar-user-wrapper .topbar-user {
    border-radius: 8px;
    padding: 4px 8px;
    transition: background 0.15s;
}

.topbar-user-wrapper .topbar-user:hover {
    background: var(--bg-secondary);
}

.user-profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 1200;
    overflow: hidden;
    animation: fadeInDown 0.15s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown-avatar-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 16px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.user-dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-dropdown-name {
    font-size: 0.97rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    line-height: 1.2;
}

.user-dropdown-email {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 4px 16px;
}

.user-dropdown-item:first-of-type {
    padding-top: 10px;
}

.user-dropdown-item:last-of-type {
    padding-bottom: 14px;
}

.user-dropdown-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.user-dropdown-value {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

/* ── Settings — Avatar Upload ─────────────────────────────────── */
.avatar-section {
    padding-bottom: 20px;
}

.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.settings-avatar-preview {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 3px solid var(--border-color);
}

.settings-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.avatar-upload-label {
    display: inline-block;
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.avatar-upload-label:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}

.avatar-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

#avatar-upload-status {
    font-size: 0.8rem;
    min-height: 1.2em;
}

#avatar-upload-status.success {
    color: var(--success, #22c55e);
}

#avatar-upload-status.error {
    color: var(--danger, #ef4444);
}

/* btn-secondary generic style (if not already defined) */
.btn-secondary:not([class*="btn-primary"]):not([class*="btn-danger"]) {
    background: var(--bg-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Avatar Crop Modal ────────────────────────────────────────── */
.avatar-crop-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.avatar-crop-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.avatar-crop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.avatar-crop-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.avatar-crop-close:hover {
    background: var(--bg-secondary);
    color: var(--text-main);
}

.avatar-crop-body {
    padding: 16px;
    background: #1a1a1a;
}

.avatar-crop-container {
    width: 100%;
    max-height: 420px;
    overflow: hidden;
}

.avatar-crop-container img {
    display: block;
    max-width: 100%;
}

.avatar-crop-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
}

/* ── Help & Support — AI Chat Widget ─────────────────────────── */
.help-chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.help-chat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 10px 14px;
    /* Light mode: white pill with blue icon and text */
    background: #ffffff;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.help-chat-toggle:hover {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    transform: translateY(-1px);
}

/* Dark mode: invert — filled accent pill */
body.dark-mode .help-chat-toggle {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

body.dark-mode .help-chat-toggle:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-fg);
}

.help-chat-label {
    letter-spacing: 0.01em;
}

.help-chat-panel {
    width: 340px;
    max-height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInDown 0.15s ease;
}

.help-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    background: var(--accent);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    flex-shrink: 0;
}

.help-chat-title {
    display: flex;
    align-items: center;
}

.help-chat-icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}

.help-chat-icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

.help-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.help-chat-msg {
    display: flex;
}

.help-chat-msg--user {
    justify-content: flex-end;
}

.help-chat-msg--assistant {
    justify-content: flex-start;
}

.help-chat-bubble {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.help-chat-msg--user .help-chat-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.help-chat-msg--assistant .help-chat-bubble {
    background: var(--bg-secondary);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Typing indicator */
.help-chat-typing .help-chat-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.2s infinite ease-in-out;
    display: inline-block;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

.help-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.help-chat-input {
    flex: 1;
    padding: 7px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.15s;
}

.help-chat-input:focus {
    border-color: var(--accent);
}

.help-chat-input:disabled {
    opacity: 0.6;
}

.help-chat-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: filter 0.15s, transform 0.1s;
}

.help-chat-send:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}
