/* ============================================
   SPL System - Glassmorphism Design System
   DiceBot Brand Palette: Gold (#FFB800) on Black
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: #0a0a0a;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #111111 50%, #1a1a1a 100%);
    background-attachment: fixed;
    color: #e0e0e0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
img { max-width: 100%; }

/* --- Typography --- */
h1, h2, h3, h4 {
    color: #fff;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: linear-gradient(135deg, #FFB800, #FF9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Header / Nav --- */
header {
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    color: #FFB800;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
}

.logo img {
    mix-blend-mode: screen;
}

.nav-links {
    display: flex;
    gap: 8px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.25s ease;
}

.nav-links a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-links a[style*="color: #FFB800"],
.nav-links a[style*="color:#FFB800"] {
    background: rgba(255, 184, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links .user-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 14px 5px 5px;
    border-radius: 24px;
    text-decoration: none;
    background: rgba(255, 184, 0, 0.06);
    border: 1px solid rgba(255, 184, 0, 0.15);
    transition: all 0.25s ease;
    cursor: pointer;
}

.nav-links .user-link:hover {
    background: rgba(255, 184, 0, 0.12);
    border-color: rgba(255, 184, 0, 0.35);
}

.nav-links .user-link .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.name-effect-rainbow {
    background: linear-gradient(90deg, #ff5f6d, #ffc371, #47c9ff, #c471ed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 220% 220%;
    animation: usernameRainbowShift 5s ease infinite;
}

.name-effect-glow {
    text-shadow: 0 0 8px rgba(255, 184, 0, 0.75);
}

.nav-links .user-link .user-points {
    color: #FFB800;
    font-weight: 700;
    font-size: 13px;
}

@keyframes usernameRainbowShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 184, 0, 0.4);
    transition: border-color 0.3s ease;
    flex-shrink: 0;
    display: block;
}

.nav-link-icon.user-avatar-wrap {
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.nav-link-icon.user-avatar-wrap .user-avatar {
    display: block;
}

.nav-links .user-link:hover .user-avatar {
    border-color: #FFB800;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.header-section {
    text-align: center;
    margin-bottom: 40px;
}

.header-section h1 {
    font-size: 36px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #FFB800, #FF9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-section p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
}

/* --- Glass Panel --- */
.panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
    transform: translateY(-1px);
}

.panel h2 {
    color: #FFB800;
    margin-bottom: 18px;
    font-size: 22px;
    font-weight: 700;
}

.panel h3 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-bottom: 10px;
}

.panel p {
    line-height: 1.55;
}

/* --- Login Box (Admin Pages) --- */
#loginScreen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 44px;
    text-align: center;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.login-box h1 {
    font-size: 30px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #FFB800, #FF9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-box p {
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 28px;
    font-size: 15px;
}

/* Login form inputs (admin credential auth) */
#loginScreen .form-group { margin-bottom: 0; }
#loginScreen .form-group label {
    display: block; color: rgba(255,255,255,0.5); font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
#loginScreen .form-group input {
    width: 100%; padding: 12px 16px; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff;
    font-size: 14px; font-family: 'Inter', sans-serif; transition: border-color 0.2s;
    box-sizing: border-box;
}
#loginScreen .form-group input:focus { outline: none; border-color: rgba(255,184,0,0.5); }
#loginScreen .form-group input::placeholder { color: rgba(255,255,255,0.25); }
#loginScreen button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(255,184,0,0.3); }
#loginScreen button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error-message {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 14px;
    border-radius: 12px;
    margin-top: 18px;
    display: none;
    font-size: 14px;
}

