/* ==========================================================================
   KALORIA — SHARED SIDEBAR + HEADER NAVIGATION SYSTEM
   ========================================================================== */

:root {
    --sidebar-width: 300px;
    --sidebar-mobile-width: 85vw;
    --header-h: 64px;
    --overlay-bg: rgba(15, 23, 42, 0.38);
    --sidebar-bg: #FFFFFF;
    --sidebar-border: #E2E8F0;
    --nav-active-bg: #ECFDF5;
    --nav-active-border: #10B981;
    --nav-active-text: #047857;
    --nav-hover-bg: #F8FAFC;
    --nav-text: #334155;
    --nav-icon: #64748B;
    --section-label: #94A3B8;
    --ease-sidebar: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   SHARED APP HEADER
   ========================================================================== */
.kaloria-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    height: var(--header-h);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--sidebar-border);
}

.kaloria-header-inner {
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Hamburger Button */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--sidebar-border);
    background: #FFFFFF;
    cursor: pointer;
    color: #334155;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #F1F5F9;
    border-color: #CBD5E1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

/* Brand Logo in Header */
.kaloria-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    flex-shrink: 0;
}

.kaloria-brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #047857, #10B981);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.kaloria-brand-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: #0F172A;
    letter-spacing: -0.02em;
}

.kaloria-brand-text span {
    color: #10B981;
}

/* Header right slot */
.kaloria-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* AI Badge pill */
.header-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ECFDF5;
    color: #047857;
    border: 1px solid #A7F3D0;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

/* Page content offset */
.page-body-with-header {
    padding-top: var(--header-h);
    min-height: 100vh;
}

/* ==========================================================================
   OVERLAY
   ========================================================================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: var(--overlay-bg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.sidebar-overlay.is-open {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================================================
   SIDEBAR DRAWER
   ========================================================================== */
.kaloria-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 500;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-sidebar);
    box-shadow: 12px 0 40px -8px rgba(15, 23, 42, 0.1);
    overflow: hidden;
}

.kaloria-sidebar.is-open {
    transform: translateX(0);
}

/* Sidebar top brand bar */
.sidebar-brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid #F1F5F9;
    flex-shrink: 0;
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #047857, #10B981);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0F172A;
    letter-spacing: -0.02em;
}

.sidebar-brand-name span {
    color: #10B981;
}

/* Close button */
.sidebar-close-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #F8FAFC;
    cursor: pointer;
    color: #64748B;
    flex-shrink: 0;
    transition: background 0.18s, color 0.18s;
}

.sidebar-close-btn:hover {
    background: #0F172A;
    color: #FFFFFF;
    border-color: #0F172A;
}

/* Sidebar version tag */
.sidebar-version {
    margin: 12px 20px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ECFDF5;
    color: #047857;
    border: 1px solid #A7F3D0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    width: fit-content;
}

/* Sidebar scrollable nav area */
.sidebar-nav-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    scrollbar-width: thin;
    scrollbar-color: #E2E8F0 transparent;
}

.sidebar-nav-area::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav-area::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav-area::-webkit-scrollbar-thumb {
    background: #E2E8F0;
    border-radius: 4px;
}

/* Nav section label */
.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--section-label);
    padding: 0 10px;
    margin: 14px 0 6px;
}

.nav-section-label:first-child {
    margin-top: 0;
}

/* Nav item */
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    color: var(--nav-text);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    position: relative;
    white-space: nowrap;
}

.nav-item svg {
    flex-shrink: 0;
    color: var(--nav-icon);
    transition: color 0.18s;
}

.nav-item:hover {
    background: var(--nav-hover-bg);
    color: #0F172A;
}

.nav-item:hover svg {
    color: #10B981;
}

/* Active nav item */
.nav-item.is-active {
    background: var(--nav-active-bg);
    border-color: #A7F3D0;
    color: var(--nav-active-text);
    font-weight: 600;
}

.nav-item.is-active svg {
    color: #10B981;
}

.nav-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #10B981;
    border-radius: 0 3px 3px 0;
}

