:root {
    --avni-primary: #1a237e;
    --avni-secondary: #0d47a1;
    --avni-accent: #ff6f00;
    --avni-dark: #0d1b4a;
    --avni-light: #e8eaf6;
    --avni-bg: #f0f2f5;
    --avni-text: #212529;
    --avni-text-muted: #6c757d;
    --avni-border: #dee2e6;
    --avni-success: #28a745;
    --avni-danger: #dc3545;
    --avni-warning: #ffc107;
    --avni-info: #17a2b8;
    --sidebar-width: 260px;
    --header-height: 60px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--avni-bg);
    overflow-x: hidden;
    color: var(--avni-text);
}

/* Sidebar */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: linear-gradient(180deg, var(--avni-dark) 0%, var(--avni-primary) 50%, var(--avni-secondary) 100%);
    color: #fff; z-index: 1040;
    overflow-y: auto; overflow-x: hidden;
    transition: transform 0.3s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 4px; }
.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-brand img { height: 36px; width: auto; }
.sidebar-brand-text h5 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .5px; color: #fff; }
.sidebar-brand-text small { opacity: .7; font-size: 10px; display: block; color: rgba(255,255,255,.8); }
.sidebar-nav { padding: 8px 0; }
.sidebar-nav .nav-section {
    padding: 12px 20px 4px;
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 1.5px; opacity: .45;
    font-weight: 700; color: rgba(255,255,255,.7);
}
.sidebar-nav a {
    display: flex; align-items: center;
    padding: 9px 20px; padding-left: 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none; font-size: 13px;
    transition: all .15s ease;
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--avni-accent);
}
.sidebar-nav a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: var(--avni-accent);
    font-weight: 600;
}
.sidebar-nav a i {
    width: 20px; margin-right: 10px;
    font-size: 14px; text-align: center;
}
.sidebar-nav a .badge {
    margin-left: auto;
    font-size: 10px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--avni-border);
    position: sticky; top: 0; z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.top-header .page-title {
    font-size: 17px; font-weight: 600;
    color: var(--avni-primary);
}
.user-menu {
    display: flex; align-items: center; gap: 16px;
}
.user-menu .user-info { text-align: right; line-height: 1.3; }
.user-menu .user-name { font-size: 13px; font-weight: 600; color: var(--avni-text); }
.user-menu .user-role { font-size: 11px; color: var(--avni-text-muted); }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--avni-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    cursor: pointer;
}

/* Content Wrapper */
.content-wrapper {
    padding: 20px 24px;
    flex: 1;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    border-radius: 10px;
    margin-bottom: 20px;
    transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--avni-border);
    border-radius: 10px 10px 0 0 !important;
    padding: 14px 20px;
}
.card-header .card-title {
    font-size: 15px; font-weight: 600;
    color: var(--avni-text); margin: 0;
}
.card-body { padding: 20px; }
.card-footer {
    background: #fff;
    border-top: 1px solid var(--avni-border);
    border-radius: 0 0 10px 10px !important;
    padding: 12px 20px;
}