/* --- Buttons --- */
.btn {
    background: linear-gradient(135deg, #FFB800, #FF9500);
    color: #000;
    border: none;
    padding: 11px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(255, 184, 0, 0.25);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.01em;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 184, 0, 0.35);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-small {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 10px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* --- Forms --- */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 14px;
    color: #fff;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.25s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 184, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 184, 0, 0.08);
    background: rgba(0, 0, 0, 0.42);
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

/* --- Info / Warning / Status Boxes --- */
.info-box {
    background: rgba(255, 184, 0, 0.06);
    border: 1px solid rgba(255, 184, 0, 0.2);
    border-radius: 12px;
    padding: 16px;
    color: #FFD666;
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: inset 0 0 0 1px rgba(255, 184, 0, 0.08);
}

.warning-box {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 16px;
    color: #f87171;
    margin-top: 16px;
    font-size: 14px;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.08);
}

/* --- Overlay Cards --- */
.overlay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.overlay-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.overlay-card:hover {
    border-color: rgba(255, 184, 0, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.overlay-card h3 {
    color: #FFB800;
    margin-bottom: 8px;
    font-size: 16px;
}

.overlay-card p {
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 14px;
    font-size: 13px;
}

.overlay-url {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 10px;
    color: #FFB800;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    word-break: break-all;
    margin-bottom: 12px;
}

/* --- Kick Status Badge --- */
.kick-status {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.kick-status.connected {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

table th {
    text-align: left;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.82);
}

table tr {
    transition: background 0.2s ease;
}

table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.008);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* --- Full-page loading overlay (hides when auth/nav ready) --- */
.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, #0a0a0a 0%, #111 50%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease;
}
.app-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.app-loading-overlay.hidden.removed {
    display: none;
}
.app-loading-overlay .app-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #FFB800;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.app-loading-overlay .app-loading-label {
    position: absolute;
    margin-top: 72px;
    font-size: 13px;
    color: rgba(255,255,255,0.4);
}

/* --- Loading Spinner & Error States --- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
}

.loading-spinner::before {
    content: '';
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #FFB800;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    text-align: center;
}

.error-state::before {
    content: '\26A0';
    font-size: 28px;
    opacity: 0.6;
}

.error-state .retry-btn {
    margin-top: 8px;
    padding: 8px 20px;
    background: rgba(255, 184, 0, 0.15);
    border: 1px solid rgba(255, 184, 0, 0.3);
    color: #FFB800;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.error-state .retry-btn:hover {
    background: rgba(255, 184, 0, 0.25);
}

/* --- Mobile points (next to hamburger) --- */
.nav-mobile-points {
    display: none;
    color: #FFB800;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    margin-right: 10px;
}

/* --- Hamburger Button --- */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    z-index: 201;
    -webkit-tap-highlight-color: transparent;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.open span:nth-child(2) {
    opacity: 0;
}
.hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* --- Mobile Nav Overlay --- */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
}
.nav-overlay.open { display: block; }

/* --- Responsive (generic small-screen) --- */
@media (max-width: 768px) {
    .panel { padding: 20px; }

    .header-section { margin-bottom: 24px; }
    .header-section h1 { font-size: 26px; }
    .header-section p { font-size: 13px; }

    .panel h2 { font-size: 18px; margin-bottom: 14px; }

    .form-row { grid-template-columns: 1fr; }

    .action-bar { flex-direction: column; }
    .action-bar .btn { width: 100%; justify-content: center; }

    table th, table td { padding: 10px 10px; font-size: 13px; }

    .login-box { padding: 28px 20px; }
    .login-box h1 { font-size: 24px; }

    .overlay-grid { grid-template-columns: 1fr; }
    .overlay-url { font-size: 10px; }
}

/* ============================
   Toast Notifications
   ============================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #fff;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease forwards;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.toast:hover {
    opacity: 0.85;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-success {
    background: rgba(16, 185, 129, 0.92);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.toast-error {
    background: rgba(239, 68, 68, 0.92);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.toast-warning {
    background: rgba(245, 158, 11, 0.92);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.toast-info {
    background: rgba(59, 130, 246, 0.92);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

@media (max-width: 768px) {
    .toast-container {
        top: 12px; right: 12px; left: 12px;
    }
    .toast {
        min-width: auto; max-width: none;
    }
}

/* ============================
   Skeleton Loaders
   ============================ */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long { width: 90%; }

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.skeleton-card {
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}

.skeleton-stat {
    height: 48px;
    border-radius: 12px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================
   Update Banner
   ============================ */
#updateBanner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100002;
    background: linear-gradient(135deg, #FFB800, #FF9500);
    color: #000;
    text-align: center;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 12px rgba(255, 184, 0, 0.4);
    transition: transform 0.3s ease;
}

#updateBanner button {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s;
}

#updateBanner button:hover {
    opacity: 0.85;
}

/* ============================
   Connection Error Overlay
   ============================ */
.connection-error-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100003;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 184, 0, 0.3);
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    max-width: 400px;
    color: #e0e0e0;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ============================
   Code User Badge
   Glowing pill shown next to code users on leaderboard / admin
   ============================ */
