/* CentraMEDKIT Sidebar — Compact Modern */
/* Loaded from sidebar.php, after page inline styles, so it wins the cascade. */

:root {
    --sb-width: 240px;
    --sb-bg: rgba(255, 255, 255, 0.97);
    --sb-ink: var(--text-primary, #1f2937);
    --sb-ink-soft: var(--text-secondary, #64748b);
    --sb-line: rgba(15, 23, 42, 0.06);
    --sb-icon-bg: rgba(15, 23, 42, 0.05);
    --sb-hover-bg: rgba(59, 130, 246, 0.08);
    --sb-hover-ink: var(--primary-color, #2563eb);
    --sb-user-bg: rgba(15, 23, 42, 0.04);
    --sb-brand-color: var(--sb-ink);
    --sb-accent: var(--primary-color, #2563eb);
    --sb-accent-dark: var(--primary-dark, #1e40af);

    --tb-bg: rgba(255, 255, 255, 0.92);
    --tb-ink: #1f2937;
    --tb-ink-soft: #6b7280;
    --tb-line: rgba(15, 23, 42, 0.06);
    --tb-accent: var(--primary-color, #2563eb);
}

/* ---------- Layout (desktop) ---------- */

@media (min-width: 769px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: 240px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        z-index: 1000 !important;
    }

    .sidebar-nav {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-content {
        margin-left: 240px !important;
        width: calc(100% - 240px) !important;
        box-sizing: border-box !important;
        padding-top: 56px !important;
        flex: none !important;
    }
}

/* ---------- Top bar ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 56px;
    padding: 0 1.25rem;
    background: var(--tb-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--tb-line);
    color: var(--tb-ink);
}

.topbar-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.topbar-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: 9px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    flex: none;
    color: #dc2626;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.18);
    transition: all 0.2s ease;
}

.topbar-logout:hover {
    background: #dc2626;
    border-color: transparent;
    color: #fff;
    transform: translateY(-1px);
}

.topbar-logout svg {
    width: 15px;
    height: 15px;
}

@media (max-width: 480px) {
    .topbar-logout .logout-label {
        display: none;
    }

    .topbar-logout {
        padding: 0.45rem 0.6rem;
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
}

.topbar-date {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--tb-ink-soft);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: inherit;
}

.topbar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--tb-accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    flex: none;
}

.topbar-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--tb-ink);
    white-space: nowrap;
}

@media (min-width: 769px) {
    .topbar {
        position: fixed;
        top: 0;
        left: var(--sb-width);
        right: 0;
        z-index: 950;
    }
}

@media (max-width: 768px) {
    .topbar {
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        order: -1;
        z-index: 950;
    }

    .topbar-date {
        display: none;
    }
}

/* ---------- Base (all viewports) ---------- */

.sidebar {
    background: var(--sb-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--sb-line);
    padding: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--sb-line);
    margin-bottom: 0;
}

.sidebar-logo {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.45);
}

.sidebar-header-text {
    min-width: 0;
}

.sidebar-brand {
    display: block;
    max-width: 100%;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    text-align: left;
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
    color: var(--sb-brand-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-tagline {
    display: block;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--sb-ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding: 0.55rem 0.75rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 8px;
}

/* Nav sections */

.nav-section {
    margin-top: 0.85rem;
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-section-label {
    display: block;
    padding: 0.4rem 0.65rem 0.35rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sb-ink-soft);
    opacity: 0.8;
}

/* Nav items */

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    font-size: 0.845rem;
    font-weight: 500;
    color: var(--sb-ink);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.nav-link:hover {
    background: var(--sb-hover-bg);
    color: var(--sb-hover-ink);
    transform: translateX(2px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--sb-accent), var(--sb-accent-dark));
    color: #fff;
    box-shadow: 0 6px 14px -6px rgba(37, 99, 235, 0.5);
    font-weight: 600;
}

.nav-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 0;
    border-radius: 8px;
    background: var(--sb-icon-bg);
    color: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-icon svg {
    width: 15px;
    height: 15px;
}

.nav-link:hover .nav-icon {
    background: var(--sb-hover-bg);
}

.nav-link.active .nav-icon {
    background: rgba(255, 255, 255, 0.18);
}

/* Logout */

.nav-link.logout-link {
    margin-top: 0.4rem;
    border: none;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    font-weight: 600;
}

.nav-link.logout-link:hover {
    transform: none;
    background: #dc2626;
    color: #fff;
    box-shadow: 0 6px 14px -6px rgba(220, 38, 38, 0.5);
}

.nav-link.logout-link:hover .nav-icon {
    background: rgba(255, 255, 255, 0.18);
}

/* Footer user chip */

.sidebar-footer {
    flex: none;
    padding: 0.75rem;
    border-top: 1px solid var(--sb-line);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    background: var(--sb-user-bg);
    min-width: 0;
}

.sidebar-avatar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sb-accent), var(--sb-accent-dark));
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-user-meta {
    min-width: 0;
}

.sidebar-user-name {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sb-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    display: block;
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--sb-ink-soft);
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile tidy-up */

@media (max-width: 768px) {
    .sidebar {
        padding: 0;
    }
}

/* Redesigned Premium Topbar Switcher Button */
.topbar-console-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #000000;
    padding: 0.45rem 1rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.topbar-console-btn:hover {
    color: #000000;
    border-color: var(--tb-accent, #2563eb);
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.25);
}

.topbar-console-btn:active {
    transform: translateY(0);
}

.topbar-console-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.2;
    display: block;
}

@media (max-width: 768px) {
    .topbar-console-btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.72rem;
        gap: 0.35rem;
    }
    .topbar-console-btn svg {
        width: 12px;
        height: 12px;
    }
}