/* Small Box (Dashboard cards) */
.small-box {
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    position: relative; overflow: hidden;
    min-height: 120px;
    transition: transform .2s;
}
.small-box:hover { transform: translateY(-2px); }
.small-box .inner { padding: 20px; }
.small-box .inner h3 { font-size: 28px; font-weight: 700; margin: 0 0 4px; color: #fff; }
.small-box .inner p { font-size: 13px; color: rgba(255,255,255,.85); margin: 0; }
.small-box .icon {
    position: absolute; top: 15px; right: 15px;
    font-size: 48px; color: rgba(255,255,255,.15);
    transition: .3s;
}
.small-box:hover .icon { font-size: 52px; }
.small-box-footer {
    display: block; padding: 8px 20px;
    background: rgba(0,0,0,.1);
    color: rgba(255,255,255,.85);
    font-size: 12px; text-decoration: none;
    transition: .2s;
}
.small-box-footer:hover { background: rgba(0,0,0,.2); color: #fff; }

/* Info Box */
.info-box {
    display: flex; align-items: center;
    background: #fff; border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 16px 20px; gap: 16px;
    min-height: 90px;
    transition: transform .2s;
}
.info-box:hover { transform: translateY(-1px); }
.info-box-icon {
    width: 50px; height: 50px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff;
    flex-shrink: 0;
}
.info-box-content { flex: 1; }
.info-box-text { font-size: 13px; color: var(--avni-text-muted); margin-bottom: 2px; }
.info-box-number { font-size: 22px; font-weight: 700; color: var(--avni-text); }

/* Buttons */
.btn {
    border-radius: 8px; font-size: 13px;
    padding: 8px 18px; font-weight: 500;
    transition: all .15s ease;
}
.btn-primary { background: var(--avni-primary); border-color: var(--avni-primary); color: #fff; }
.btn-primary:hover { background: var(--avni-secondary); border-color: var(--avni-secondary); }
.btn-outline-primary { color: var(--avni-primary); border-color: var(--avni-primary); }
.btn-outline-primary:hover { background: var(--avni-primary); border-color: var(--avni-primary); color: #fff; }
.btn-accent { background: var(--avni-accent); border-color: var(--avni-accent); color: #fff; }
.btn-accent:hover { background: #e65100; border-color: #e65100; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--avni-border);
    padding: 9px 14px;
    font-size: 13px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--avni-primary);
    box-shadow: 0 0 0 3px rgba(26,35,126,.1);
}
.form-label { font-size: 13px; font-weight: 500; color: var(--avni-text); margin-bottom: 4px; }
.form-text { font-size: 11px; color: var(--avni-text-muted); }
.form-control-sm { padding: 6px 10px; font-size: 12px; }
.input-group-text { border-radius: 8px; }

/* Tables */
.table { margin-bottom: 0; }
.table thead th {
    border-top: none; border-bottom: 2px solid var(--avni-border);
    font-weight: 600; font-size: 12px;
    color: var(--avni-text-muted);
    text-transform: uppercase; letter-spacing: .4px;
    padding: 12px 12px;
}
.table td {
    vertical-align: middle;
    font-size: 13px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.table tbody tr:hover { background: rgba(26,35,126,.03); }
.table-striped tbody tr:nth-of-type(odd) { background: rgba(0,0,0,.01); }

/* Badges */
.badge { 
    border-radius: 6px; padding: 4px 10px;
    font-size: 11px; font-weight: 600;
}
.badge-stage { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; }

/* Alerts */
.alert { border: none; border-radius: 10px; padding: 14px 18px; font-size: 13px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger { background: #f8d7da; color: #721c24; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-info { background: #d1ecf1; color: #0c5460; }

/* Progress Bars */
.progress { border-radius: 10px; height: 8px; background: #e9ecef; }
.progress-bar { border-radius: 10px; }

/* Tabs */
.nav-tabs { border-bottom: 1px solid var(--avni-border); }
.nav-tabs .nav-link {
    color: var(--avni-text-muted); font-weight: 500;
    border: none; padding: 10px 18px;
    border-bottom: 3px solid transparent;
    font-size: 13px; transition: .15s;
}
.nav-tabs .nav-link:hover { color: var(--avni-primary); border-color: transparent; }
.nav-tabs .nav-link.active {
    color: var(--avni-primary);
    border-bottom-color: var(--avni-accent);
    background: transparent;
}

/* Pagination */
.pagination { margin: 0; }
.page-link {
    border: none; padding: 8px 14px;
    color: var(--avni-primary); font-size: 13px;
    border-radius: 6px; margin: 0 2px;
}
.page-link:hover { background: var(--avni-light); color: var(--avni-primary); }
.page-item.active .page-link { background: var(--avni-primary); color: #fff; }

/* Modals */
.modal-content { border: none; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { border-bottom: 1px solid var(--avni-border); padding: 16px 24px; border-radius: 14px 14px 0 0; }
.modal-header .modal-title { font-size: 16px; font-weight: 600; }
.modal-header .btn-close:focus { box-shadow: none; }
.modal-body { padding: 20px 24px; }
.modal-footer { border-top: 1px solid var(--avni-border); padding: 14px 24px; border-radius: 0 0 14px 14px; }

/* Breadcrumbs */
.breadcrumb { background: transparent; padding: 0; margin: 0; font-size: 12px; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--avni-text-muted); }
.breadcrumb-item.active { color: var(--avni-primary); font-weight: 500; }

/* Timeline */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
    content: ''; position: absolute;
    left: 10px; top: 0; bottom: 0;
    width: 2px; background: var(--avni-border);
}
.timeline-item { position: relative; margin-bottom: 18px; padding-bottom: 8px; }
.timeline-item::before {
    content: ''; position: absolute;
    left: -25px; top: 5px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--avni-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--avni-primary);
}
.timeline-item .timeline-date { font-size: 11px; color: var(--avni-text-muted); }
.timeline-item .timeline-content { margin-top: 2px; font-size: 13px; }
.timeline-item .timeline-user { font-weight: 600; color: var(--avni-primary); }

/* Customer Header */
.customer-header {
    background: linear-gradient(135deg, var(--avni-dark) 0%, var(--avni-primary) 50%, var(--avni-secondary) 100%);
    color: #fff; padding: 24px; border-radius: 12px; margin-bottom: 20px;
}
.customer-header .case-id { color: var(--avni-accent); font-weight: 700; font-size: 14px; }
.customer-header .customer-name { font-size: 22px; font-weight: 700; }
.customer-stats { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }
.customer-stats .stat-item { text-align: center; }
.customer-stats .stat-value { font-size: 18px; font-weight: 700; }
.customer-stats .stat-label { font-size: 11px; opacity: .8; }

/* Dropdown */
.dropdown-menu {
    border: none; border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    padding: 6px;
}
.dropdown-item {
    border-radius: 6px; padding: 8px 14px;
    font-size: 13px; transition: .1s;
}
.dropdown-item:hover { background: var(--avni-light); }
.dropdown-item i { width: 18px; text-align: center; }
.dropdown-divider { margin: 4px 0; }

/* Notifications */
.notification-bell { position: relative; cursor: pointer; }
.notification-bell i { font-size: 20px; color: var(--avni-text-muted); }
.notification-badge {
    position: absolute; top: -6px; right: -8px;
    background: var(--avni-danger); color: #fff;
    font-size: 10px; font-weight: 700;
    width: 18px; height: 18px;
    border-radius: 50%; display: flex;
    align-items: center; justify-content: center;
}
.notification-dropdown { width: 340px; max-height: 400px; overflow-y: auto; }
.notification-item { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: rgba(26,35,126,.04); }
.notification-item .notif-title { font-size: 13px; font-weight: 600; }
.notification-item .notif-time { font-size: 11px; color: var(--avni-text-muted); }

/* Border colors */
.border-left-primary { border-left: 3px solid var(--avni-primary); }
.border-left-success { border-left: 3px solid var(--avni-success); }
.border-left-warning { border-left: 3px solid var(--avni-warning); }
.border-left-danger { border-left: 3px solid var(--avni-danger); }
.border-left-info { border-left: 3px solid var(--avni-info); }

/* Color helpers */
.bg-primary { background-color: var(--avni-primary) !important; }
.bg-secondary { background-color: var(--avni-secondary) !important; }
.bg-accent { background-color: var(--avni-accent) !important; }
.text-primary { color: var(--avni-primary) !important; }

/* Error pages */
.error-page {
    text-align: center; padding: 80px 20px;
    min-height: 60vh; display: flex;
    flex-direction: column; justify-content: center;
}
.error-page .error-code { font-size: 100px; font-weight: 800; color: var(--avni-primary); line-height: 1; }
.error-page .error-title { font-size: 24px; font-weight: 600; margin: 10px 0; }
.error-page .error-text { color: var(--avni-text-muted); margin-bottom: 24px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 48px; color: var(--avni-border); margin-bottom: 16px; }
.empty-state h5 { color: var(--avni-text-muted); font-weight: 500; }

/* Statistics cards */
.stat-card { text-align: center; padding: 20px; }
.stat-card .stat-icon { font-size: 32px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--avni-text-muted); }

/* Mobile toggle button */
.mobile-toggle {
    display: none;
    background: none; border: none;
    font-size: 22px; color: var(--avni-text-muted);
    cursor: pointer; padding: 4px;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-toggle {
        display: block;
    }
    .content-wrapper { padding: 16px; }
    .top-header { padding: 0 16px; }
}

@media (max-width: 575.98px) {
    .small-box .inner h3 { font-size: 22px; }
    .info-box { padding: 12px 16px; min-height: 70px; }
    .info-box-number { font-size: 18px; }
    .info-box-icon { width: 40px; height: 40px; font-size: 18px; }
    .customer-header { padding: 16px; }
    .customer-header .customer-name { font-size: 18px; }
    .customer-stats { gap: 12px; }
    .table-responsive { font-size: 12px; }
    .content-wrapper { padding: 12px; }
    .notification-dropdown { width: 290px; }
}

/* Print */
@media print {
    .sidebar, .top-header, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Loading spinner */
.spinner-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,.7); z-index: 9999;
    display: none; align-items: center; justify-content: center;
}
.spinner-overlay.show { display: flex; }

/* Charts placeholder */
.chart-container { position: relative; min-height: 250px; }

/* Kanban-like cards */
.kanban-card { border-left: 3px solid var(--avni-primary); }
.kanban-card.urgent { border-left-color: var(--avni-danger); }
.kanban-card.high { border-left-color: var(--avni-warning); }

/* Search results dropdown */
#searchResults {
    position: absolute; top: 100%; left: 0; right: 0;
    z-index: 1050;
    background: #fff; border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    max-height: 320px; overflow-y: auto;
    display: none;
}

/* Login page enhancements */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--avni-dark) 0%, var(--avni-primary) 50%, var(--avni-secondary) 100%);
    position: relative; overflow: hidden;
}
.login-page::before {
    content: ''; position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,.03) 0%, transparent 70%);
    animation: loginFloat 20s ease-in-out infinite;
}
@keyframes loginFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, 30px); }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,.3); z-index: 1035;
}
@media (max-width: 991.98px) {
    .sidebar-overlay.show { display: block; }
}