.code-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(34,211,238,0.2), rgba(56,189,248,0.15));
    border: 1px solid rgba(34,211,238,0.35);
    color: #22d3ee;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1.4;
    box-shadow: 0 0 6px rgba(34,211,238,0.15);
}
.code-badge-lg {
    padding: 2px 8px;
    font-size: 10px;
    box-shadow: 0 0 10px rgba(34,211,238,0.2);
}

/* ============================
   Collapsible Panels
   ============================ */
.panel-collapsible .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    margin: -28px -28px 0;
    padding: 20px 28px;
    border-radius: 16px;
    transition: background 0.2s ease;
}

.panel-collapsible .panel-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.panel-collapsible .panel-header h2 {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-collapse-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.panel-collapsible.collapsed .panel-collapse-icon {
    transform: rotate(-90deg);
}

.panel-collapsible .panel-body {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease, margin-top 0.35s ease;
    max-height: 2000px;
    opacity: 1;
    margin-top: 18px;
}

.panel-collapsible.collapsed .panel-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.panel-collapsible .panel-header-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 500;
}

/* Secondary panel style for config/settings sections */
.panel-secondary {
    background: rgba(255, 255, 255, 0.015);
    border-color: rgba(255, 255, 255, 0.05);
}

.panel-secondary:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.panel-secondary h2 {
    font-size: 18px;
    color: rgba(255, 184, 0, 0.8);
}

@media (max-width: 768px) {
    .panel-collapsible .panel-header {
        margin: -20px -20px 0;
        padding: 16px 20px;
    }
}

/* ============================
   Sidebar App Shell (Public + Admin)
   ============================ */
:root {
    --shell-sidebar-width: 272px;
    --shell-sidebar-collapsed-width: 88px;
    --shell-page-gutter: 28px;
}

body.has-sidebar-shell header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--shell-sidebar-width);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
    padding: 16px;
    overflow-y: auto;
    z-index: 210;
    transition: width 0.24s ease;
}

body.has-sidebar-shell nav.app-sidebar {
    height: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 16px;
}

body.has-sidebar-shell .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

body.has-sidebar-shell .sidebar-collapse-btn,
body.has-sidebar-shell .sidebar-mobile-close,
body.has-sidebar-shell .sidebar-mobile-open {
    font-family: 'Inter', sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.88);
    border-radius: 10px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

body.has-sidebar-shell .sidebar-collapse-btn:hover,
body.has-sidebar-shell .sidebar-mobile-close:hover,
body.has-sidebar-shell .sidebar-mobile-open:hover {
    border-color: rgba(255, 184, 0, 0.45);
    background: rgba(255, 184, 0, 0.13);
    color: #ffcf5d;
}

body.has-sidebar-shell.sidebar-collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
}

body.has-sidebar-shell .nav-link {
    display: flex !important;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}

body.has-sidebar-shell .nav-link.is-active {
    color: #ffcf5d;
    background: rgba(255, 184, 0, 0.12);
}

body.has-sidebar-shell .nav-link-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 6px;
    transition: transform 0.15s ease;
}

body.has-sidebar-shell .nav-link:hover .nav-link-icon {
    transform: scale(1.12);
}

body.has-sidebar-shell .nav-link.is-active .nav-link-icon {
    transform: scale(1.12);
}

body.has-sidebar-shell .nav-link-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.18s ease;
}

body.has-sidebar-shell .sidebar-mobile-open,
body.has-sidebar-shell .sidebar-mobile-close {
    display: none;
}

body.has-sidebar-shell .nav-mobile-points {
    margin: 2px 0 0;
}

body.has-sidebar-shell .nav-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    margin-top: 4px;
    flex: 1;
    min-height: 0;
}

body.has-sidebar-shell .nav-links li {
    width: 100%;
}

body.has-sidebar-shell .nav-links a {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    gap: 10px;
    min-height: 40px;
    box-sizing: border-box;
}

body.has-sidebar-shell .nav-links .user-link {
    width: 100%;
    padding: 10px 12px;
    min-height: 40px;
}

body.has-sidebar-shell #userSection {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.has-sidebar-shell .user-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

body.has-sidebar-shell .user-info .btn {
    flex: 1 1 100%;
    justify-content: center;
}

