/* ============================================================
   Growtify CRM — Premium Light SaaS Theme
   Version: 2.0.0
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Brand Colors */
    --brand-red: #e83e3e;
    --brand-red-dark: #c0392b;
    --brand-red-light: rgba(232, 62, 62, 0.08);
    --brand-accent: #ff6b6b;

    /* Mesh Gradient Background */
    --mesh-gradient: radial-gradient(at 0% 0%, rgba(232, 62, 62, 0.03) 0, transparent 50%),
                     radial-gradient(at 50% 0%, rgba(232, 62, 62, 0.02) 0, transparent 50%),
                     radial-gradient(at 100% 0%, rgba(232, 62, 62, 0.03) 0, transparent 50%);

    /* Premium Light Theme */
    --bg-primary: #f8faff;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --topbar-bg: rgba(255, 255, 255, 0.7);

    /* Borders & Rounding (PREMIUM SOFT) */
    --border-color: #f1f3f7;
    --border-radius-sm: 12px;
    --border-radius: 24px;
    --border-radius-lg: 32px;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Premium Shadows (MULTI-LAYERED SOFT) */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.08);
    --shadow-premium: 0 20px 60px -12px rgba(0, 0, 0, 0.1);
    --shadow-red: 0 10px 30px rgba(232, 62, 62, 0.25);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-blur: blur(24px);

    /* Font stack */
    --brand-font: 'Plus Jakarta Sans', 'Outfit', sans-serif;
}

/* ── Global Reset ───────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
    font-family: var(--brand-font);
    background-color: var(--bg-primary);
    background-image: var(--mesh-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseSubtle {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.animate-fade-in { animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }

/* ── Glassmorphism & Premium Patterns ───────────────────────── */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
}

.premium-card {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.premium-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-premium);
    border-color: rgba(232, 62, 62, 0.1);
}

/* ── Widget Styles (Premium App Style) ──────────────────────── */
.widget-stat {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.widget-icon-box {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.widget-icon-box::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.12;
    background: currentColor;
    z-index: -1;
    border: 1px solid currentColor;
}

.widget-stat:hover .widget-icon-box {
    transform: scale(1.1) rotate(-5deg);
}

.widget-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -1.5px;
}

.widget-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

/* ── Widget Trends ────────────────────────────────────────── */
.widget-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 0.75rem;
}

.trend-up {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 8px;
}

.trend-down {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 2px 8px;
    border-radius: 8px;
}

.trend-neutral {
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 8px;
}

/* ── Top Posts & Platform Pills ───────────────────────────── */
.platform-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    border: 1px solid rgba(0,0,0,0.05);
}

.top-post-card {
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    background: white;
    transition: all 0.3s ease;
}

.top-post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.top-post-img {
    height: 140px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* ── Global Tag Overrides ───────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.8px;
}

p { color: var(--text-secondary); }
a { color: var(--brand-red); }

/* ── PUBLIC PAGES (Login, Landing) ─────────────────────────── */

.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
}

.logo-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--brand-red), #ff6b6b);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
    box-shadow: 0 4px 12px rgba(232, 62, 62, 0.35);
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--brand-red); }

.auth-btns { display: flex; gap: 0.75rem; }

.btn-saas {
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    border: none;
    display: inline-flex;
    align-items: center;
}

.btn-saas-primary {
    background: var(--brand-red);
    color: white;
    box-shadow: 0 4px 12px rgba(232, 62, 62, 0.3);
}

.btn-saas-primary:hover {
    background: var(--brand-red-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(232, 62, 62, 0.4);
    color: white;
}

.btn-saas-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
}

.btn-saas-outline:hover {
    background: var(--bg-primary);
    border-color: var(--brand-red);
    color: var(--brand-red);
}

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    background: linear-gradient(135deg, #fafbff 0%, #f0f2f8 100%);
}

