/* ==========================================================================
   Relite Insurance — Ultra-Premium SaaS Design System & Tokens
   Inspired by Apple, Stripe, Linear, Vercel, and Figma Design Languages
   ========================================================================== */

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

:root {
    /* Color Palette */
    --ri-primary:           #4f46e5;
    --ri-primary-light:     #6366f1;
    --ri-primary-dark:      #3730a3;
    --ri-primary-gradient:  linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --ri-accent:           #06b6d4;
    --ri-accent-gradient:   linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    --ri-success:          #10b981;
    --ri-success-light:    #ecfdf5;
    --ri-warning:          #f59e0b;
    --ri-warning-light:    #fffbeb;
    --ri-danger:           #ef4444;
    --ri-danger-light:     #fef2f2;
    --ri-info:             #3b82f6;
    
    /* Neutrals & Surfaces */
    --ri-body-bg:          #f6f8fd;
    --ri-card-bg:          #ffffff;
    --ri-card-border:      rgba(226, 232, 240, 0.85);
    --ri-text-main:        #0f172a;
    --ri-text-muted:       #64748b;
    --ri-text-subtle:      #94a3b8;

    /* Sidebar Obsidian Theme */
    --ri-sidebar-bg:       #0f172a;
    --ri-sidebar-border:   rgba(255, 255, 255, 0.08);
    --ri-sidebar-text:     #94a3b8;
    --ri-sidebar-hover:    rgba(255, 255, 255, 0.06);
    --ri-sidebar-active:   linear-gradient(90deg, rgba(99, 102, 241, 0.25) 0%, rgba(99, 102, 241, 0.05) 100%);

    /* Topbar Glass */
    --ri-topbar-bg:        rgba(255, 255, 255, 0.82);
    --ri-topbar-border:    rgba(226, 232, 240, 0.7);

    /* Spacing & Radii */
    --ri-radius-sm:        6px;
    --ri-radius-md:        10px;
    --ri-radius-lg:        16px;
    --ri-radius-xl:        24px;
    --ri-radius-full:      9999px;

    /* Shadows & Depth */
    --ri-shadow-sm:        0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --ri-shadow-md:        0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    --ri-shadow-lg:        0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --ri-shadow-glow:      0 0 25px -5px rgba(99, 102, 241, 0.28);

    /* Transitions & Blur */
    --ri-transition:       all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    --ri-blur:             blur(16px);
}

/* Base resets & typography */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--ri-body-bg);
    color: var(--ri-text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ri-text-main);
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.6); }

/* ==========================================================================
   Navigation & Sidebar Architecture
   ========================================================================== */

#ri-sidebar {
    width: 260px;
    height: 100vh;
    background: var(--ri-sidebar-bg);
    border-right: 1px solid var(--ri-sidebar-border);
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

#ri-sidebar.collapsed {
    width: 72px;
}

.sidebar-brand {
    padding: 20px 18px;
    border-bottom: 1px solid var(--ri-sidebar-border);
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    background: var(--ri-primary-gradient);
    border-radius: var(--ri-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ri-shadow-glow);
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

#ri-sidebar.collapsed .brand-text,
#ri-sidebar.collapsed .nav-section,
#ri-sidebar.collapsed .nav-link .link-text,
#ri-sidebar.collapsed .nav-link .badge {
    display: none !important;
}

.nav-section {
    padding: 14px 18px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.6);
}

#ri-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--ri-sidebar-text);
    border-radius: var(--ri-radius-md);
    margin: 2px 12px;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--ri-transition);
    position: relative;
}

#ri-sidebar .nav-link i {
    font-size: 17px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    transition: transform 0.2s ease;
}

#ri-sidebar .nav-link:hover {
    background: var(--ri-sidebar-hover);
    color: #ffffff;
    transform: translateX(2px);
}

#ri-sidebar .nav-link:hover i {
    transform: scale(1.15);
    color: var(--ri-primary-light);
}

#ri-sidebar .nav-link.active {
    background: var(--ri-sidebar-active);
    color: #ffffff;
    font-weight: 600;
    border-left: 3px solid var(--ri-primary-light);
}

#ri-sidebar .nav-link.active i {
    color: var(--ri-primary-light);
}

/* Topbar Header */
#ri-topbar {
    height: 64px;
    background: var(--ri-topbar-bg);
    backdrop-filter: var(--ri-blur);
    -webkit-backdrop-filter: var(--ri-blur);
    border-bottom: 1px solid var(--ri-topbar-border);
    box-shadow: var(--ri-shadow-sm);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1030;
}

#ri-topbar .breadcrumb {
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
}

#ri-topbar .breadcrumb-item + .breadcrumb-item::before {
    color: var(--ri-text-subtle);
    content: "›";
    font-size: 14px;
}

#ri-topbar .breadcrumb-item a {
    color: var(--ri-text-muted);
    text-decoration: none;
    transition: var(--ri-transition);
}

