/* ===== MEDISYNC DESIGN SYSTEM ===== */
/* Font: Roboto | Theme: Clean White Minimalist */

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

:root {
    --primary: #1a4c6b;
    --primary-light: #f0f6fa;
    --primary-dark: #113247;
    --accent: #0d9488;
    --danger: #d32f2f;
    --bg: #ffffff;
    --bg-alt: #f7f8fa;
    --border: #e8eaed;
    --text: #202124;
    --text-secondary: #5f6368;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 20px;
    --glass: rgba(255, 255, 255, 0.85);
}

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

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Inter', 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-alt);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 48px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeUp .5s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-card .logo-area { margin-bottom: 32px; }
.login-card .logo-area img { max-width: 180px; height: auto; }
.login-card h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 4px; }
.login-card .subtitle {
    font-size: 0.85rem; font-weight: 400;
    color: var(--text-secondary); letter-spacing: 1px;
    text-transform: uppercase; margin-bottom: 36px;
}

@media (max-width: 576px) {
    .login-container {
        padding: 16px;
        background: #fff;
    }
    .login-card {
        padding: 32px 20px;
        box-shadow: none;
        border: none;
    }
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label {
    display: block; font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.input-field, select.input-field, textarea.input-field {
    width: 100%; padding: 12px 16px;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    background: var(--bg-alt);
    color: var(--text);
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem;
    transition: all .25s ease;
    outline: none;
}
.input-field:hover { background: #f0f1f3; }
.input-field:focus {
    border-color: var(--primary);
    background: var(--bg);
    box-shadow: 0 0 0 3px rgba(0,70,173,0.12);
}
.input-field::placeholder { color: #bbb; }

textarea.input-field { resize: vertical; min-height: 120px; }
select.input-field { cursor: pointer; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 28px; border-radius: var(--radius); border: none;
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem; font-weight: 500;
    cursor: pointer; transition: all .2s ease;
}
.btn-primary {
    background: var(--primary); color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0,70,173,0.25);
    transform: translateY(-1px);
}
.btn-sm { padding: 8px 20px; font-size: 0.85rem; width: auto; }
.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #00a844; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-warning { background: #f57f17; color: #fff; }
.btn-warning:hover { background: #e67616; }

/* ===== LAYOUT ===== */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    padding-top: 88px; /* Offset for global fixed header with dynamic clock-in pill */
}

/* ===== SIDEBAR (HIDDEN IN FAVOR OF NEW TAILWIND SIDEBAR) ===== */
.sidebar {
    display: none !important;
}
.sidebar-brand {
    text-align: center; margin-bottom: 36px; padding: 0 8px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.mobile-close { display: none; }
.sidebar-brand img { max-width: 140px; margin-bottom: 8px; }
.sidebar-brand h2 {
    font-size: 1.25rem; font-weight: 600;
    color: var(--primary);
}

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 16px; border-radius: 10px;
    font-size: 0.9rem; font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 4px;
    transition: all .2s ease;
}
.nav-link i { width: 20px; text-align: center; font-size: 1rem; }
.nav-link:hover { background: var(--border); color: var(--text); }
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}
.nav-section {
    font-size: 0.7rem; font-weight: 500;
    color: #aaa; text-transform: uppercase;
    letter-spacing: 1.5px; padding: 16px 16px 8px;
}

/* ===== MAIN CONTENT ===== */
.main-content { 
    flex-grow: 1;
    padding: 24px 32px; 
    width: 100%;
    margin-left: 260px; /* Offset for desktop left sidebar (w-64) */
    transition: all 0.3s ease;
}

@media (max-width: 1023px) {
    .main-content {
        margin-left: 80px; /* Offset for tablet compact sidebar rail (w-20) */
        padding: 20px;
    }
}

@media (max-width: 767px) {
    .main-content {
        margin-left: 0; /* No offset for mobile drawer view */
        padding: 16px;
    }
}

/* Glassmorphism custom premium tokens */
:root {
    --glass-bg: linear-gradient(135deg, rgba(224, 242, 241, 0.4) 0%, rgba(255, 255, 255, 0.6) 50%, rgba(178, 223, 219, 0.4) 100%);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(11, 74, 70, 0.05);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.page-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 36px;
}
.page-header h1 { font-size: 1.75rem; font-weight: 600; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 2px; }

.profile-pill {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 20px 8px 8px; border-radius: 50px;
    background: var(--bg-alt); border: 1px solid var(--border);
    cursor: pointer; transition: all .2s;
    white-space: nowrap; flex-shrink: 0;
}
.attendance-widget {
    white-space: nowrap; flex-shrink: 0;
}
.profile-pill:hover { box-shadow: var(--shadow); }
.profile-pill .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
}
.profile-pill span { font-weight: 500; font-size: 0.9rem; }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px; margin-bottom: 36px;
}
.stat-card {
    padding: 24px; border-radius: var(--radius);
    background: var(--bg); border: 1px solid var(--border);
    transition: all .2s;
}
.stat-card:hover {
    box-shadow: var(--shadow); transform: translateY(-2px);
}
.stat-label {
    font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 8px;
}
.stat-value { font-size: 2rem; font-weight: 600; color: var(--primary); }

