/* ===== Sidebar — Single Panel ===== */
.site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    transition: transform 0.3s ease;
}

/* Logo */
.sidebar-logo {
    position: relative;
    padding: 20px 16px 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo-text {
    flex: 1;
    min-width: 0;
    font-size: 1.3rem;
    font-weight: 400;
    font-family: inherit;
    color: var(--sidebar-foreground);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted-color);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-theme-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-foreground);
    border-color: var(--sidebar-border);
}

.sidebar-theme-btn:focus-visible {
    outline: 2px solid var(--sidebar-ring);
    outline-offset: 2px;
}

.sidebar-theme-btn svg {
    width: 22px;
    height: 22px;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--sidebar-foreground);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    line-height: 1.3;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
}

.sidebar-link:focus-visible {
    outline: 2px solid var(--sidebar-ring);
    outline-offset: 2px;
}

.sidebar-link.active {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg {
    opacity: 1;
}

/* Bottom section */
.sidebar-bottom {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* User info in sidebar */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
}

.sidebar-user:hover {
    background: var(--sidebar-hover);
}

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sidebar-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-accent);
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    overflow: hidden;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sidebar-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: var(--muted-color);
}

.sidebar-user-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-color);
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    text-decoration: none;
}

.sidebar-user-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-foreground);
}

.sidebar-user-btn svg {
    width: 16px;
    height: 16px;
}

/* Theme dropdown positioned below logo bar */
.sidebar-logo .theme-control {
    flex-shrink: 0;
}

/* Theme selector in sidebar */
.sidebar-theme {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.sidebar-theme:hover {
    background: var(--sidebar-hover);
}

.sidebar-theme svg {
    width: 16px;
    height: 16px;
    color: var(--muted-color);
    flex-shrink: 0;
}

.sidebar-theme-label {
    flex: 1;
    font-size: 0.82rem;
    color: var(--muted-color);
    font-weight: 500;
}

/* Mobile toggle — drawer handle at sidebar edge */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 0;
    z-index: 10001;
    width: 40px;
    height: 32px;
    border-radius: 0 8px 8px 0;
    border: 1px solid var(--sidebar-border);
    border-left: none;
    background: var(--sidebar-bg);
    color: var(--sidebar-foreground);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mobile-sidebar-toggle:hover {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-ring);
}

.mobile-sidebar-toggle:focus-visible {
    outline: 2px solid var(--sidebar-ring);
    outline-offset: 2px;
}

.mobile-sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

body.sidebar-mobile-open .mobile-sidebar-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .mobile-sidebar-toggle {
        display: flex;
    }

    .site-sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-mobile-open .site-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }

    body.sidebar-mobile-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    .sidebar-theme-btn {
        width: 36px;
        height: 36px;
        min-height: 0;
        min-width: 0;
        padding: 0;
    }
}

/* ===== User Modal ===== */
.dialog-overlay {
    z-index: 10002;
}

.user-modal {
    width: 360px;
    padding: 0;
    position: relative;
}

.user-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--menu-hover);
    color: var(--muted-color);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.user-modal-close:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.user-modal-close svg {
    width: 16px;
    height: 16px;
}

/* Tabs */
.user-modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.user-modal-tab {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted-color);
    cursor: pointer;
    transition: color 0.15s ease, box-shadow 0.15s ease;
}

.user-modal-tab:hover {
    color: var(--text-color);
}

.user-modal-tab.active {
    color: var(--accent-color);
    box-shadow: inset 0 -2px 0 var(--accent-color);
}

/* Form in modal */
.user-modal-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-modal-form .auth-submit {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.user-modal-form .forgot-password-link {
    font-size: 0.82rem;
    color: var(--link-color);
    text-align: right;
    margin-top: -4px;
    text-decoration: none;
}

.user-modal-form .forgot-password-link:hover {
    text-decoration: underline;
}

/* Auth message in modal */
.user-modal .auth-message {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.user-modal .auth-message--error {
    background: var(--error-bg);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

/* Form group in modal */
.user-modal .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-modal .form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
}

.user-modal .form-group input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.user-modal .form-group input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--input-focus) 15%, transparent);
}

.user-modal .form-group input::placeholder {
    color: var(--muted-color);
    opacity: 0.6;
}

/* OAuth in modal */
.user-modal .auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0 20px;
    color: var(--muted-color);
    font-size: 0.85rem;
}

.user-modal .auth-divider::before,
.user-modal .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.user-modal .discord-login-btn,
.user-modal .google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    margin-left: 20px;
    margin-right: 20px;
}

.user-modal .discord-login-btn {
    background: var(--brand-discord);
    color: #fff;
    border: none;
    margin-bottom: 10px;
}

.user-modal .discord-login-btn:hover {
    background: var(--brand-discord-hover);
}

.user-modal .google-login-btn {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.user-modal .google-login-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-color);
}

/* Profile section */
.user-modal-profile {
    padding: 32px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.user-modal-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 600;
    overflow: hidden;
    background: var(--sidebar-hover);
    color: var(--sidebar-accent);
    flex-shrink: 0;
}

.user-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-modal-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-color);
}

.user-modal-role {
    font-size: 0.82rem;
    color: var(--muted-color);
}

.user-modal-actions {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-modal-actions .btn {
    width: 100%;
    justify-content: center;
}