/* Nav item badge */
.nav-badge {
    margin-left: auto;
    background: #10B981;
    color: #FFFFFF;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

/* Sidebar divider */
.sidebar-divider {
    height: 1px;
    background: #F1F5F9;
    margin: 8px 0;
}

/* Sidebar bottom user section */
.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid #F1F5F9;
    flex-shrink: 0;
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #F8FAFC;
    border: 1px solid #F1F5F9;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #047857, #10B981);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0F172A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-plan {
    font-size: 0.72rem;
    color: #64748B;
}

/* Sidebar logout link */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748B;
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 6px;
    text-decoration: none;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
}

.sidebar-logout-btn:hover {
    background: #FEF2F2;
    color: #DC2626;
}

/* ==========================================================================
   MOBILE
   ========================================================================== */
@media (max-width: 768px) {
    .kaloria-sidebar {
        width: var(--sidebar-mobile-width);
        max-width: 340px;
    }
}

/* ==========================================================================
   BODY SCROLL LOCK
   ========================================================================== */
body.sidebar-lock {
    overflow: hidden;
}

/* ── Sidebar avatar rasm ─────────────────────────────────────────────── */
.sidebar-avatar-img {
    background: none;
    padding: 0;
    overflow: hidden;
}
.sidebar-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER DROPDOWN Z-INDEX FIX
   header z-index: 300, sidebar z-index: 500, overlay: 400
   Dropdown header ichida bo'lgani uchun header z-index oshiriladi
   va dropdown o'zi ham yuqori z-index oladi.
   ═══════════════════════════════════════════════════════════════════════ */

/* Header ni overlay/sidebar ustiga chiqarish */
.kaloria-header {
    z-index: 600 !important;
}

/* user-profile-wrapper — stacking context yaratadi */
#headerProfileWrapper,
.user-profile-wrapper {
    position: relative !important;
    z-index: 610 !important;
}

/* Dropdown — wrapper ichida absolute, lekin z-index juda yuqori */
#headerDropdownMenu,
.user-dropdown-card {
    position: absolute !important;
    top: calc(100% + 10px) !important;
    right: 0 !important;
    left: auto !important;
    width: 264px !important;
    z-index: 9999 !important;
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 18px !important;
    padding: 16px !important;
    box-shadow: 0 20px 48px -8px rgba(15, 23, 42, 0.18) !important;
    animation: kDropSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes kDropSlide {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* avatar-img — profil rasmi uchun */
.avatar-circle.avatar-img,
img.avatar-circle {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
}

/* header-ai-badge — link sifatida */
.header-ai-badge {
    text-decoration: none !important;
    cursor: pointer !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER DROPDOWN — BARCHA SAHIFALAR UCHUN (shared)
   ═══════════════════════════════════════════════════════════════════════ */

/* Profile button */
.profile-avatar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.profile-avatar-btn:hover {
    border-color: #CBD5E1;
    box-shadow: 0 2px 8px rgba(15,23,42,0.07);
}

/* Avatar circle */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #047857, #10B981);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Chevron */
.chevron-icon {
    color: #94A3B8;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.profile-avatar-btn[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

/* Dropdown card */
.user-dropdown-card {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
}

/* Dropdown header (user info qismi) */
.dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
}
.dropdown-avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #047857, #10B981);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.user-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0F172A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-email {
    font-size: 0.75rem;
    color: #64748B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Divider */
.dropdown-divider {
    height: 1px;
    background: #F1F5F9;
    margin: 6px 0;
}

/* Dropdown items */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.dropdown-item svg {
    color: #94A3B8;
    flex-shrink: 0;
    transition: color 0.15s;
}
.dropdown-item:hover {
    background: #F8FAFC;
    color: #0F172A;
}
.dropdown-item:hover svg {
    color: #10B981;
}

/* Logout tugmasi */
.dropdown-item.btn-logout {
    color: #EF4444;
}
.dropdown-item.btn-logout svg {
    color: #EF4444;
}
.dropdown-item.btn-logout:hover {
    background: #FEF2F2;
    color: #DC2626;
}
.dropdown-item.btn-logout:hover svg {
    color: #DC2626;
}

/* Login button (kirish) */
.btn-primary-sm {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    background: linear-gradient(135deg, #047857, #10B981);
    color: #fff;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
    transition: opacity 0.18s, transform 0.18s;
}
.btn-primary-sm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
