@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --sidebar-bg: #111827;
    --border-color: #1f2937;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.15);

    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;

    --font-sans: 'Inter', -apple-system, sans-serif;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(12px);

    --sidebar-width: 240px;
    --maillist-width: 310px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ── Custom Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    background-clip: padding-box;
}
/* Firefox scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) rgba(0, 0, 0, 0.2);
}

/* ── Glassmorphism ─────────────────────────────────────────────────── */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    border-radius: 12px;
}

/* ── Login Page ────────────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 40%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 28px 32px;
    box-shadow: var(--shadow-premium);
    animation: fadeIn 0.6s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    background-color: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    transition: var(--transition-smooth);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-color), #4f46e5);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn:hover {
    background: linear-gradient(135deg, var(--accent-hover), #4338ca);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.03);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* ── Alerts ────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error-color);
    color: #fca5a5;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-color);
    color: #a7f3d0;
}

/* ═══════════════════════════════════════════════════════════════════
   MAIL CLIENT — 3-COLUMN DESKTOP LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Mobile overlay backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 200;
}

.sidebar-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.sidebar-section {
    padding: 12px 14px;
}

.section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 8px;
}

.account-selector {
    width: 100%;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.account-selector:focus { outline: none; border-color: var(--accent-color); }

.nav-list { list-style: none; }

.nav-item { margin-bottom: 3px; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition-smooth);
}

.nav-link:hover { color: #ffffff; background-color: rgba(255, 255, 255, 0.04); }

.nav-link.active {
    color: #ffffff;
    background-color: var(--accent-glow);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
}

.nav-icon {
    margin-right: 10px;
    font-size: 16px;
    display: flex;
    align-items: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #ffffff;
    flex-shrink: 0;
}

.user-info { overflow: hidden; }

.user-name {
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 13px;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Mail List Panel ───────────────────────────────────────────────── */
.mail-list-panel {
    width: var(--maillist-width);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #0f172a;
    flex-shrink: 0;
}

.panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title { font-size: 17px; font-weight: 700; }

/* Hamburger — visible on mobile only */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition-smooth);
}

.hamburger-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }

.sync-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition-smooth);
    padding: 4px;
    border-radius: 4px;
}

.sync-btn:hover { color: #ffffff; background: rgba(255, 255, 255, 0.05); }

.search-bar { position: relative; }

.search-input {
    width: 100%;
    padding: 9px 14px 9px 34px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition-smooth);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: rgba(255, 255, 255, 0.05);
}

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

.mail-list-scroll { flex-grow: 1; overflow-y: auto; }

/* ── Mail Cards ────────────────────────────────────────────────────── */
.mail-card {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
}

.mail-card:hover { background-color: rgba(255, 255, 255, 0.02); }

.mail-card.active {
    background-color: rgba(99, 102, 241, 0.06);
    border-left: 3px solid var(--accent-color);
}

.mail-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 11px;
}

.mail-sender { font-weight: 600; color: #ffffff; }
.mail-date   { color: var(--text-muted); white-space: nowrap; }

.mail-subject {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.unread-indicator {
    position: absolute;
    left: 6px;
    top: 17px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
}

.mail-card.unread .mail-subject { font-weight: 700; }
.mail-card.unread .mail-sender  { color: #ffffff; }

/* ── Mail Reader Panel ─────────────────────────────────────────────── */
.mail-reader-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #0b0f19;
    min-width: 0; /* prevent flex overflow */
}

.reader-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.reader-subject {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 5px;
    line-height: 1.3;
}

.sender-details { font-size: 13px; color: var(--text-secondary); }
.sender-details span { color: var(--text-muted); }

.reader-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.reader-actions .btn {
    width: auto;
    padding: 8px 16px;
    font-size: 12.5px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.reader-body-container {
    flex-grow: 1;
    padding: 18px;
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.01);
}

/* ── Email Body iframe ─────────────────────────────────────────────── */
.reader-body-frame {
    width: 100%;
    min-height: 300px;
    border: none;
    background: transparent;
    display: block;
}

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
    padding: 20px;
}

.empty-state-icon { font-size: 48px; opacity: 0.3; }

/* ── Compose Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    padding: 16px;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 660px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-premium);
    transform: translateY(20px);
    transition: var(--transition-smooth);
}

.modal-overlay.show .modal-content { transform: translateY(0); }

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    line-height: 1;
}

.close-btn:hover { color: #ffffff; }

.modal-body { padding: 20px 22px; overflow-y: auto; }

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    flex-wrap: wrap;
}

.modal-body select {
    width: 100%;
    padding: 10px 12px;
    background-color: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    margin-bottom: 14px;
    font-family: var(--font-sans);
    font-size: 13px;
}

/* ── Signature Section in Compose ──────────────────────────────────── */
.signature-divider {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 4px 0 0;
}

.signature-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

#signaturePreview {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 12px;
    resize: vertical;
    line-height: 1.5;
}

