/* ============================================================
   InsureTrack CRM - Main Stylesheet
   Premium SaaS Dashboard Design
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-subtle: #eff6ff;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: var(--primary);
    --navbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-bs-theme="dark"] {
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --sidebar-bg: #020617;
    --light: #1e293b;
    --white: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 4px 16px rgba(0,0,0,0.2);
}

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

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    overflow-x: hidden;
}

/* ============================================================
   PAGE LOADER
   ============================================================ */
.page-loader {
    position: fixed; inset: 0; z-index: 99999;
    background: var(--white);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.4s, visibility 0.4s;
}
.page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
    height: var(--navbar-height);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.15rem;
}
.brand-text {
    font-size: 1.15rem; font-weight: 700; color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section { padding: 8px 0; }
.nav-section-title {
    font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); padding: 8px 24px 6px;
    letter-spacing: 1px;
}

.nav-link-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px; color: var(--sidebar-text);
    text-decoration: none; font-size: 0.84rem; font-weight: 500;
    transition: var(--transition); position: relative;
    margin: 2px 12px; border-radius: var(--radius-sm);
}
.nav-link-item:hover {
    color: #fff; background: rgba(255,255,255,0.06);
}
.nav-link-item.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.nav-link-item i { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 8px;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 1039;
    backdrop-filter: blur(4px);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-wrapper { display: flex; min-height: 100vh; }
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    height: var(--navbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 1030;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

.search-box {
    position: relative; width: 360px;
}
.search-box i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.9rem;
}
.search-box input {
    width: 100%; padding: 9px 16px 9px 40px;
    border: 1px solid var(--border-color);
    border-radius: 50px; font-size: 0.84rem;
    background: var(--body-bg); color: var(--text-primary);
    transition: var(--transition);
}
.search-box input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: var(--card-bg);
}
.search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    display: none; overflow: hidden; z-index: 100; max-height: 400px; overflow-y: auto;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 10px 16px; display: flex; align-items: center; gap: 12px;
    cursor: pointer; transition: var(--transition); text-decoration: none;
    color: var(--text-primary); border-bottom: 1px solid var(--border-color);
}
.search-result-item:hover { background: var(--primary-subtle); }
.search-result-item:last-child { border-bottom: none; }

.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
}
.user-avatar-sm { width: 30px; height: 30px; font-size: 0.7rem; }
.user-menu-btn {
    background: none; border: 1px solid var(--border-color);
    border-radius: 50px; padding: 4px 12px 4px 4px;
    transition: var(--transition);
}
.user-menu-btn:hover { background: var(--body-bg); border-color: var(--primary); }

.notification-badge { font-size: 0.6rem; }
.notification-dropdown { border-radius: var(--radius) !important; box-shadow: var(--shadow-lg) !important; }
.notif-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; transition: var(--transition);
}
.notif-item:hover { background: var(--primary-subtle); }
.notif-item.unread { background: var(--primary-subtle); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px; }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
    font-size: 1.5rem; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.5px;
}
.page-subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-top: 2px; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    background: transparent; border-bottom: 1px solid var(--border-color);
    padding: 16px 20px; font-weight: 600;
}

/* Stat Cards */
.stat-card {
    padding: 20px; border-radius: var(--radius);
    background: var(--card-bg); border: 1px solid var(--border-color);
    transition: var(--transition); position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -1px; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }
.stat-card .stat-change { font-size: 0.72rem; font-weight: 600; }
.stat-card::after {
    content: ''; position: absolute; top: -50px; right: -50px;
    width: 120px; height: 120px; border-radius: 50%;
    opacity: 0.05;
}
.stat-card.primary .stat-icon { background: #eff6ff; color: var(--primary); }
.stat-card.primary::after { background: var(--primary); }
.stat-card.success .stat-icon { background: #ecfdf5; color: var(--success); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger .stat-icon { background: #fef2f2; color: var(--danger); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.info .stat-icon { background: #ecfeff; color: var(--info); }
.stat-card.info::after { background: var(--info); }

/* ============================================================
   TABLES
   ============================================================ */
.table-card { overflow: hidden; }
.table-card .card-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.table { margin-bottom: 0; color: var(--text-primary); }
.table thead th {
    background: var(--body-bg); font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary); border-bottom: 2px solid var(--border-color);
    padding: 12px 16px; white-space: nowrap;
}
.table tbody td {
    padding: 14px 16px; vertical-align: middle;
    border-bottom: 1px solid var(--border-color); font-size: 0.84rem;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--primary-subtle); }
.table tbody tr:last-child td { border-bottom: none; }

.table-actions .btn { padding: 4px 8px; font-size: 0.78rem; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    border: none; border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 16px 24px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); padding: 10px 14px;
    font-size: 0.84rem; color: var(--text-primary);
    background: var(--card-bg);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-label { font-weight: 500; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 6px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { font-weight: 500; font-size: 0.84rem; border-radius: var(--radius-sm); padding: 9px 18px; transition: var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-light { background: var(--body-bg); border-color: var(--border-color); color: var(--text-primary); }
.btn-icon { width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-weight: 500; font-size: 0.72rem; padding: 5px 10px; border-radius: 6px; }

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton { background: linear-gradient(90deg, var(--border-color) 25%, var(--body-bg) 50%, var(--border-color) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 6px; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 100px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 20px;
}
.filter-bar .form-control, .filter-bar .form-select { max-width: 200px; padding: 8px 12px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrapper { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border-color); flex-wrap: wrap; gap: 12px; }
.pagination-info { font-size: 0.82rem; color: var(--text-secondary); }
.pagination .page-link { border-radius: 8px; margin: 0 2px; border: 1px solid var(--border-color); color: var(--text-primary); font-size: 0.82rem; padding: 6px 12px; }
.pagination .page-link:hover { background: var(--primary-subtle); border-color: var(--primary); color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper { min-height: 100vh; display: flex; }
.login-left { flex: 1; background: linear-gradient(135deg, #1e3a8a 0%, #7c3aed 100%); display: flex; align-items: center; justify-content: center; padding: 40px; position: relative; overflow: hidden; }
.login-left::before { content: ''; position: absolute; width: 400px; height: 400px; background: rgba(255,255,255,0.05); border-radius: 50%; top: -100px; right: -100px; }
.login-left::after { content: ''; position: absolute; width: 300px; height: 300px; background: rgba(255,255,255,0.03); border-radius: 50%; bottom: -80px; left: -80px; }
.login-left-content { position: relative; z-index: 1; color: #fff; max-width: 480px; }
.login-left-content h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.login-left-content p { font-size: 1.1rem; opacity: 0.85; line-height: 1.6; }
.login-right { width: 520px; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--card-bg); }
.login-form { width: 100%; max-width: 400px; }
.login-form h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.login-form p { color: var(--text-secondary); margin-bottom: 32px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
}
@media (max-width: 767.98px) {
    .page-content { padding: 16px; }
    .login-left { display: none; }
    .login-right { width: 100%; }
    .search-box { width: 200px; }
    .stat-card .stat-value { font-size: 1.4rem; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state i { font-size: 3rem; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h5 { font-weight: 600; color: var(--text-secondary); }
.empty-state p { color: var(--text-muted); font-size: 0.85rem; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container { position: relative; padding: 16px; }

/* Status row highlight */
tr.expiring-soon { background: #fffbeb !important; }
tr.expired-row { background: #fef2f2 !important; }
