/* ==============================
   CSS Custom Properties
   Light defaults — sidebar always dark
   ============================== */
:root {
    --sidebar-bg: #1a1f2e;
    --sidebar-hover-bg: #2d3548;
    --sidebar-active-accent: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-logo-bg: #1a1f2e;
    --sidebar-width: 250px;
    --topbar-height: 60px;
    /* Content area — LIGHT defaults */
    --content-bg: #f1f5f9;
    --surface-bg: #ffffff;
    --surface-border: #e2e8f0;
    --surface-hover: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    /* Bracket */
    --bracket-line: rgba(0, 0, 0, 0.15);
    --bracket-card-border: #e2e8f0;
    --bracket-divider: #e2e8f0;
    --bracket-wrapper-bg: rgba(0, 0, 0, 0.03);
    --bracket-wrapper-border: rgba(0, 0, 0, 0.06);
    --match-completed-bg: #f0fdf4;
}

/* ==============================
   Dark Theme Overrides
   ============================== */
[data-theme="dark"] {
    --content-bg: #1a1f2e;
    --surface-bg: rgba(255, 255, 255, 0.04);
    --surface-border: rgba(255, 255, 255, 0.08);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: rgba(148, 163, 184, 0.6);
    /* Bracket */
    --bracket-line: rgba(255, 255, 255, 0.12);
    --bracket-card-border: rgba(255, 255, 255, 0.15);
    --bracket-divider: rgba(255, 255, 255, 0.08);
    --bracket-wrapper-bg: rgba(255, 255, 255, 0.03);
    --bracket-wrapper-border: rgba(255, 255, 255, 0.06);
    --match-completed-bg: rgba(30, 41, 59, 0.9);
}

/* ==============================
   Sidebar
   ============================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    background-color: var(--sidebar-logo-bg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-logo img {
    height: 40px;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.5;
    padding: 1rem 1.5rem 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    border-left: 3px solid transparent;
    min-height: 44px;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-link.active {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-accent);
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* Submenu toggle */
.sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    border-left: 3px solid transparent;
    width: 100%;
    background: none;
    border-right: none;
    border-top: none;
    border-bottom: none;
    cursor: pointer;
    min-height: 44px;
}

.sidebar-submenu-toggle:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-submenu-toggle.active {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-accent);
}

.sidebar-submenu-toggle .sidebar-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.sidebar-submenu-toggle[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(90deg);
}

.sidebar-submenu .sidebar-link {
    padding-left: 3.25rem;
    font-size: 0.8125rem;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--sidebar-text);
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sidebar-text);
    background: none;
    border: none;
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 0.35rem 0;
    transition: color 0.15s ease;
    width: 100%;
}

.sidebar-logout-btn:hover {
    color: #ef4444;
}

/* ==============================
   Sidebar Overlay (mobile)
   ============================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

.sidebar-overlay.show {
    display: block;
}

/* ==============================
   Topbar — Base
   ============================== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
}

/* Topbar — Dark Glass */
[data-theme="dark"] .topbar {
    background: rgba(26, 31, 46, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.topbar-hamburger:hover {
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-notif-link {
    position: relative;
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.375rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.topbar-notif-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.topbar-user-greeting {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.topbar-logout-btn {
    color: var(--text-secondary);
    background: none;
    border: 1px solid var(--surface-border);
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 36px;
}

.topbar-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* ==============================
   Content Wrapper
   ============================== */
.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--content-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Animated mesh gradient — dark mode only */
[data-theme="dark"] .content-wrapper::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.09) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(6, 182, 212, 0.07) 0%, transparent 50%);
    animation: meshMove 20s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

@keyframes meshMove {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(-5%, 3%) scale(1.05); }
    66%  { transform: translate(3%, -5%) scale(0.98); }
    100% { transform: translate(-2%, 2%) scale(1.02); }
}

.content-main {
    flex: 1;
    padding: 1.5rem;
}

.content-footer {
    padding: 0.75rem 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-footer img {
    opacity: 0.5;
}

/* ==============================
   Public Dashboard
   ============================== */
.content-wrapper-public {
    min-height: 100vh;
    background: var(--content-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Animated mesh gradient — dark mode only */
[data-theme="dark"] .content-wrapper-public::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.09) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(6, 182, 212, 0.07) 0%, transparent 50%);
    animation: meshMove 20s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

.public-topbar {
    height: var(--topbar-height);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

[data-theme="dark"] .public-topbar {
    background: rgba(26, 31, 46, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: none;
}

.public-topbar img {
    filter: brightness(0.9);
}

/* ==============================
   Mobile Responsive (< 992px)
   ============================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0;
    }

    .topbar-hamburger {
        display: flex;
    }
}