/* ── Signature Settings Panel (in admin / profile) ─────────────────── */
.signature-editor {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    background-color: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    resize: vertical;
    line-height: 1.5;
}

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Admin Panel ───────────────────────────────────────────────────── */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
    overflow-y: auto;
    height: calc(100vh - 73px);
}

.admin-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.admin-card h2 {
    font-size: 16px;
    margin-bottom: 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    color: #ffffff;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 13px;
}

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

.admin-table th { color: var(--text-muted); font-weight: 600; }

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

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin  { background-color: rgba(99, 102, 241, 0.15); color: #818cf8; }
.badge-member { background-color: rgba(156, 163, 175, 0.15); color: #d1d5db; }

.delete-link { color: var(--error-color); text-decoration: none; font-weight: 500; }
.delete-link:hover { text-decoration: underline; }

/* ── Spinner ───────────────────────────────────────────────────────── */
.spinner {
    border: 2px solid rgba(255,255,255,.1);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border-left-color: #ffffff;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* ── Comments ──────────────────────────────────────────────────────── */
.comments-section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--border-color);
}

.comments-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 8px;
}

.comment-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 11px 14px;
    animation: fadeIn 0.3s ease-out;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 5px;
    flex-wrap: wrap;
    gap: 4px;
}

.commenter-name { font-weight: 600; color: #818cf8; }

.comment-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: pre-wrap;
}

.comment-text span.mention {
    background-color: rgba(99, 102, 241, 0.35);
    color: #ffffff;
    border-radius: 4px;
    padding: 1px 6px;
    font-weight: 600;
}

.comment-form { display: flex; flex-direction: column; gap: 10px; }

.comment-input-row { display: flex; gap: 10px; }

.comment-textarea {
    flex-grow: 1;
    min-height: 50px;
    max-height: 100px;
    resize: vertical;
}

.tag-select-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tag-select {
    padding: 6px 12px;
    background-color: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE  ≤ 768px
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    body { overflow: auto; height: auto; }

    /* Make the whole app scrollable vertically on mobile */
    .dashboard-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    /* Sidebar slides in as a drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        z-index: 200;
        overflow-y: auto;
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop.open { display: block; }

    .sidebar-close-btn { display: flex; }

    /* Mail list takes full width, fixed height */
    .mail-list-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
        height: auto;
        max-height: 55vh;
    }

    .mail-list-scroll { max-height: 44vh; }

    /* Show hamburger in panel header */
    .hamburger-btn { display: flex; }

    /* Panel header title row gains space for hamburger */
    .panel-title-row { gap: 8px; }

    /* Reader panel full width below list */
    .mail-reader-panel {
        width: 100%;
        flex-grow: 0;
        min-height: 60vh;
    }

    /* Reader header stacks vertically */
    .reader-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .reader-actions { width: 100%; justify-content: flex-start; }

    /* Compose modal full screen on mobile */
    .modal-overlay { padding: 0; align-items: flex-end; }

    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
    }

    /* Admin grid stacks to 1 column */
    .admin-grid { grid-template-columns: 1fr; height: auto; }

    /* Admin table: allow horizontal scroll */
    .admin-table { display: block; overflow-x: auto; white-space: nowrap; }

    /* Reader body padding tighter */
    .reader-body-container { padding: 12px; }

    /* Buttons in reader actions wrap nicely */
    .reader-actions .btn { font-size: 12px; padding: 6px 12px; }

    /* Portal layout on mobile */
    .portal-layout { padding: 20px 16px !important; }

    .metrics-row { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }

    .main-columns { grid-template-columns: 1fr !important; }

    .services-grid { grid-template-columns: 1fr !important; }

    .service-item { height: auto !important; min-height: 120px !important; }

    /* CRM layout on mobile */
    .crm-layout { padding: 20px 14px !important; }

    .metrics-row { grid-template-columns: 1fr 1fr !important; }
}