/* ===== CARDS / SECTIONS ===== */
.card {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px;
    margin-bottom: 24px;
}
.card-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 24px;
}
.card-header h3 { font-size: 1.1rem; font-weight: 600; }

/* ===== TABLES ===== */
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 18px 24px;
    font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    background: transparent;
}
td {
    padding: 18px 24px; border-bottom: 1px solid var(--border);
    font-size: 0.95rem; color: var(--text);
}
tr:hover td { background: var(--bg-alt); }

/* Table Responsive Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== STATUS PILLS ===== */
.pill {
    display: inline-block; padding: 4px 14px;
    border-radius: 50px; font-size: 0.75rem; font-weight: 500;
}
.pill-success { background: #e8f5e9; color: #2e7d32; }
.pill-warning { background: #fff8e1; color: #f57f17; }
.pill-danger  { background: #fce4ec; color: #c62828; }
.pill-info    { background: var(--primary-light); color: var(--primary); }
.pill-muted   { background: #f1f3f4; color: #666; }

/* ===== GRID UTILS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.dashboard-main-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.hr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.awards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.bottom-cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.full-span { grid-column: 1 / -1; }

/* ===== DISPATCH MODULE ===== */
.dispatch-file {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 8px;
    transition: all .2s;
}
.dispatch-file:hover { background: var(--bg-alt); }
.dispatch-file i { color: var(--danger); font-size: 1.2rem; }
.dispatch-file .name { flex: 1; font-weight: 500; }
.dispatch-file .meta { font-size: 0.8rem; color: var(--text-secondary); }

.progress-bar {
    width: 100%; height: 6px; border-radius: 3px;
    background: var(--border); overflow: hidden; margin: 16px 0;
}
.progress-bar .fill {
    height: 100%; border-radius: 3px;
    background: var(--primary); transition: width .3s ease;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-secondary);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; opacity: .4; }
.empty-state p { font-size: 1rem; }

/* ===== RESPONSIVE: TABLET (769px - 1024px) ===== */
@media (max-width: 1024px) {
    .dashboard-main-grid { grid-template-columns: 1fr; }
    .awards-grid { grid-template-columns: repeat(2, 1fr); }
    .intel-grid { grid-template-columns: repeat(2, 1fr); }
    .hr-grid { grid-template-columns: 1fr 1fr; }
    .bottom-cards-grid { grid-template-columns: 1fr; }
    .main-content { padding: 24px 20px; }
    .grid-2 { grid-template-columns: 1fr 1fr; gap: 20px; }
    .grid-3 { grid-template-columns: 1fr 1fr; gap: 20px; }
    .modal-content { width: 90%; max-width: 700px; }
}

/* ===== RESPONSIVE: MOBILE (768px and below) ===== */
@media (max-width: 768px) {
    .dashboard-layout { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }
    .awards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .intel-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .hr-grid { grid-template-columns: 1fr; }
    .bottom-cards-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }
    .card { padding: 16px; }
    .card-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    th, td { padding: 12px 10px; font-size: 0.8rem; }
    .modal-content { width: 95%; max-width: none; height: 85vh; margin: 5vh auto; }
    .btn { padding: 10px 20px; font-size: 0.85rem; }
}

/* ===== RESPONSIVE: SMALL MOBILE (480px and below) ===== */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-label { font-size: 0.7rem; }
    .stat-value { font-size: 1.3rem; }
    .awards-grid { grid-template-columns: 1fr; gap: 10px; }
    .intel-grid { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 1.1rem; }
    .card-header h3 { font-size: 0.95rem; }
    .btn { padding: 8px 16px; font-size: 0.8rem; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ===== MODAL ===== */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px); animation: fadeIn 0.3s ease;
}
.modal-content {
    background-color: var(--bg); margin: 5vh auto; padding: 20px;
    border-radius: var(--radius); width: 80%; max-width: 1000px; height: 90vh;
    box-shadow: var(--shadow); position: relative;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.modal-close { cursor: pointer; font-size: 1.5rem; color: var(--text-secondary); }
.modal-close:hover { color: var(--danger); }
.modal-body { flex: 1; overflow: hidden; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
}

.mobile-nav-group {
    display: none !important;
}

/* Row Highlight for new calls */
.row-highlight td {
    background-color: #fff9c4 !important;
}
/* ===== RESPONSIVE DESIGN (Mobile/Tablet) ===== */
@media (max-width: 992px) {
    .dashboard-layout { 
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 2000;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.15);
        display: flex !important;
        flex-direction: column;
        background: white;
        padding-bottom: 80px; /* Space for bottom nav if needed */
    }

    .mobile-close {
        display: block !important;
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(8px);
        z-index: 1999;
        animation: fadeIn 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        padding: 16px;
        margin-top: 0;
        padding-bottom: 100px; /* Important: space for bottom nav */
    }

    .mobile-menu-toggle {
        display: none !important; /* Hidden because we have bottom nav menu button */
    }

    .page-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--glass);
        backdrop-filter: blur(12px);
        margin: -16px -16px 24px -16px;
        padding: 16px;
        border-bottom: 1px solid var(--border);
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .page-header h1 { font-size: 1.25rem; }
    .page-header p { display: none; }

    /* Hide chat trigger on mobile, use bottom nav instead */
    .chat-trigger {
        display: none !important;
    }
    
    .chat-box {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        z-index: 9999;
    }

    .stats-grid, .perf-grid, .awards-grid, .dashboard-main-grid, .hr-grid, .bottom-cards-grid, .portal-grid, .intel-grid, .intel-grid > div {
        grid-template-columns: 1fr !important;
    }

    .card {
        padding: 20px;
        border-radius: var(--radius);
        border: none;
        box-shadow: 0 2px 10px rgba(0,0,0,0.03);
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }
    
    .table-responsive table {
        width: 100%;
        min-width: 600px;
    }
    
    /* Horizontal Tabs for Mobile */
    .tabs {
        display: flex !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 5px;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex-shrink: 0 !important; }

    /* Modal Responsiveness */
    .modal-content, .modal > div.card {
        width: 95% !important;
        max-width: 500px !important;
        margin: 10px auto !important;
    }
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 1500;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
}

