/* ==========================================================================
   InsureDesk — front office console
   ========================================================================== */

:root {
    --brand: #2a62d8;
    --brand-600: #1f50b8;
    --brand-50: #eaf1fd;
    --ink: #101828;
    --ink-2: #475467;
    --ink-3: #8a94a6;
    --line: #e6e9f0;
    --surface: #ffffff;
    --plane: #f4f6fb;
    --sidebar: #0d1b3e;
    --sidebar-2: #13265a;
    --sidebar-ink: #b7c3e0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --sidebar-w: 248px;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--plane);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 42, 98, 216;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 42, 98, 216;
    --bs-link-hover-color: var(--brand-600);
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
}

body {
    font-size: .9rem;
    background: var(--plane);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-600);
    --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 1px 2px rgba(42, 98, 216, .25);
}
.btn-light { --bs-btn-bg: #f2f4f8; --bs-btn-border-color: #f2f4f8; --bs-btn-hover-bg: #e6e9f0; --bs-btn-hover-border-color: #e6e9f0; }
.btn-icon {
    width: 34px; height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; color: var(--ink-2); background: transparent; border: 0;
}
.btn-icon:hover { background: #eef1f6; color: var(--ink); }
.btn-icon.danger:hover { background: #fdecec; color: #c4302b; }
.btn-icon .bi { font-size: 1.05rem; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--sidebar-ink);
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform .25s ease;
}
.brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    color: #fff; text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4f8bff, #2a62d8);
    color: #fff; font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(42, 98, 216, .45);
}
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; }
.brand-text { font-weight: 700; font-size: 1.1rem; line-height: 1.1; display: flex; flex-direction: column; }
.brand-text small { font-weight: 500; font-size: .72rem; color: var(--sidebar-ink); letter-spacing: .04em; text-transform: uppercase; }