body.has-sidebar-shell .container {
    max-width: none;
    margin: 30px var(--shell-page-gutter) 30px calc(var(--shell-sidebar-width) + var(--shell-page-gutter));
    padding: 0;
    transition: margin-left 0.24s ease;
}

body.has-sidebar-shell.sidebar-collapsed header {
    width: var(--shell-sidebar-collapsed-width);
}

body.has-sidebar-shell.sidebar-collapsed .logo {
    justify-content: center;
}

body.has-sidebar-shell.sidebar-collapsed .logo img {
    margin-right: 0 !important;
}

body.has-sidebar-shell.sidebar-collapsed .logo {
    font-size: 0;
}

body.has-sidebar-shell.sidebar-collapsed .nav-link {
    justify-content: center;
    gap: 0;
}

body.has-sidebar-shell.sidebar-collapsed .nav-link-text,
body.has-sidebar-shell.sidebar-collapsed #userName,
body.has-sidebar-shell.sidebar-collapsed #userRole,
body.has-sidebar-shell.sidebar-collapsed .user-name,
body.has-sidebar-shell.sidebar-collapsed .user-points {
    display: none;
}

body.has-sidebar-shell.sidebar-collapsed .nav-links .user-link {
    justify-content: center;
}

body.has-sidebar-shell.sidebar-collapsed .user-info {
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
}

body.has-sidebar-shell.sidebar-collapsed .user-info .btn {
    flex: 0 0 auto;
}

/* Button styled as nav-link (View Site / Sign Out in admin; Sign Out in public) */
body.has-sidebar-shell .nav-link-as-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    padding: 10px 12px;
    border-radius: 8px;
}

body.has-sidebar-shell .nav-link-as-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* Public nav: profile + sign out stacked */
body.has-sidebar-shell .user-section-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

body.has-sidebar-shell .user-section-inner .user-link {
    width: 100%;
}

body.has-sidebar-shell .user-section-inner .nav-link-as-btn {
    width: 100%;
}

/* Admin user row: avatar + name (View Site / Sign Out are separate nav rows) */
body.has-sidebar-shell .admin-nav-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    width: 100%;
}

body.has-sidebar-shell.sidebar-collapsed .admin-user-row .admin-nav-user-info {
    justify-content: center;
    padding: 10px 12px;
}

body.has-sidebar-shell.sidebar-collapsed .admin-user-row #userName,
body.has-sidebar-shell.sidebar-collapsed .admin-user-row #userRole {
    display: none;
}

/* Sidebar action buttons (legacy / other use) */
body.has-sidebar-shell .sidebar-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

body.has-sidebar-shell .sidebar-action-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    display: none;
}

body.has-sidebar-shell.sidebar-collapsed .sidebar-action-btn {
    width: 26px;
    min-width: 26px;
    height: 26px;
    padding: 0;
    flex: 0 0 auto;
    border-radius: 8px;
}

body.has-sidebar-shell.sidebar-collapsed .sidebar-action-label {
    display: none;
}

body.has-sidebar-shell.sidebar-collapsed .sidebar-action-icon {
    display: inline-flex;
    font-size: 14px;
}

body.has-sidebar-shell.sidebar-collapsed .container {
    margin-left: calc(var(--shell-sidebar-collapsed-width) + var(--shell-page-gutter));
}

/* ============================
   Mobile Sidebar (<= 900px)
   Single consolidated block — all mobile overrides in one place.
   Uses !important liberally to beat desktop collapsed-state rules.
   ============================ */
.app-sidebar-overlay {
    display: none;
}

button.sidebar-mobile-open {
    display: none;
}