#ri-topbar .breadcrumb-item a:hover {
    color: var(--ri-primary);
}

#ri-topbar .breadcrumb-item.active {
    color: var(--ri-text-main);
    font-weight: 600;
}

/* ==========================================================================
   Cards, Panels & Glass Containers
   ========================================================================== */

.card, .dash-panel, .kpi-card, .chart-card {
    background: var(--ri-card-bg);
    border: 1px solid var(--ri-card-border);
    border-radius: var(--ri-radius-lg);
    box-shadow: var(--ri-shadow-md);
    transition: var(--ri-transition);
}

.card:hover, .dash-panel:hover {
    box-shadow: var(--ri-shadow-lg);
}

.card-header, .dash-panel-head {
    background: transparent;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    padding: 16px 20px;
    font-weight: 700;
    color: var(--ri-text-main);
}

/* The body half of the panel. `.dash-panel-head` was aliased onto `.card-header`
   above, but `.dash-panel-body` was never given a rule to match `.card-body` — so
   every panel built with it rendered its contents hard against the panel edge.
   302 views use this class. */
.dash-panel-body {
    padding: 20px;
}

/* `.dash-panel-body p-0` is the deliberate opt-out used by panels holding a
   full-bleed table; Bootstrap's utility has to win over the rule above. */
.dash-panel-body.p-0 {
    padding: 0 !important;
}

/* The page gutter. <main> is a bare flex child with no padding of its own, so
   `.page-content` is what holds content away from the sidebar and the window edge
   — and it had no rule either, which is why pages sat flush against the nav.
   381 views use this class. */
.page-content {
    padding: 24px 28px;
}

/* Grouped form sections. Used by the employee and dealer forms; lived in one view's
   <style> block until the second screen needed it, which is the point at which
   copying it would have started two copies drifting apart. */
.form-section {
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid #eceef1;
}

.form-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 0;
}

.form-section-title {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 11px;
    color: #8a8f98;
    margin-bottom: 14px;
}

/* A readable measure: without it, inputs stretch the full width of a wide monitor
   and the eye loses the label they belong to. */
.employee-form,
.dealer-form {
    max-width: 960px;
}

.employee-form .form-label,
.dealer-form .form-label {
    font-size: 13px;
    margin-bottom: 4px;
    color: #4a4f57;
}

@media (max-width: 767.98px) {
    .page-content { padding: 16px; }
    .dash-panel-body { padding: 16px; }
}

.glass-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: var(--ri-blur);
    -webkit-backdrop-filter: var(--ri-blur);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--ri-shadow-lg);
    border-radius: var(--ri-radius-xl);
}

/* Hero Section */
.dash-hero {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    color: #ffffff;
    border-radius: var(--ri-radius-xl);
    padding: 28px 32px;
    margin-bottom: 24px;
    box-shadow: 0 12px 32px -8px rgba(49, 46, 129, 0.4);
    position: relative;
    overflow: hidden;
}

.dash-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.dash-hero h4 {
    color: #ffffff;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.dash-hero .role-pill, .dash-hero .scope-pill, .role-pill, .scope-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--ri-radius-full);
}

.dash-hero .role-pill {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    backdrop-filter: blur(4px);
}

.scope-pill {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

/* KPI Grid & Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ri-shadow-lg);
}

.kpi-card.kpi-accent {
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #f5f7ff 0%, #ffffff 100%);
}

.kpi-card .kpi-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--ri-radius-md);
    background: rgba(79, 70, 229, 0.08);
    color: var(--ri-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ri-text-muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--ri-text-main);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.kpi-value.up {
    color: var(--ri-success);
    font-size: 1.4rem;
}

.kpi-value.down {
    color: var(--ri-danger);
    font-size: 1.4rem;
}

/* Sell Insurance Tiles */
.sell-section {
    margin-bottom: 24px;
}

.section-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--ri-text-subtle);
    margin-bottom: 12px;
}

.sell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.sell-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    background: var(--ri-card-bg);
    border: 1px solid var(--ri-card-border);
    border-radius: var(--ri-radius-lg);
    padding: 18px;
    color: var(--ri-text-main);
    transition: var(--ri-transition);
}

.sell-tile:hover {
    border-color: var(--ri-primary-light);
    box-shadow: var(--ri-shadow-glow), var(--ri-shadow-md);
    transform: translateY(-2px);
    color: var(--ri-primary);
}

.sell-tile i {
    font-size: 26px;
    color: var(--ri-primary);
}

.sell-tile .st-title {
    font-weight: 700;
    font-size: 0.92rem;
}

.sell-tile .st-sub {
    font-size: 0.75rem;
    color: var(--ri-text-muted);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: var(--ri-card-bg);
    border: 1px solid var(--ri-card-border);
    border-radius: var(--ri-radius-lg);
    padding: 14px 20px;
    margin-bottom: 24px;
    box-shadow: var(--ri-shadow-sm);
}