/* ==================================================================
   User Profile & Account Management styles
   ================================================================== */

/* User avatar (topbar + lists) */
.user-avatar img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.avatar-36 { width: 36px; height: 36px; font-size: 13px; }
.avatar-40 { width: 40px; height: 40px; font-size: 14px; }
.avatar-photo { width: 36px; height: 36px; }
.avatar-photo-lg { width: 44px; height: 44px; }
.user-avatar-lg { width: 44px; height: 44px; }
.user-avatar-lg img { width: 44px; height: 44px; }
.user-initials { font-weight: 600; line-height: 1; }

/* Topbar profile dropdown */
.user-profile-toggle {
    color: inherit;
    border-radius: 8px;
    padding: 4px 6px;
    gap: 4px;
}
.user-profile-toggle:hover { background: var(--avni-light); }
.user-profile-toggle::after { margin-left: 4px; color: var(--avni-text-muted); }
.user-profile-toggle .user-info { text-align: left; }
.user-profile-toggle .user-name,
.user-profile-toggle .user-role { display: block; }
.user-profile-menu { min-width: 260px; }
.user-profile-head {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.user-profile-head .min-w-0 { min-width: 0; }
.user-profile-menu .dropdown-header { padding: 10px 14px; }
.min-w-0 { min-width: 0; }

/* Ensure the topbar dropdowns render above cards/tables */
.top-header { z-index: 1060; }
.top-header .dropdown-menu {
    z-index: 1080;
    margin-top: 6px;
}

/* Profile summary card */
.profile-summary-card {
    position: sticky;
    top: 84px;
}
.profile-photo-wrapper {
    width: 140px;
    height: 140px;
}
.profile-photo-wrapper .profile-photo-lg,
.profile-photo-wrapper img {
    width: 140px;
    height: 140px;
    font-size: 44px;
    object-fit: cover;
}
.profile-photo-lg {
    width: 140px;
    height: 140px;
    font-size: 44px;
}

/* Profile detail fields */
.profile-field {
    padding-bottom: 10px;
}
.profile-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--avni-text-muted);
    font-weight: 600;
    margin-bottom: 2px;
}
.profile-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--avni-text);
}

/* Tables with avatars */
.table .avatar-36 { flex-shrink: 0; }

/* Responsive profile layout */
@media (max-width: 991.98px) {
    .profile-summary-card { position: static; }
}
@media (max-width: 575.98px) {
    .user-profile-toggle .user-info { display: none !important; }
    .user-profile-menu { min-width: 230px; }
}