.side-nav { padding: .5rem .75rem; flex: 1; overflow-y: auto; }
.nav-caption { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6f7fa8; padding: .75rem .75rem .4rem; }
.side-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .8rem; margin-bottom: 2px;
    color: var(--sidebar-ink); text-decoration: none;
    border-radius: 10px; font-weight: 500;
    transition: background .15s, color .15s;
}
.side-link .bi { font-size: 1.1rem; opacity: .85; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active {
    background: rgba(79, 139, 255, .18);
    color: #fff;
    box-shadow: inset 3px 0 0 #6fa0ff;
}
.sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.quick-actions { display: flex; gap: .5rem; }
.quick-btn {
    flex: 1; height: 40px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .06); color: #dbe4ff; text-decoration: none;
    transition: background .15s;
}
.quick-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 1rem;
    padding: .9rem 1.75rem;
    background: rgba(244, 246, 251, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.3rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.topbar-title p { margin: 0; color: var(--ink-3); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.today { color: var(--ink-2); font-size: .82rem; }
.user-chip {
    display: flex; align-items: center; gap: .6rem;
    border: 1px solid var(--line); background: var(--surface);
    border-radius: 999px; padding: .25rem .75rem .25rem .25rem;
    color: var(--ink);
}
.user-chip strong { font-size: .82rem; font-weight: 600; line-height: 1.1; }
.user-chip small { font-size: .7rem; color: var(--ink-3); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: .78rem;
    flex-shrink: 0;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }

.content { padding: 1.5rem 1.75rem; flex: 1; }
.app-footer {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.75rem; font-size: .78rem; color: var(--ink-3);
    border-top: 1px solid var(--line);
}

/* ---------- Cards / panels ---------- */
.card.panel { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.panel-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    padding: 1.1rem 1.25rem .5rem;
}
.panel-head h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-head p { margin: 2px 0 0; color: var(--ink-3); font-size: .8rem; }
.panel-body { padding: .5rem 1.25rem 1.25rem; }

/* KPI tiles */
.kpi-card {
    display: flex; gap: 1rem; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow); height: 100%;
}
.kpi-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.tone-blue   { background: #e8f0fd; color: #2a62d8; }
.tone-teal   { background: #e3f6f0; color: #0f8a62; }
.tone-violet { background: #eeebfc; color: #5b49d0; }
.tone-orange { background: #fdeee6; color: #c9531f; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: .78rem; color: var(--ink-2); font-weight: 500; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-meta { font-size: .76rem; color: var(--ink-3); }
.kpi-meta a { text-decoration: none; font-weight: 500; }

.stat-pill {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .75rem 1rem; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.stat-pill span { font-size: .75rem; color: var(--ink-3); font-weight: 500; }
.stat-pill strong { font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Charts */
.chart-box { position: relative; height: 260px; }
.chart-box.chart-lg { height: 300px; }

/* ---------- Toolbar & tables ---------- */
.toolbar {
    display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.toolbar-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar-filters .form-select { width: auto; min-width: 150px; }
.toolbar-actions { display: flex; gap: .5rem; }
.date-range { width: auto; }
.date-range .form-control { max-width: 145px; }
.filter-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--brand-50); color: var(--brand); border-radius: 999px;
    padding: .25rem .4rem .25rem .75rem; font-size: .78rem; font-weight: 500;
}
.filter-chip button { border: 0; background: transparent; color: inherit; padding: 0 .25rem; line-height: 1; }

.table-wrap { padding: .5rem 1.25rem 1rem; }
.table { --bs-table-hover-bg: #f7f9fd; margin-bottom: 0; }
.table > thead th {
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--ink-3); background: #f8fafc !important; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { border-color: #eef1f5; }
.table .num { font-variant-numeric: tabular-nums; }
.id-link { font-weight: 600; text-decoration: none; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .82rem; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: .75rem; color: var(--ink-3); display: block; }
.count-pill {
    display: inline-flex; min-width: 26px; height: 22px; padding: 0 .45rem;
    align-items: center; justify-content: center;
    border-radius: 999px; background: #eef1f6; color: var(--ink-2); font-size: .75rem; font-weight: 600;
}
.row-actions { display: inline-flex; gap: 2px; white-space: nowrap; }

.mini-table th:first-child, .mini-table td:first-child { padding-left: 1.25rem; }
.mini-table th:last-child, .mini-table td:last-child { padding-right: 1.25rem; }

/* DataTables polish */
div.dt-container .dt-search input { border-radius: var(--radius-sm); min-width: 240px; padding-left: 2rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238a94a6' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat .7rem center; }
div.dt-container .dt-length select { border-radius: var(--radius-sm); }
div.dt-container .dt-info { color: var(--ink-3); font-size: .8rem; }
div.dt-container .pagination { --bs-pagination-border-radius: 8px; --bs-pagination-font-size: .82rem; gap: 4px; }
div.dt-container .page-link { border-radius: 8px !important; border: 1px solid var(--line); color: var(--ink-2); }
div.dt-container .page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
div.dt-container div.dt-layout-row { margin: .6rem 0; }
div.dt-processing > div:last-child > div { background: var(--brand); }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before { background-color: var(--brand); }
table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details > li { display: flex; gap: 1rem; justify-content: space-between; }

/* ---------- Status badges ---------- */
.status {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .6rem; border-radius: 999px;
    font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.s-good    { background: #e6f6ec; color: #0b7a35; }
.status.s-warn    { background: #fff4dc; color: #8a5a00; }
.status.s-info    { background: #e8f0fd; color: #2456c0; }
.status.s-bad     { background: #fdecec; color: #b42318; }
.status.s-muted   { background: #eef1f5; color: #5b6576; }

/* ---------- Forms & modals ---------- */
.modal-content { border: 0; border-radius: 18px; box-shadow: 0 20px 60px rgba(16, 24, 40, .2); }
.modal-header { border-bottom: 1px solid var(--line); padding: 1rem 1.5rem; }
.modal-header .modal-title { font-weight: 600; font-size: 1.05rem; }
.modal-body { padding: 1.25rem 1.5rem 1.5rem; }
.modal-footer { border-top: 1px solid var(--line); padding: .85rem 1.5rem; }
.form-section {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--ink-3); margin: 1.4rem 0 .75rem; display: flex; align-items: center; gap: .75rem;
}
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.modal-body > .form-section:first-of-type { margin-top: 0; }
.form-label { font-weight: 500; font-size: .82rem; color: var(--ink-2); margin-bottom: .3rem; }
.form-label.req::after { content: " *"; color: #d0392b; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #d9dee8; font-size: .88rem; }
.form-control:focus, .form-select:focus { border-color: #8db0f2; box-shadow: 0 0 0 .2rem rgba(42, 98, 216, .15); }
.form-control[readonly] { background: #f6f8fb; }
.input-group-text { background: #f6f8fb; border-color: #d9dee8; color: var(--ink-3); }

/* Select2 alignment with Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection { border-radius: var(--radius-sm); border-color: #d9dee8; min-height: 38px; font-size: .88rem; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection { border-color: #8db0f2; box-shadow: 0 0 0 .2rem rgba(42, 98, 216, .15); }
.is-invalid + .select2-container--bootstrap-5 .select2-selection { border-color: var(--bs-form-invalid-border-color); }
.is-invalid + .select2-container + .invalid-feedback { display: block; }
.s2-option { display: flex; flex-direction: column; line-height: 1.25; }
.s2-option small { color: var(--ink-3); }
.select2-results__option--highlighted .s2-option small { color: rgba(255, 255, 255, .8); }

/* Policy summary card (claims form) */
.policy-card {
    height: 100%; min-height: 220px;
    border-radius: var(--radius); border: 1px dashed #cdd5e3; background: #fafbfd;
    padding: 1.25rem;
}
.policy-card.filled { border-style: solid; border-color: var(--line); background: linear-gradient(160deg, #f5f8ff 0%, #ffffff 60%); }
.policy-card-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--ink-3); }
.policy-card-empty .bi { font-size: 2rem; margin-bottom: .5rem; }
.policy-card h6 { font-weight: 700; margin-bottom: .1rem; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; margin-top: 1rem; }
.kv div span { display: block; font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kv div strong { font-weight: 600; font-size: .9rem; }
.limit-bar { height: 8px; border-radius: 999px; background: #e9edf4; overflow: hidden; margin-top: .35rem; }
.limit-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .2s; }
.limit-bar.over > span { background: #d03b3b; }

/* Customer profile offcanvas */
.profile-canvas { --bs-offcanvas-width: 560px; }
.profile-canvas .offcanvas-header { border-bottom: 1px solid var(--line); }
.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.profile-stats > div { background: #f6f8fb; border-radius: var(--radius-sm); padding: .7rem .9rem; }
.profile-stats span { display: block; font-size: .72rem; color: var(--ink-3); }
.profile-stats strong { font-size: 1.05rem; }
.profile-list { list-style: none; padding: 0; margin: 0; }
.profile-list li {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    padding: .75rem 0; border-bottom: 1px solid #eef1f5;
}
.profile-list li:last-child { border-bottom: 0; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; font-size: .85rem; margin-bottom: 1.25rem; }
.contact-grid span { display: block; font-size: .72rem; color: var(--ink-3); }
.nav-tabs-clean { border-bottom: 1px solid var(--line); gap: 1rem; }
.nav-tabs-clean .nav-link { border: 0; color: var(--ink-3); font-weight: 500; padding: .5rem 0; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs-clean .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }

.empty-state { text-align: center; color: var(--ink-3); padding: 2rem 1rem; }
.empty-state .bi { font-size: 1.75rem; display: block; margin-bottom: .4rem; }

/* SweetAlert2 */
.swal2-popup { border-radius: 18px !important; font-family: var(--bs-body-font-family); }
.swal2-styled.swal2-confirm { border-radius: 10px !important; }
.swal2-styled.swal2-cancel { border-radius: 10px !important; }

/* ---------- Auth ---------- */
.auth-body { background: var(--plane); }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-hero {
    flex: 1; align-items: center; justify-content: center; padding: 3rem;
    color: #fff;
    background:
        radial-gradient(1200px 500px at -10% -10%, rgba(79, 139, 255, .35), transparent 60%),
        radial-gradient(800px 400px at 110% 110%, rgba(20, 184, 166, .25), transparent 60%),
        linear-gradient(160deg, #0d1b3e 0%, #13265a 100%);
}
.auth-hero > div { max-width: 460px; }
.auth-hero h1 { font-weight: 700; font-size: 2.4rem; margin: 1.25rem 0 .5rem; letter-spacing: -.02em; }
.auth-hero p { color: #c4cfe9; font-size: 1.05rem; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-points li { display: flex; gap: .75rem; align-items: center; padding: .55rem 0; color: #dbe4ff; }
.auth-points .bi { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .08); display: inline-flex; align-items: center; justify-content: center; }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); padding: 2.25rem; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h2 { font-weight: 700; font-size: 1.5rem; margin-bottom: .25rem; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(13, 27, 62, .45); z-index: 1035; }
    .main { margin-left: 0; }
    .topbar { padding: .75rem 1rem; }
    .content { padding: 1rem; }
    .app-footer { padding: 1rem; }
}
@media (max-width: 767.98px) {
    .toolbar { padding: .85rem 1rem; }
    .toolbar-filters { width: 100%; }
    .toolbar-filters .form-select { flex: 1 1 140px; min-width: 0; }
    .date-range { width: 100%; }
    .date-range .form-control { max-width: none; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .btn { flex: 1; }
    .table-wrap { padding: .25rem .75rem .75rem; }
    div.dt-container .dt-search input { min-width: 0; width: 100%; }
    div.dt-container .dt-search { width: 100%; }
    div.dt-container .dt-search label { display: none; }
    .kpi-card { padding: .9rem; gap: .75rem; flex-direction: column; }
    .kpi-icon { width: 38px; height: 38px; font-size: 1.1rem; }
    .kpi-value { font-size: 1.25rem; }
    .chart-box, .chart-box.chart-lg { height: 230px; }
    .topbar-title h1 { font-size: 1.1rem; }
    .contact-grid, .kv { grid-template-columns: 1fr; }
}