@media (max-width: 900px) {
    /* --- Lock body scroll when drawer is open --- */
    body.has-sidebar-shell.sidebar-mobile-open {
        overflow: hidden !important;
    }

    /* --- Sidebar drawer (off-screen left by default) --- */
    body.has-sidebar-shell header,
    body.has-sidebar-shell.sidebar-collapsed header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: min(84vw, 300px) !important;
        transform: translateX(-100%) !important;
        transition: transform 0.25s ease !important;
        background: #0c0c12 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        z-index: 210 !important;
        padding: 16px !important;
        overflow-y: auto !important;
        border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    /* --- Slide drawer in when open --- */
    body.has-sidebar-shell.sidebar-mobile-open header,
    body.has-sidebar-shell.sidebar-collapsed.sidebar-mobile-open header {
        transform: translateX(0) !important;
    }

    /* --- Hide desktop collapse button, show close button --- */
    body.has-sidebar-shell .sidebar-collapse-btn,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-collapse-btn {
        display: none !important;
    }

    body.has-sidebar-shell .sidebar-mobile-close,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-mobile-close {
        display: inline-flex !important;
    }

    /* --- Content area — no sidebar offset on mobile --- */
    body.has-sidebar-shell .container,
    body.has-sidebar-shell.sidebar-collapsed .container {
        margin: 56px 16px 24px 16px !important;
        padding: 0 !important;
    }

    /* --- Force full expanded layout in mobile drawer (undo collapsed state) --- */
    body.has-sidebar-shell .logo,
    body.has-sidebar-shell.sidebar-collapsed .logo {
        font-size: inherit !important;
        justify-content: flex-start !important;
    }

    body.has-sidebar-shell .logo img,
    body.has-sidebar-shell.sidebar-collapsed .logo img {
        margin-right: 8px !important;
    }

    body.has-sidebar-shell .nav-links,
    body.has-sidebar-shell.sidebar-collapsed .nav-links {
        display: flex !important;
        flex-direction: column !important;
    }

    body.has-sidebar-shell .nav-link-text,
    body.has-sidebar-shell.sidebar-collapsed .nav-link-text {
        display: inline !important;
    }

    body.has-sidebar-shell .nav-link,
    body.has-sidebar-shell.sidebar-collapsed .nav-link {
        justify-content: flex-start !important;
        gap: 10px !important;
    }

    body.has-sidebar-shell.sidebar-collapsed #userName,
    body.has-sidebar-shell.sidebar-collapsed #userRole,
    body.has-sidebar-shell.sidebar-collapsed .user-name,
    body.has-sidebar-shell.sidebar-collapsed .user-points {
        display: inline !important;
    }

    /* --- Action buttons: full width labels, no icons --- */
    body.has-sidebar-shell .sidebar-action-label,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-action-label {
        display: inline !important;
    }

    body.has-sidebar-shell .sidebar-action-icon,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-action-icon {
        display: none !important;
    }

    body.has-sidebar-shell .sidebar-action-btn,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-action-btn {
        width: auto !important;
        min-width: unset !important;
        height: auto !important;
        padding: 8px 14px !important;
        flex: 1 1 100% !important;
        border-radius: 8px !important;
    }

    /* --- User info section --- */
    body.has-sidebar-shell .user-info,
    body.has-sidebar-shell.sidebar-collapsed .user-info {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        padding-top: 16px !important;
        margin-top: 8px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    body.has-sidebar-shell .user-info .btn,
    body.has-sidebar-shell.sidebar-collapsed .user-info .btn {
        width: 100% !important;
        flex: 1 1 100% !important;
        justify-content: center !important;
    }

    body.has-sidebar-shell .nav-links .user-link {
        padding: 10px 14px;
        border-radius: 10px;
        margin-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    /* --- Mobile points badge --- */
    body.has-sidebar-shell .nav-mobile-points {
        display: inline-block !important;
    }

    body.has-sidebar-shell .nav-mobile-points:empty {
        display: none !important;
    }

    /* --- Hamburger open button (lives on body, outside header) --- */
    body.has-sidebar-shell .sidebar-mobile-open,
    body.has-sidebar-shell.sidebar-collapsed .sidebar-mobile-open {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        z-index: 220 !important;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        border-radius: 10px !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
        background: rgba(12, 12, 18, 0.92) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        cursor: pointer !important;
    }

    /* Hide hamburger when drawer is open */
    body.has-sidebar-shell.sidebar-mobile-open .sidebar-mobile-open {
        display: none !important;
    }

    /* --- Overlay (lives on body, outside header) --- */
    body.has-sidebar-shell .app-sidebar-overlay,
    body.has-sidebar-shell.sidebar-collapsed .app-sidebar-overlay {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.55) !important;
        z-index: 205 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.25s ease !important;
    }

    body.has-sidebar-shell.sidebar-mobile-open .app-sidebar-overlay {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Hamburger icon */
.mobile-hamburger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 18px;
    height: 18px;
}

.mobile-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 1px;
    transition: background 0.2s ease;
}