@media (max-width: 992px) {
    .mobile-bottom-nav {
        display: flex;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    gap: 4px;
    flex: 1;
    transition: all 0.2s;
    cursor: pointer;
}

.bottom-nav-item i {
    font-size: 1.2rem;
    transition: all 0.2s;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
}

.chat-toggle-btn {
    position: relative;
    top: -15px;
}

.chat-icon-wrapper {
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 70, 173, 0.3);
    border: 4px solid var(--bg);
}

.chat-icon-wrapper i {
    font-size: 1.4rem;
}

.chat-toggle-btn span {
    margin-top: 5px;
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .profile-pill span {
        display: none;
    }
    
    .profile-pill {
        padding: 4px;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr;
    }
    /* Performance header badge hidden on very small screens to prevent overflow */
    .perf-live-badge {
        display: none !important;
    }
    /* Perf grid: 2 cols on mobile instead of 4-6 */
    .perf-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .perf-grid .perf-card[style*="grid-column: span 2"] {
        grid-column: 1 / -1 !important;
    }
    /* Date input: full width of its container */
    #perfDateSelector {
        max-width: 110px;
    }
}

/* ===== PROFILE DROPDOWN ===== */
.profile-container { position: relative; }
.profile-dropdown {
    position: absolute; top: 110%; right: 0;
    width: 200px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); display: none; z-index: 1000;
    padding: 8px 0; animation: fadeDown 0.2s ease;
}
.profile-dropdown.show { display: block; }
.dropdown-item {
    padding: 10px 20px; display: flex; align-items: center; gap: 12px;
    font-size: 0.9rem; color: var(--text); transition: background 0.2s;
    cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-alt); }
.dropdown-item i { color: var(--text-secondary); width: 16px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 8px 0; }
.dropdown-item.logout { color: var(--danger); }
.dropdown-item.logout i { color: var(--danger); }