.auth-card {
    background: white;
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-header h2 {
    font-size: 1.9rem;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.auth-header p { color: var(--text-muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-saas-control {
    width: 100%;
    background: #f8f9fc;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-saas-control:focus {
    outline: none;
    border-color: var(--brand-red);
    background: white;
    box-shadow: 0 0 0 3px rgba(232, 62, 62, 0.1);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-check-input { accent-color: var(--brand-red); }

/* ── Footer ─────────────────────────────────────────────────── */
.main-footer {
    padding: 3rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: white;
}

.footer-text { font-size: 0.875rem; color: var(--text-muted); }
.footer-branding { font-weight: 700; color: var(--brand-red); margin: 0 4px; }


/* ══════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT (Internal Pages)
   ══════════════════════════════════════════════════════════════ */

body .crm-wrapper {
    display: flex !important;
    min-height: 100vh !important;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body .sidebar {
    width: 280px !important;
    min-width: 280px !important;
    background: var(--sidebar-bg) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border-right: 1px solid var(--border-color) !important;
    display: flex !important;
    flex-direction: column !important;
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    padding: 1rem 0 !important;
    z-index: 1000 !important;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

body .sidebar-brand {
    padding: 2.5rem 2rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 1rem !important;
}

body .sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 1rem !important;
    flex-grow: 1 !important;
    overflow-y: auto !important;
    gap: 0.5rem !important;
}

.sidebar-section {
    font-size: 0.72rem !important;
    text-transform: uppercase !important;
    letter-spacing: 2px !important;
    color: var(--text-muted) !important;
    margin: 1.5rem 0 0.75rem 1.25rem !important;
    font-weight: 800 !important;
    opacity: 0.6;
}

body .nav-item-crm {
    display: flex !important;
    align-items: center !important;
    gap: 1rem !important;
    padding: 0.9rem 1.25rem !important;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    border-radius: 18px !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

body .nav-item-crm i {
    font-size: 1.25rem !important;
    width: 24px !important;
    text-align: center !important;
    color: var(--text-muted) !important;
    transition: all 0.3s ease !important;
}

body .nav-item-crm:hover {
    background: var(--brand-red-light) !important;
    color: var(--brand-red) !important;
    transform: translateX(5px) !important;
}

body .nav-item-crm:hover i {
    color: var(--brand-red) !important;
}

body .nav-item-crm.active {
    background: var(--brand-red) !important;
    color: white !important;
    box-shadow: var(--shadow-red) !important;
}

body .nav-item-crm.active i {
    color: white !important;
}

body .sidebar-footer {
    padding: 1.5rem !important;
    border-top: 1px solid var(--border-color) !important;
    background: rgba(255, 255, 255, 0.5) !important;
    border-radius: 0 0 0 0 !important;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.25rem;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand-red), var(--brand-accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(232, 62, 62, 0.2);
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Topbar ─────────────────────────────────────────────────── */
body .main-content {
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    background: var(--bg-primary) !important;
}

body .topbar {
    height: 75px !important;
    background: var(--topbar-bg) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border-bottom: 1px solid var(--border-color) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 2.5rem !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 990 !important;
    box-shadow: var(--shadow-sm) !important;
}

.topbar-title {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    letter-spacing: -0.5px !important;
}

.page-content {
    padding: 2.5rem !important;
    flex-grow: 1 !important;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.6rem;
    margin: 0;
    color: var(--text-primary);
}

/* ── Stat Cards ─────────────────────────────────────────────── */
/* ── Global Card Overrides ────────────────────────────────────── */
.card,
body .card {
    background: white !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text-primary) !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow: hidden !important;
}

body .card:hover {
    box-shadow: var(--shadow-md) !important;
}

body .card-header {
    background: white !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.5rem 2rem !important;
    font-weight: 700 !important;
}

body .card-body {
    padding: 2rem !important;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card,
body .card {
    background: white !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text-primary) !important;
}

body .card-header {
    background: white !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.25rem 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    border-radius: 16px 16px 0 0 !important;
}

body .card-header h5 {
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table, body .table {
    color: var(--text-primary) !important;
}

body .table thead th {
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border-bottom: 2px solid var(--border-color) !important;
    padding: 0.75rem 1rem !important;
    background: #fafbfc !important;
}

body .table tbody td {
    padding: 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle !important;
    color: var(--text-primary) !important;
    font-size: 0.875rem !important;
}

body .table tbody tr:hover {
    background: #fafbfc !important;
}

body .text-muted {
    color: var(--text-muted) !important;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary,
body .btn-primary {
    background: var(--brand-red) !important;
    border-color: var(--brand-red) !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 8px rgba(232, 62, 62, 0.25) !important;
}

.btn-primary:hover,
body .btn-primary:hover {
    background: var(--brand-red-dark) !important;
    border-color: var(--brand-red-dark) !important;
    box-shadow: 0 4px 12px rgba(232, 62, 62, 0.35) !important;
}

.btn-outline-primary,
body .btn-outline-primary {
    color: var(--brand-red) !important;
    border-color: var(--brand-red) !important;
    border-radius: 10px !important;
}

.btn-outline-primary:hover,
body .btn-outline-primary:hover {
    background: var(--brand-red) !important;
    color: white !important;
    border-color: var(--brand-red) !important;
}

/* CRM-specific button styles (from original app.css) */
.btn-primary-crm {
    background: var(--brand-red);
    color: white;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(232, 62, 62, 0.2);
}

.btn-primary-crm:hover {
    background: var(--brand-red-dark);
    transform: translateY(-1px);
    color: white;
}

.btn-outline-crm {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline-crm:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

/* ── Notification Badge ──────────────────────────────────────── */
.notif-badge {
    background: var(--brand-red);
    color: white;
    border-radius: 99px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 800;
}

.notif-btn {
    background: #f1f3f7;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.notif-btn:hover { background: #e8ebf2; }

.icon-btn {
    background: #f1f3f7;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: #fff0f0;
    color: var(--brand-red);
}

/* ── Alert Messages ──────────────────────────────────────────── */
.alert-crm {
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success-crm { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-danger-crm { background: #fff5f5; color: #c53030; border-color: #fed7d7; }
.alert-info-crm { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ── Status Badges ───────────────────────────────────────────── */
.status-badge {
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: capitalize;
    display: inline-block;
}

.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-pending { background: #fef9c3; color: #a16207; }
.badge-approved { background: #dcfce7; color: #15803d; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-scheduled { background: #dbeafe; color: #1d4ed8; }
.badge-published { background: #ede9fe; color: #6d28d9; }

/* ── Platform Pills ──────────────────────────────────────────── */
.platform-pill {
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-block;
}

.instagram { background: #fce4ec; color: #c2185b; }
.facebook { background: #e3f2fd; color: #1565c0; }
.tiktok { background: #f3e5f5; color: #6a1b9a; }
.linkedin { background: #e8f4fd; color: #0a66c2; }
.twitter { background: #e8f5fe; color: #1da1f2; }

/* ── Misc ────────────────────────────────────────────────────── */
.border-bottom { border-bottom: 1px solid var(--border-color) !important; }
.bg-light { background-color: var(--bg-primary) !important; }

/* Scrollbars - Light Theme */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-red); }

/* ── Page Header — HIDDEN because topbar already shows title ── */
.page-header {
    display: none !important;
}

/* ── Chat Layout ─────────────────────────────────────────────── */
/* The chat page needs full remaining viewport height            */
.chat-page-content {
    padding: 0 !important;
    height: calc(100vh - 68px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    display: flex !important;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Sidebar — Contact List */
.chat-sidebar {
    width: 300px;
    min-width: 300px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-header {
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    background: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-sidebar-header i {
    color: var(--brand-red);
}

.chat-sidebar-list {
    overflow-y: auto;
    flex: 1;
}

.chat-user-item {
    display: flex !important;
    align-items: center;
    gap: 0.85rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f3f7;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none !important;
    color: inherit !important;
}

.chat-user-item:hover {
    background: #fafbfc;
}

.chat-user-item.active {
    background: #fff0f0;
    border-left: 3px solid var(--brand-red);
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-red), #ff8080);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.chat-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.chat-last-msg {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-unread {
    background: var(--brand-red);
    color: white;
    border-radius: 99px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fc;
}

.chat-header {
    height: 68px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.chat-user-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.chat-user-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.online-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.chat-back-btn {
    display: none; /* Hidden on desktop, shown on mobile */
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Message Bubbles */
.msg-bubble {
    max-width: 65%;
    padding: 0.65rem 1rem;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.msg-bubble.sent {
    background: var(--brand-red);
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.msg-bubble.recv {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.msg-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Chat Input Footer */
.chat-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-footer .form-control {
    border-radius: 24px;
    border: 1.5px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    background: var(--bg-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.chat-footer .form-control:focus {
    outline: none;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(232, 62, 62, 0.08);
    background: white;
}

.chat-footer .btn-primary-crm {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

/* Mobile Chat */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        transition: transform 0.3s ease;
    }

    .chat-main {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 20;
    }

    body.chat-open .chat-main {
        transform: translateX(0);
    }

    .chat-back-btn {
        display: flex !important;
    }

    .chat-container {
        position: relative;
        height: calc(100vh - 68px - 65px); /* minus topbar + bottom nav */
    }
}


@media (max-width: 992px) {
    body .sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        z-index: 1200 !important;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
    body .sidebar.open {
        left: 0 !important;
    }
    
    .page-content { 
        padding-top: 85px !important; 
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Floating Topbar Icons refined */
    body .topbar {
        position: absolute !important;
        top: 0;
        left: 0;
        right: 0;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        pointer-events: none;
        z-index: 1100 !important;
        height: 80px !important;
        padding: 0 1.25rem !important;
    }
    
    body .topbar #sidebar-toggler,
    body .topbar .topbar-actions {
        pointer-events: auto;
        background: var(--glass-bg);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border: 1px solid var(--glass-border);
        width: 45px;
        height: 45px;
        border-radius: 14px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-sm);
    }
    
    body .topbar .topbar-title {
        display: none !important;
    }

    /* Scaling down widgets for mobile */
    .premium-card { border-radius: 20px !important; }
    .widget-stat { padding: 1.25rem !important; }
    .widget-icon-box { 
        width: 48px !important; 
        height: 48px !important; 
        margin-bottom: 1rem !important;
        font-size: 1.3rem !important;
    }
    .widget-value { font-size: 1.75rem !important; }
    .widget-label { font-size: 0.75rem !important; }
}

@media (max-width: 768px) {
    .page-content { padding-bottom: 100px !important; }

    /* Fix chat layout overlaps */
    .chat-page-content {
        padding-top: 0 !important;
        height: calc(100vh - 65px) !important;
    }
    .chat-header {
        height: 85px !important;
        padding-top: 15px !important;
        padding-left: 70px !important; /* Make room for floating hamburger */
        padding-right: 70px !important; /* Make room for floating bell */
        align-items: center !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
}

/* ── Mobile Bottom Navigation ─────────────────────────────────
   ONLY shown on mobile (max-width: 992px).
   Hidden on all desktop/tablet views.
   ─────────────────────────────────────────────────────────── */
.bottom-nav {
    display: none; /* Hidden by default (desktop) */
}

@media (max-width: 992px) {
    /* Show bottom nav only on mobile */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background: white;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: stretch;
        padding: 0;
    }

    /* Add bottom padding to page content so it's not hidden behind nav */
    .page-content {
        padding-bottom: 80px !important;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.6rem;
        font-weight: 600;
        padding: 8px 4px;
        position: relative;
        transition: color 0.15s ease;
    }

    .bottom-nav-item i {
        font-size: 1.35rem;
        line-height: 1;
    }

    .bottom-nav-item::after {
        content: attr(title);
        font-size: 0.58rem;
        font-weight: 600;
        text-transform: capitalize;
    }

    .bottom-nav-item:hover {
        color: var(--brand-red);
    }

    .bottom-nav-item.active {
        color: var(--brand-red);
    }

    .bottom-nav-item.active i {
        filter: drop-shadow(0 0 4px rgba(232, 62, 62, 0.4));
    }

    /* Active indicator dot */
    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        background: var(--brand-red);
        border-radius: 0 0 4px 4px;
    }

    /* Badge on bottom nav icon */
    .bottom-nav-item .notif-badge {
        position: absolute;
        top: 6px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        font-size: 0.6rem;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }
}