/* ── Tablet: 769–1024px ────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {

    :root {
        --sidebar-width: 200px;
        --maillist-width: 260px;
    }

    .reader-actions { flex-wrap: wrap; gap: 6px; }

    .reader-actions .btn { font-size: 12px; padding: 6px 10px; }

    .metrics-row { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   CRM WORKSPACE & TICKET ASSIGNMENT CUSTOM STYLES
   ═══════════════════════════════════════════════════════════════════ */

/* ── Premium Buttons & Focus Upgrade ─────────────────────────────── */
.btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent-color) 0%, #4f46e5 100%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    letter-spacing: 0.2px;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.06);
    opacity: 0;
    transition: opacity 0.2s;
}
.btn:hover::after {
    opacity: 1;
}
.btn:active {
    transform: translateY(0.5px);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: none !important;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #fff !important;
}

/* ── Count Badges for Sidebar ────────────────────────────────────── */
.badge-count {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
}
.nav-link:hover .badge-count {
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* ── Contact Badges & Priorities ────────────────────────────────── */
.contact-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}
.priority-high {
    background-color: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.priority-medium {
    background-color: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.15);
}
.priority-low {
    background-color: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

/* ── CRM Timeline Feed ───────────────────────────────────────────── */
.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 10px;
}
.timeline-item {
    position: relative;
    padding-left: 28px;
    border-left: 2px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    transition: var(--transition-smooth);
}
.timeline-item:hover {
    border-left-color: var(--accent-color);
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1f2937;
    border: 2px solid #0f1424;
    transition: var(--transition-smooth);
}
.timeline-item:hover::before {
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
    border-color: #fff;
}
.timeline-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.timeline-direction {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
}
.direction-in { color: #818cf8; }
.direction-out { color: #34d399; }
.timeline-subject {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}
.timeline-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Details Drawer ──────────────────────────────────────────────── */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}
.drawer-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.drawer-content {
    position: fixed;
    top: 0;
    right: -560px;
    width: 100%;
    max-width: 560px;
    height: 100%;
    background: #0b0f19;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}
.drawer-content.show {
    right: 0;
}
.drawer-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.drawer-title-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.drawer-title {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    margin-top: 4px;
}
/* Tabs inside drawer */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    padding: 10px 24px;
}
.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
    font-family: inherit;
    outline: none;
}
.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}
.tab-btn.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    font-weight: 600;
}
.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
}
.drawer-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0,0,0,0.2);
    display: flex;
    gap: 12px;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-val {
    font-size: 13px;
    color: #fff;
}
.detail-val.full-width {
    grid-column: span 2;
}

