/* ==========================================================================
   SIDEBAR GLOBAL — shared across all pages
   ========================================================================== */

/* ── 1. APP-CONTENT OFFSET ──────────────────────────────────────────────── */
.app-content {
    margin-left: 220px;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.gs-collapsed .app-content {
    margin-left: 60px;
}

/* ── 2. SIDEBAR SHELL ───────────────────────────────────────────────────── */
.global-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1a1a20 0%, #0f0f13 100%);
    border-right: 1px solid #27272a;
    z-index: 200;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

body.gs-collapsed .global-sidebar {
    width: 60px;
}

/* ── Toggle icon swap: collapsed shows hamburger, expanded shows chevron ── */
.gs-toggle-icon { width: 14px; height: 14px; flex-shrink: 0; }
.gs-toggle-icon--expand  { display: none; }

body.gs-collapsed .gs-toggle-icon--collapse { display: none; }
body.gs-collapsed .gs-toggle-icon--expand   { display: block; }

/* No rotation needed — icons are separate */
body.gs-collapsed .gs-toggle svg { transform: none; }

/* Collapsed brand: hide logo + name, center the toggle-as-hamburger */
body.gs-collapsed .gs-brand-expanded-only {
    display: none;
}

body.gs-collapsed .gs-brand {
    justify-content: center;
    padding: 0;            /* height stays 56px — only alignment changes */
    gap: 0;
}

/* Collapsed toggle: fits inside 56px brand, comfortable hit area */
body.gs-collapsed .gs-toggle {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
}

body.gs-collapsed .gs-toggle .gs-toggle-icon { width: 18px; height: 18px; }

/* Collapsed nav items: center icon, kill gap so no leftward offset */
body.gs-collapsed .gs-nav-item {
    justify-content: center;
    padding: 9px;
    gap: 0;
    position: relative;
}

/* Collapsed user section: center the logo image */
body.gs-collapsed .gs-user {
    justify-content: center;
    gap: 0;
}

/* ── 3. BRAND ───────────────────────────────────────────────────────────── */
.gs-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid #27272a;
    flex-shrink: 0;
    height: 56px;          /* fixed — never changes between states */
}

.gs-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
    flex-shrink: 0;
}

.gs-brand-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.03em;
    background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 40%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    flex: 1;
    opacity: 1;
    transition: opacity 0.15s;
}

.gs-toggle {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    cursor: pointer;
    color: #71717a;
    transition: all 0.2s;
    padding: 0;
}

.gs-toggle:hover {
    background: #2b2d31;
    color: #f5f5f7;
    border-color: #6366f1;
}

.gs-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.25s;
}

body.gs-collapsed .gs-toggle svg {
    transform: rotate(180deg);
}

/* ── 4. NAV ─────────────────────────────────────────────────────────────── */
.gs-nav {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}

.gs-nav::-webkit-scrollbar { width: 3px; }
.gs-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.gs-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #a1a1aa;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    border: 1px solid transparent;
    cursor: pointer;
}

.gs-nav-item:hover {
    background: #2b2d31;
    color: #f5f5f7;
}

.gs-nav-item.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(124,58,237,0.12));
    color: #a5b4fc;
    border-color: rgba(99,102,241,0.25);
}

.gs-nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.gs-nav-label {
    opacity: 1;
    transition: opacity 0.15s;
    overflow: hidden;
    white-space: nowrap;
}

body.gs-collapsed .gs-nav-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Collapsed: tooltip only (layout handled in the block above) */

body.gs-collapsed .gs-nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #24242a;
    color: #f5f5f7;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 6px;
    border: 1px solid #3f3f46;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 300;
}

body.gs-collapsed .gs-nav-item:hover::after {
    opacity: 1;
}

/* ── 5. USER SECTION ────────────────────────────────────────────────────── */
.gs-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-top: 1px solid #27272a;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    height: 60px;          /* fixed — never changes between states */
}

.gs-user:hover {
    background: rgba(99,102,241,0.06);
}

/* Website logo at bottom of sidebar (replaces user avatar) */
.gs-user-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Keep .gs-avatar only for popup header */
.gs-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
    user-select: none;
}

.gs-user-info {
    flex: 1;
    min-width: 0;
    opacity: 1;
    transition: opacity 0.15s;
}

body.gs-collapsed .gs-user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

.gs-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f5f5f7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-user-email {
    font-size: 11px;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 6. PROFILE POPUP ───────────────────────────────────────────────────── */
.gs-profile-popup {
    position: fixed;
    bottom: 68px;
    left: 8px;
    width: 290px;
    background: rgba(18, 18, 24, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.65), 0 0 0 1px rgba(99,102,241,0.1);
    padding: 14px;
    z-index: 600;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    transition: opacity 0.2s cubic-bezier(0.4,0,0.2,1),
                transform 0.2s cubic-bezier(0.4,0,0.2,1),
                visibility 0.2s;
}

.gs-profile-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.gsp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(124,58,237,0.05));
    border: 1px solid rgba(99,102,241,0.12);
    border-radius: 10px;
    margin-bottom: 12px;
}

.gsp-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
    user-select: none;
}

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

.gsp-name {
    font-size: 13px;
    font-weight: 700;
    color: #f5f5f7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gsp-email {
    font-size: 11px;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gsp-lang {
    font-size: 11px;
    font-weight: 700;
    color: #a1a1aa;
    background: rgba(99,102,241,0.1);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(99,102,241,0.2);
    letter-spacing: 0.06em;
    flex-shrink: 0;
    transition: all 0.2s;
}

.gsp-lang:hover {
    background: rgba(99,102,241,0.2);
    color: #a5b4fc;
}

/* Section label */
.gsp-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

/* Text input */
.gsp-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #f5f5f7;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s;
    font-family: inherit;
}