.filter-bar .filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ri-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ==========================================================================
   Buttons & Micro-interactions
   ========================================================================== */

.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    border-radius: var(--ri-radius-md);
    padding: 8px 16px;
    font-size: 13.5px;
    transition: var(--ri-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--ri-primary-gradient);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    color: #ffffff;
}

.btn-outline-primary {
    color: var(--ri-primary);
    border-color: #c7d2fe;
    background: rgba(79, 70, 229, 0.02);
}

.btn-outline-primary:hover {
    background: var(--ri-primary);
    color: #ffffff;
    border-color: var(--ri-primary);
}

.btn-outline-secondary {
    color: var(--ri-text-main);
    border-color: var(--ri-card-border);
    background: #ffffff;
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    color: var(--ri-text-main);
    border-color: #cbd5e1;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--ri-radius-sm);
}

/* ==========================================================================
   Forms, Inputs & Floating Labels
   ========================================================================== */

.form-control, .form-select {
    font-size: 13.5px;
    border-radius: var(--ri-radius-md);
    border: 1px solid var(--ri-card-border);
    padding: 9px 14px;
    color: var(--ri-text-main);
    background-color: #ffffff;
    transition: var(--ri-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ri-primary-light);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    outline: none;
}

/* Modern Floating Label Inputs */
.form-floating > .form-control,
.form-floating > .form-select {
    height: 54px;
    padding: 1.25rem 0.9rem 0.4rem;
}

.form-floating > label {
    padding: 0.9rem 0.9rem;
    color: var(--ri-text-muted);
    font-size: 13.5px;
}

/* ==========================================================================
   Data Tables & DevExtreme Grid Overrides
   ========================================================================== */

.table-responsive {
    border-radius: var(--ri-radius-lg);
    border: 1px solid var(--ri-card-border);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    color: var(--ri-text-main);
}

.table thead th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #f8fafc;
    color: var(--ri-text-muted);
    border-bottom: 1px solid var(--ri-card-border);
    padding: 14px 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    font-size: 13.5px;
}

.table tbody tr:hover {
    background-color: #f1f5f9;
}

/* DevExtreme Theme Overrides */
.dx-datagrid {
    font-family: 'Inter', sans-serif !important;
    border-radius: var(--ri-radius-lg) !important;
    border: 1px solid var(--ri-card-border) !important;
    box-shadow: var(--ri-shadow-sm) !important;
}

.dx-datagrid-headers {
    background: #f8fafc !important;
    color: var(--ri-text-muted) !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    border-bottom: 1px solid var(--ri-card-border) !important;
}

.dx-datagrid-rowsview .dx-data-row {
    transition: var(--ri-transition);
}

.dx-datagrid-rowsview .dx-data-row:hover {
    background-color: #f1f5f9 !important;
}

/* ==========================================================================
   Modals, Dialogs & Session Timeout
   ========================================================================== */

.modal-content {
    border-radius: var(--ri-radius-xl);
    border: 1px solid var(--ri-card-border);
    box-shadow: var(--ri-shadow-lg);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    padding: 18px 24px;
    background: #f8fafc;
}

.modal-backdrop.show {
    opacity: 0.6;
    backdrop-filter: var(--ri-blur);
    -webkit-backdrop-filter: var(--ri-blur);
}

#divPopupTimeOut {
    border-radius: var(--ri-radius-lg) !important;
    border: 1px solid #fde68a !important;
    background: rgba(254, 243, 199, 0.95) !important;
    backdrop-filter: var(--ri-blur);
    box-shadow: var(--ri-shadow-lg) !important;
}

/* ==========================================================================
   Toasts & Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 11000;
}

.toast {
    border-radius: var(--ri-radius-md) !important;
    box-shadow: var(--ri-shadow-lg) !important;
    font-weight: 500;
    backdrop-filter: var(--ri-blur);
}

/* ==========================================================================
   Charts Grid & Styling
   ========================================================================== */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.chart-card {
    padding: 20px;
    min-height: 320px;
}

.chart-card.chart-wide {
    grid-column: 1 / -1;
}

.chart-card h6 {
    font-size: 0.95rem;
    color: var(--ri-text-main);
    margin-bottom: 16px;
}

/* ==========================================================================
   Authentication & Error Pages (Luxury Dark / Glass Layout)
   ========================================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b 0%, #0f172a 60%, #020617 100%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
    top: -100px;
    left: -100px;
    border-radius: 50%;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--ri-radius-xl);
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: #ffffff;
}

.auth-card h3 {
    color: #ffffff;
}

.auth-card .form-control {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.auth-card .form-control::placeholder {
    color: #94a3b8;
}

.auth-card .form-control:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--ri-primary-light);
}

.error-page {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-badge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--ri-danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #ri-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        width: 0;
    }
    #ri-sidebar.mobile-open {
        width: 260px;
    }
    .chart-card.chart-wide {
        grid-column: span 1;
    }
}