/* ── Email Preview modal ─────────────────────────────────────────── */
.email-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}
.email-preview-modal.show {
    opacity: 1;
    pointer-events: auto;
}
.email-preview-content {
    width: 100%;
    max-width: 800px;
    height: 85vh;
    background: #0f1424;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── CRM Database Tables ─────────────────────────────────────────── */
.contacts-table {
    width: 100%;
    border-collapse: collapse;
}
.contacts-table th {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.contacts-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.contacts-table tr:hover td {
    background: rgba(255,255,255,0.015);
}


/* ── Notifications Bell & Dropdown ───────────────────────────────── */
.notification-bell-container {
    position: relative;
    display: inline-block;
}
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: var(--error-color);
    border-radius: 50%;
    border: 1px solid #0b0f19;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #1e293b; /* charcoal gray background */
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    z-index: 1200;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: notifFadeIn 0.2s ease;
}
@keyframes notifFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}
.notif-dropdown-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}
.notif-dropdown-header button {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.notif-dropdown-header button:hover {
    text-decoration: underline;
}
.notif-dropdown-list {
    max-height: 320px;
    overflow-y: auto;
}
/* Scrollbar styling for notification dropdown list */
.notif-dropdown-list::-webkit-scrollbar {
    width: 6px;
}
.notif-dropdown-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.notif-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.notif-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    text-decoration: none;
    color: var(--text-primary);
}
.notif-item:hover {
    background: rgba(255,255,255,0.02);
}
.notif-item:last-child {
    border-bottom: none;
}
.notif-item.read {
    opacity: 0.5; /* grayed out read notifications */
}
.notif-item.read:hover {
    opacity: 0.95;
}
.notif-icon-box {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.notif-icon-email {
    background: rgba(99,102,241,0.15);
    color: #818cf8;
}
.notif-icon-mention {
    background: rgba(245,158,11,0.15);
    color: #fbbf24;
}
.notif-item-body {
    min-width: 0;
    flex: 1;
}
.notif-item-text {
    font-size: 12px;
    line-height: 1.4;
    color: #e2e8f0;
    margin-bottom: 4px;
    word-break: break-word;
}
.notif-item-time {
    font-size: 10px;
    color: var(--text-muted);
}
.notif-empty {
    padding: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}
.notif-section-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 16px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    border-top: 1px solid rgba(255,255,255,0.03);
}
.notif-section-header:first-child {
    border-top: none;
}
.notif-empty-inline {
    padding: 12px 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
    text-align: center;
}

/* ── Global Custom Slim Scrollbar Styling ──────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: var(--transition-smooth);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid transparent;
    background-clip: padding-box;
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) rgba(0, 0, 0, 0.15);
}

/* ── Mobile Layouts & Responsiveness Overrides ─────────────────────── */
@media (max-width: 768px) {
    /* Main Layout overrides on mobile */
    .portal-layout, .tracker-layout, .crm-db-layout {
        height: auto !important;
        min-height: 100vh;
        overflow-y: visible !important;
        padding: 20px 14px !important;
    }

    .crm-db-header, .tracker-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 16px;
    }

    .crm-db-header > div:last-child, .tracker-header > div:last-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .crm-db-header .btn, .tracker-header .btn {
        width: 100% !important;
        text-align: center;
        justify-content: center;
    }

    .user-profile {
        justify-content: center;
        width: 100%;
    }

    /* Database tabs on mobile */
    .db-tabs-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
        border-bottom: none !important;
    }
    .db-tabs {
        flex-direction: column !important;
        width: 100% !important;
        gap: 6px !important;
    }
    .db-tab-btn {
        width: 100% !important;
        justify-content: center;
        border-bottom: none !important;
        border-radius: 6px !important;
        background: rgba(255, 255, 255, 0.02) !important;
    }
    .db-tab-btn.active {
        background: var(--accent-glow) !important;
        border: 1px solid rgba(99, 102, 241, 0.3) !important;
    }

    /* Drawers on mobile */
    .drawer-content {
        width: 100% !important;
        max-width: 100% !important;
        right: -100% !important;
    }
    .drawer-content.show {
        right: 0 !important;
    }
    .drawer-footer {
        padding: 16px !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    .drawer-footer .btn {
        flex: 1 1 calc(50% - 8px);
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .detail-val.full-width {
        grid-column: span 1 !important;
    }
    
    /* Metrics rows on mobile */
    .metrics-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        margin-bottom: 24px !important;
    }
}

@media (max-width: 480px) {
    .metrics-row {
        grid-template-columns: 1fr !important;
    }
}