/* ===== FLOATING CHAT WIDGET ===== */
.chat-widget-container {
    position: fixed; bottom: 30px; right: 30px; z-index: 9000;
    font-family: 'Inter', sans-serif;
}
.chat-trigger {
    width: 60px; height: 60px; background: var(--primary); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); cursor: pointer; transition: transform 0.2s;
    font-size: 1.5rem;
}
.chat-trigger:hover { transform: scale(1.1); }
.chat-trigger .unread-badge {
    position: absolute; top: 0; right: 0; background: var(--danger);
    width: 20px; height: 20px; border-radius: 50%; font-size: 0.7rem;
    display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

.chat-box {
    position: absolute; bottom: 80px; right: 0;
    width: 380px; height: 550px; background: #fff;
    border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none; flex-direction: column; overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-box.show { display: flex; }

.chat-box-header {
    background: var(--primary); color: #fff; padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.chat-box-header h3 { font-size: 1rem; font-weight: 500; }
.header-actions { display: flex; gap: 12px; font-size: 0.9rem; cursor: pointer; }

.chat-box-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #f8fafc; }
.chat-box-list { flex: 1; overflow-y: auto; }
.chat-box-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.chat-box-input {
    padding: 12px 16px; background: #fff; border-top: 1px solid var(--border);
    display: flex; gap: 8px; align-items: center;
}
.chat-box-input input {
    flex: 1; border: 1px solid #e2e8f0; border-radius: 20px;
    padding: 8px 16px; outline: none; font-size: 0.9rem; background: #f1f5f9;
}
.chat-box-input button {
    background: var(--primary); color: #fff; border: none; width: 34px; height: 34px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer;
}

@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
/* ===== PREMIUM CHAT SYSTEM ===== */
.chat-messages, .chat-box-messages { 
    background: #f1f5f9 !important; 
    padding: 24px !important;
}

.msg-row { 
    display: flex; 
    gap: 12px; 
    max-width: 85%; 
    margin-bottom: 8px;
    animation: bubbleFade .3s ease;
}
.msg-row.sent { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.received { align-self: flex-start; }

.msg-avatar { 
    width: 36px; height: 36px; border-radius: 12px; 
    background: #cbd5e1; display: flex; align-items: center; justify-content: center; 
    font-size: 0.8rem; font-weight: 600; color: #fff; flex-shrink: 0; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.ai-msg-avatar { background: #0f172a; border: 2px solid #6366f1; }

.msg-content { display: flex; flex-direction: column; max-width: 100%; }
.sent .msg-content { align-items: flex-end; }

.msg-bubble { 
    padding: 12px 18px; border-radius: 18px; font-size: 0.95rem; 
    line-height: 1.5; position: relative; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    border: 1px solid transparent; 
    transition: transform 0.2s;
}
.sent .msg-bubble { 
    background: linear-gradient(135deg, #0046ad, #0062f5); 
    color: #fff; border-bottom-right-radius: 4px; 
}
.received .msg-bubble { 
    background: #fff; color: #1e293b; 
    border-bottom-left-radius: 4px; border-color: #e2e8f0; 
}

.ai-bubble { 
    border: 2px solid rgba(99, 102, 241, 0.4) !important; 
    background: #fdf2ff !important; 
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15) !important; 
}

.msg-sender-name { 
    font-size: 0.7rem; font-weight: 600; color: #64748b; 
    margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}
.sent .msg-sender-name { margin-right: 4px; }
.received .msg-sender-name { margin-left: 4px; }

.msg-meta { 
    font-size: 0.65rem; margin-top: 5px; display: flex; 
    gap: 6px; opacity: 0.7; align-items: center; 
}
.sent .msg-meta { color: rgba(255,255,255,0.9); }

@keyframes bubbleFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Fix widget specific bubble width */
.chat-box-messages .msg-row { max-width: 95% !important; }
.chat-box-messages .msg-bubble { font-size: 0.85rem !important; padding: 10px 14px !important; }

/* ===== PREMIUM INBOX LIST ===== */
.chat-item {
    display: flex; gap: 16px; padding: 18px 24px;
    cursor: pointer; border-bottom: 1px solid var(--border);
    transition: all 0.2s ease; position: relative;
}
.chat-item:hover { background: #f8fafc; }
.chat-item.active { 
    background: #eff6ff; 
    border-left: 4px solid var(--primary);
}

.chat-avatar {
    width: 48px; height: 48px; border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 1rem; flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}
.chat-avatar.ai-avatar {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border: 2px solid #6366f1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

.chat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.chat-info-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.chat-name { font-weight: 600; font-size: 0.95rem; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 0.7rem; color: #94a3b8; font-weight: 500; }
.chat-last-msg { font-size: 0.8rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Responsive adjustments for widget */
.chat-box-list .chat-item { padding: 12px 16px; }
.chat-box-list .chat-avatar { width: 40px; height: 40px; font-size: 0.9rem; }

/* Chat Delete Button */
.chat-delete-btn {
    opacity: 0; transition: opacity 0.2s; cursor: pointer;
    color: #94a3b8; font-size: 0.8rem; padding: 8px;
    border-radius: 8px; flex-shrink: 0; display: flex;
    align-items: center; justify-content: center;
}
.chat-delete-btn:hover { color: #ef4444; background: #fef2f2; }
.chat-item:hover .chat-delete-btn { opacity: 1; }

/* Premium Call Tracker Table Styles */
.call-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

.th-time, .td-time {
    width: 130px;
}

.th-caller, .td-caller {
    width: 280px;
}

.th-ext, .td-ext {
    width: 130px;
}

/* Beautiful block formatting for time-stamp */
.time-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.time-block .time {
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
}

.time-block .date {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

/* Elegant and polished Extension badges */
.ext-badge {
    background: linear-gradient(135deg, #e0e7ff, #e0f2fe);
    color: #4f46e5;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #c7d2fe;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.05);
    transition: all 0.2s ease;
}

.ext-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.1);
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
}


/* ===== DARK MODE THEME ===== */
/* Activated when html.dark class is present (set by theme toggle in layout.html) */
html.dark {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --border: #334155;
    --text: #ffffff;
    --text-secondary: #cbd5e1;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
    --glass: rgba(15, 23, 42, 0.85);
    --primary-light: #1e3a5f;
    --primary: #38bdf8;
}

html.dark body {
    background: var(--bg);
    color: var(--text);
}

/* Dark mode: Cards, inputs, tables */
html.dark .card,
html.dark .perf-card,
html.dark .stat-card,
html.dark .glass-panel {
    background-color: var(--bg-alt) !important;
    background: var(--bg-alt) !important;
    border-color: var(--border) !important;
}

html.dark .input-field, html.dark select.input-field, html.dark textarea.input-field {
    background: #0f172a;
    color: var(--text);
    border-color: var(--border);
}
html.dark .input-field:hover { background: #1e293b; }
html.dark .input-field:focus { background: #0f172a; border-color: var(--primary); }
html.dark td { border-bottom-color: var(--border); color: var(--text); }
html.dark tr:hover td { background: #1e293b; }
html.dark th { color: var(--text-secondary); }
html.dark .modal-content { background: var(--bg-alt); }
html.dark .profile-pill { background: var(--bg-alt); border-color: var(--border); }
html.dark .profile-dropdown { background: var(--bg-alt); border-color: var(--border); }
html.dark .dropdown-item { color: var(--text); }
html.dark .dropdown-item:hover { background: #0f172a; }
html.dark .chat-box { background: var(--bg-alt); }
html.dark .chat-box-body { background: #0f172a; }
html.dark .chat-box-input { background: var(--bg-alt); border-top-color: var(--border); }
html.dark .chat-box-input input { background: #0f172a; border-color: var(--border); color: var(--text); }
html.dark .chat-item:hover { background: #0f172a; }
html.dark .chat-item.active { background: #1e3a5f; }
html.dark .received .msg-bubble { background: #1e293b; color: var(--text); border-color: var(--border); }
html.dark .mobile-bottom-nav { background: rgba(15, 23, 42, 0.95); border-top-color: var(--border); }
html.dark .btn-outline { color: var(--primary); border-color: var(--primary); }
html.dark .btn-outline:hover { background: var(--primary-light); }

/* Dark mode overrides for specific hardcoded page elements */
html.dark .time-block .time { color: var(--text) !important; }
html.dark .time-block .date { color: var(--text-secondary) !important; }
html.dark .chat-name { color: var(--text) !important; }
html.dark .chat-last-msg { color: var(--text-secondary) !important; }
html.dark .pill-muted { background: #334155 !important; color: #cbd5e1 !important; }
html.dark .chat-delete-btn:hover { background: #311b1b !important; }

/* Dark mode overrides for hardcoded inline styles */
html.dark [style*="background: white"],
html.dark [style*="background:white"],
html.dark [style*="background-color: white"],
html.dark [style*="background-color:white"],
html.dark [style*="background: #ffffff"],
html.dark [style*="background:#ffffff"],
html.dark [style*="background-color: #ffffff"],
html.dark [style*="background-color:#ffffff"],
html.dark [style*="background: #fff"],
html.dark [style*="background:#fff"],
html.dark [style*="background-color: #fff"],
html.dark [style*="background-color:#fff"] {
    background-color: var(--bg-alt) !important;
    background: var(--bg-alt) !important;
}

html.dark [style*="background: linear-gradient"],
html.dark [style*="background:linear-gradient"] {
    background: linear-gradient(135deg, #1e293b, #0f172a) !important;
}

html.dark [style*="color: #1e293b"],
html.dark [style*="color:#1e293b"],
html.dark [style*="color: #334155"],
html.dark [style*="color:#334155"],
html.dark [style*="color: #0f172a"],
html.dark [style*="color:#0f172a"],
html.dark [style*="color: #475569"],
html.dark [style*="color:#475569"] {
    color: var(--text) !important;
}

html.dark [style*="color: #64748b"],
html.dark [style*="color:#64748b"],
html.dark [style*="color: #5f6368"],
html.dark [style*="color:#5f6368"] {
    color: var(--text-secondary) !important;
}

html.dark [style*="border-color: #e2e8f0"],
html.dark [style*="border-color:#e2e8f0"],
html.dark [style*="border-color: #cbd5e1"],
html.dark [style*="border-color:#cbd5e1"],
html.dark [style*="border: 1px solid #e2e8f0"],
html.dark [style*="border:1px solid #e2e8f0"],
html.dark [style*="border: 1px solid #cbd5e1"],
html.dark [style*="border:1px solid #cbd5e1"] {
    border-color: var(--border) !important;
}

/* Specific page overrides */
html.dark .incentive-selector-area { background: var(--bg-alt) !important; }
html.dark #incentiveSettingsPanel { background: var(--bg-alt) !important; }
html.dark #incentiveSettingsPanel input[type="text"],
html.dark #incentiveSettingsPanel input[type="number"] {
    background: #0f172a !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
html.dark thead[style*="background: #f8fafc"] th,
html.dark thead[style*="background:#f8fafc"] th { background: var(--bg-alt) !important; }

/* Custom Overrides for Card Headers and Dashboards */
html.dark [style*="background: #f8fafc"],
html.dark [style*="background:#f8fafc"],
html.dark [style*="background-color: #f8fafc"],
html.dark [style*="background-color:#f8fafc"] {
    background-color: var(--bg) !important;
    background: var(--bg) !important;
}

/* Weekly roster shift backgrounds */
html.dark [style*="background: #f1f5f9"],
html.dark [style*="background:#f1f5f9"] {
    background: #1e293b !important;
    background-color: #1e293b !important;
}
html.dark [style*="background: #fdf2f8"],
html.dark [style*="background:#fdf2f8"] {
    background: #311825 !important;
    background-color: #311825 !important;
}

/* Operations & Services Card 1: Packages Done */
html.dark [style*="background: #eff6ff"],
html.dark [style*="background:#eff6ff"] {
    background: rgba(59, 130, 246, 0.1) !important;
    background-color: rgba(59, 130, 246, 0.1) !important;
    border-color: rgba(59, 130, 246, 0.2) !important;
}
html.dark [style*="color: #1e3a8a"],
html.dark [style*="color:#1e3a8a"] {
    color: #93c5fd !important;
}

/* Operations & Services Card 2: Patient Mix */
html.dark [style*="background: #fdf4ff"],
html.dark [style*="background:#fdf4ff"] {
    background: rgba(192, 38, 211, 0.1) !important;
    background-color: rgba(192, 38, 211, 0.1) !important;
    border-color: rgba(192, 38, 211, 0.2) !important;
}
html.dark [style*="color: #a21caf"],
html.dark [style*="color:#a21caf"] {
    color: #f5d0fe !important;
}
html.dark [style*="border-left: 1px solid #f5d0fe"],
html.dark [style*="border-left:1px solid #f5d0fe"] {
    border-left-color: rgba(192, 38, 211, 0.2) !important;
}

/* Operations & Services Card 3: Revenue Split */
html.dark [style*="background: #f0fdf4"],
html.dark [style*="background:#f0fdf4"] {
    background: rgba(22, 163, 74, 0.1) !important;
    background-color: rgba(22, 163, 74, 0.1) !important;
    border-color: rgba(22, 163, 74, 0.2) !important;
}
html.dark [style*="color: #15803d"],
html.dark [style*="color:#15803d"] {
    color: #86efac !important;
}
html.dark [style*="color: #1d4ed8"],
html.dark [style*="color:#1d4ed8"] {
    color: #93c5fd !important;
}

/* Employee of the Month Card 1: Top Doctors */
html.dark [style*="background: #fffbeb"],
html.dark [style*="background:#fffbeb"] {
    background: rgba(245, 158, 11, 0.1) !important;
    background-color: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.2) !important;
}
html.dark [style*="color: #92400e"],
html.dark [style*="color:#92400e"] {
    color: #fde68a !important;
}
html.dark [style*="color: #b45309"],
html.dark [style*="color:#b45309"] {
    color: #fcd34d !important;
}
html.dark [style*="border-bottom: 1px dashed #fde68a"],
html.dark [style*="border-bottom:1px dashed #fde68a"],
html.dark [style*="border-bottom: 1px dashed #fcd34d"],
html.dark [style*="border-bottom:1px dashed #fcd34d"] {
    border-bottom-color: rgba(245, 158, 11, 0.2) !important;
}
html.dark [style*="border-left: 1px solid #fde68a"],
html.dark [style*="border-left:1px solid #fde68a"] {
    border-left-color: rgba(245, 158, 11, 0.2) !important;
}

/* Employee of the Month Card 2: Top Reception */
html.dark [style*="background: #ecfdf5"],
html.dark [style*="background:#ecfdf5"] {
    background: rgba(16, 185, 129, 0.1) !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.2) !important;
}
html.dark [style*="color: #065f46"],
html.dark [style*="color:#065f46"] {
    color: #a7f3d0 !important;
}
html.dark [style*="color: #047857"],
html.dark [style*="color:#047857"] {
    color: #6ee7b7 !important;
}
html.dark [style*="border-bottom: 1px dashed #a7f3d0"],
html.dark [style*="border-bottom:1px dashed #a7f3d0"],
html.dark [style*="border-bottom: 1px dashed #6ee7b7"],
html.dark [style*="border-bottom:1px dashed #6ee7b7"] {
    border-bottom-color: rgba(16, 185, 129, 0.2) !important;
}
html.dark [style*="border-left: 1px solid #a7f3d0"],
html.dark [style*="border-left:1px solid #a7f3d0"] {
    border-left-color: rgba(16, 185, 129, 0.2) !important;
}

/* Employee of the Month Card 3: Top Nurse */
html.dark [style*="background: #f0f9ff"],
html.dark [style*="background:#f0f9ff"] {
    background: rgba(2, 132, 199, 0.1) !important;
    background-color: rgba(2, 132, 199, 0.1) !important;
    border-color: rgba(2, 132, 199, 0.2) !important;
}
html.dark [style*="color: #075985"],
html.dark [style*="color:#075985"] {
    color: #bae6fd !important;
}
html.dark [style*="color: #0369a1"],
html.dark [style*="color:#0369a1"] {
    color: #7dd3fc !important;
}
html.dark [style*="border-bottom: 1px dashed #bae6fd"],
html.dark [style*="border-bottom:1px dashed #bae6fd"],
html.dark [style*="border-bottom: 1px dashed #7dd3fc"],
html.dark [style*="border-bottom:1px dashed #7dd3fc"] {
    border-bottom-color: rgba(2, 132, 199, 0.2) !important;
}
html.dark [style*="border-left: 1px solid #bae6fd"],
html.dark [style*="border-left:1px solid #bae6fd"] {
    border-left-color: rgba(2, 132, 199, 0.2) !important;
}

/* Employee of the Month Card 4: Top Lab Tech */
html.dark [style*="background: #faf5ff"],
html.dark [style*="background:#faf5ff"] {
    background: rgba(147, 51, 234, 0.1) !important;
    background-color: rgba(147, 51, 234, 0.1) !important;
    border-color: rgba(147, 51, 234, 0.2) !important;
}
html.dark [style*="color: #701a75"],
html.dark [style*="color:#701a75"] {
    color: #f5d0fe !important;
}
html.dark [style*="color: #581c87"],
html.dark [style*="color:#581c87"] {
    color: #e9d5ff !important;
}
html.dark [style*="color: #6b21a8"],
html.dark [style*="color:#6b21a8"] {
    color: #d8b4fe !important;
}
html.dark [style*="color: #9f1239"],
html.dark [style*="color:#9f1239"] {
    color: #fecdd3 !important;
}
html.dark [style*="color: #be123c"],
html.dark [style*="color:#be123c"] {
    color: #fda4af !important;
}
html.dark [style*="border-bottom: 1px dashed #e9d5ff"],
html.dark [style*="border-bottom:1px dashed #e9d5ff"],
html.dark [style*="border-bottom: 1px dashed #fecdd3"],
html.dark [style*="border-bottom:1px dashed #fecdd3"] {
    border-bottom-color: rgba(147, 51, 234, 0.2) !important;
}
html.dark [style*="border-left: 1px solid #e9d5ff"],
html.dark [style*="border-left:1px solid #e9d5ff"] {
    border-left-color: rgba(147, 51, 234, 0.2) !important;
}

/* Flatpickr Dark Mode Overrides */
html.dark .flatpickr-calendar {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5) !important;
}
html.dark .flatpickr-day {
    color: #ffffff !important;
}
html.dark .flatpickr-day:hover,
html.dark .flatpickr-day.prevMonthDay:hover,
html.dark .flatpickr-day.nextMonthDay:hover {
    background: #334155 !important;
}
html.dark .flatpickr-day.selected {
    background: #38bdf8 !important;
    color: #0f172a !important;
}
html.dark .flatpickr-day.today {
    border-color: #38bdf8 !important;
}
html.dark .flatpickr-day.prevMonthDay,
html.dark .flatpickr-day.nextMonthDay,
html.dark .flatpickr-day.flatpickr-disabled {
    color: #64748b !important;
}
html.dark .flatpickr-months .flatpickr-month,
html.dark .flatpickr-current-month,
html.dark .flatpickr-current-month .numInputWrapper span.arrowUp:after,
html.dark .flatpickr-current-month .numInputWrapper span.arrowDown:after {
    color: #ffffff !important;
    fill: #ffffff !important;
}
html.dark .flatpickr-months .flatpickr-prev-month,
html.dark .flatpickr-months .flatpickr-next-month {
    color: #ffffff !important;
    fill: #ffffff !important;
}
html.dark .flatpickr-weekday {
    color: #cbd5e1 !important;
}
html.dark .flatpickr-current-month input.cur-year {
    color: inherit !important;
}

/* Daily Report Modal Dark Mode Overrides */
html.dark #dailyReportModal div[style*="background:#fff"],
html.dark #dailyReportModal div[style*="background: #fff"] {
    background: var(--bg-alt) !important;
    color: var(--text) !important;
}
html.dark #dailyReportModal input {
    background: #0f172a !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
html.dark #dailyReportModal label,
html.dark #dailyReportModal p {
    color: var(--text-secondary) !important;
}
html.dark #dailyReportModal p[style*="color:#1e293b"],
html.dark #dailyReportModal p[style*="color: #1e293b"] {
    color: var(--text) !important;
}
html.dark #dailyReportModal button[style*="background:#f8fafc"],
html.dark #dailyReportModal button[style*="background: #f8fafc"] {
    background: var(--bg) !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

/* Date Pickers, Selects, and Filter Overrides in Dark Mode */
html.dark input[type="date"],
html.dark input[type="time"],
html.dark select,
html.dark #date-filter,
html.dark #status-filter,
html.dark #direction-filter,
html.dark a[href*="/api/calls/export"] {
    background-color: var(--bg-alt) !important;
    background: var(--bg-alt) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
/* Ensure native date/time pickers adopt dark colors */
html.dark input[type="date"],
html.dark input[type="time"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}
html.dark input[type="date"]::-webkit-calendar-picker-indicator,
html.dark input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Utility Class for Dark Inputs */
.bg-dark-input {
    background-color: var(--bg-alt) !important;
    background: var(--bg-alt) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Ensure flatpickr calendar input and parents inherit dark theme */
html.dark input.flatpickr-input,
html.dark #perfDateSelector,
html.dark #techDateSelector {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--text) !important;
}
html.dark div:has(> #perfDateSelector),
html.dark div:has(> #techDateSelector) {
    background: var(--bg-alt) !important;
    background-color: var(--bg-alt) !important;
    border-color: var(--border) !important;
}