.gsp-input:focus {
    border-color: rgba(99,102,241,0.55);
    background: rgba(99,102,241,0.05);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Button row */
.gsp-btn-row {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
}

.gsp-btn {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: #a1a1aa;
    transition: all 0.2s;
    font-family: inherit;
}

.gsp-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #f5f5f7;
}

.gsp-btn-primary {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border-color: transparent;
    color: white;
}

.gsp-btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

/* Divider */
.gsp-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 10px 0;
}

/* Collapsible password */
.gsp-collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.gsp-collapsible-header:hover {
    background: rgba(99,102,241,0.07);
    border-color: rgba(99,102,241,0.18);
}

.gsp-collapsible-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: #f5f5f7;
}

.gsp-collapsible-title svg { width: 13px; height: 13px; color: #6366f1; }

.gsp-collapsible-arrow {
    width: 13px;
    height: 13px;
    color: #71717a;
    transition: transform 0.22s;
}

.gsp-collapsible-header.active .gsp-collapsible-arrow {
    transform: rotate(180deg);
}

.gsp-collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.gsp-collapsible-content.active { max-height: 400px; }

.gsp-collapsible-body { padding: 10px 2px 4px; }

/* Password inputs */
.gsp-pw-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.gsp-pw-wrap {
    position: relative;
    margin-bottom: 8px;
}

.gsp-pw-input {
    width: 100%;
    padding: 7px 34px 7px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #f5f5f7;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s;
    font-family: inherit;
}

.gsp-pw-input:focus {
    border-color: rgba(99,102,241,0.55);
    background: rgba(99,102,241,0.05);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.gsp-pw-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: #71717a;
    cursor: pointer;
    transition: color 0.2s;
}

.gsp-pw-toggle:hover { color: #6366f1; }

/* Logout */
.gsp-logout {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 6px;
    color: #f87171;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.gsp-logout:hover {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.45);
}

.gsp-logout svg { width: 13px; height: 13px; }

/* ── 7. MOBILE FLOATING TRIGGER ─────────────────────────────────────────── */
/* Replaces the old topbar — a small floating button always visible on mobile */
.gs-mob-trigger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    background: rgba(22,22,28,0.90);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    z-index: 350;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #a1a1aa;
    transition: background 0.2s, color 0.2s, opacity 0.2s;
    padding: 0;
}

.gs-mob-trigger:hover { background: #2b2d31; color: #f5f5f7; }
.gs-mob-trigger svg   { width: 16px; height: 16px; pointer-events: none; }

/* Hide trigger while sidebar is open (sidebar covers it) */
.gs-mob-trigger.sidebar-open { opacity: 0; pointer-events: none; }

/* ── 8. MOBILE OVERLAY ──────────────────────────────────────────────────── */
.gs-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 390;
    animation: gsFadeIn 0.2s ease;
}

.gs-mobile-overlay.active { display: block; }

@keyframes gsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── 9. RESPONSIVE ≤ 768px ──────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Sidebar: full height, slides from left */
    .global-sidebar {
        top: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 400;
    }

    .global-sidebar.mobile-open { transform: translateX(0); }

    /* No more padding-top — topbar is gone */
    .app-content {
        margin-left: 0 !important;
        padding-top: 0;
    }

    /* Show floating trigger; keep desktop toggle hidden unless sidebar is open */
    .gs-mob-trigger { display: flex; }

    /* Always show toggle on mobile as the "close" button inside the open sidebar */
    .gs-toggle { display: flex !important; }

    /* In collapsed state, collapsed width still overridden to full width */
    body.gs-collapsed .global-sidebar { width: 280px; }

    /* ── When sidebar is OPEN: restore full expanded look regardless of gs-collapsed ── */
    .global-sidebar.mobile-open .gs-brand-expanded-only {
        display: revert;
    }
    .global-sidebar.mobile-open .gs-brand {
        justify-content: flex-start;
        padding: 0 14px;
        gap: 10px;
    }
    /* Toggle shows chevron-left (close) — always, even if gs-collapsed */
    .global-sidebar.mobile-open .gs-toggle {
        width: 24px;
        height: 24px;
        border: 1px solid #3f3f46;
        border-radius: 6px;
    }
    .global-sidebar.mobile-open .gs-toggle-icon--collapse { display: block !important; }
    .global-sidebar.mobile-open .gs-toggle-icon--expand   { display: none  !important; }
    .global-sidebar.mobile-open .gs-toggle svg { transform: none !important; }

    /* Nav items: restore full layout */
    .global-sidebar.mobile-open .gs-nav-item {
        justify-content: flex-start;
        padding: 9px 10px;
        gap: 10px;
    }
    .global-sidebar.mobile-open .gs-nav-label {
        opacity: 1 !important;
        width: auto !important;
        pointer-events: auto !important;
    }
    .global-sidebar.mobile-open .gs-nav-item::after { display: none; }

    /* User section */
    .global-sidebar.mobile-open .gs-user {
        justify-content: flex-start;
        gap: 10px;
    }
    .global-sidebar.mobile-open .gs-user-info {
        opacity: 1 !important;
        width: auto !important;
        overflow: visible !important;
        pointer-events: auto !important;
    }

    /* Profile popup: anchored above user section at bottom of sidebar */
    .gs-profile-popup {
        left: 8px;
        right: 8px;
        width: auto;
        bottom: 68px;
        top: auto;
        transform-origin: bottom left;
        transform: translateY(8px) scale(0.98);
    }

    .gs-profile-popup.active {
        transform: translateY(0) scale(1);
    }
}
