/* SunCity Battle — macOS Settings-Inspired Dark Theme */
:root {
    --bb-bg: #1a1d23;
    --bb-card: #22262d;
    --bb-primary: #0d6efd;
    --bb-primary-soft: rgba(13, 110, 253, 0.15);
    --bb-text: #e0e2e6;
    --bb-text-secondary: #9ca3af;
    --bb-border: #2d3238;
    --bb-border-soft: rgba(255,255,255,0.06);
    --bb-muted: #6b7280;
    --bb-sidebar-w: 260px;
    --bb-sidebar-collapsed-w: 56px;
    --bb-sidebar-bg: #1e2127;
    --bb-hover: rgba(255,255,255,0.04);
    --bb-active: rgba(13, 110, 253, 0.18);
    --bb-radius: 8px;
    --bb-radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bb-bg);
    color: var(--bb-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    margin: 0;
}

/* ===== NAVBAR ===== */
.bb-navbar {
    background: var(--bb-sidebar-bg);
    border-bottom: 1px solid var(--bb-border);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.bb-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--bb-primary) !important;
}

/* ===== ADMIN LAYOUT — Flexbox ===== */
.bb-admin-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

/* ===== SIDEBAR (macOS System Settings style) ===== */
.bb-sidebar {
    width: var(--bb-sidebar-w);
    min-width: var(--bb-sidebar-w);
    background: var(--bb-sidebar-bg);
    border-right: 1px solid var(--bb-border);
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--bb-border) transparent;
}
.bb-sidebar::-webkit-scrollbar { width: 4px; }
.bb-sidebar::-webkit-scrollbar-thumb { background: var(--bb-border); border-radius: 2px; }

/* Sidebar items — macOS pill-shaped */
.bb-sidebar .list-group-item {
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: var(--bb-radius-sm);
    margin: 1px 8px;
    transition: background 0.15s ease;
}
.bb-sidebar .list-group-item i {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0.8;
}
.bb-sidebar .list-group-item:hover {
    background: var(--bb-hover) !important;
}
.bb-sidebar .list-group-item.active {
    background: var(--bb-active) !important;
    color: #69b3ff !important;
    font-weight: 600;
}
.bb-sidebar .list-group-item.active i {
    opacity: 1;
    color: #69b3ff;
}

/* Sidebar section headers (macOS-style) */
.bb-sidebar-section {
    padding: 1.1rem 1.1rem 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: var(--bb-muted);
    white-space: nowrap;
    overflow: hidden;
}
.bb-sidebar-section:first-child { padding-top: 0.6rem; }

/* Event name in sidebar */
.bb-sidebar-event-name {
    padding: 0.6rem 1.1rem 0.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--bb-text);
    border-bottom: 1px solid var(--bb-border-soft);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Back link */
.bb-sidebar-back {
    font-size: 0.8rem !important;
    padding: 0.65rem 1.1rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--bb-border-soft) !important;
    color: var(--bb-text-secondary) !important;
}
.bb-sidebar-back:hover {
    color: var(--bb-text) !important;
    background: var(--bb-hover) !important;
}

/* Collapse button */
.bb-sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--bb-muted);
    width: 100%;
    padding: 0.35rem 1rem;
    text-align: right;
    cursor: pointer;
    font-size: 0.85rem;
}
.bb-sidebar-collapse-btn:hover { color: var(--bb-text); }

/* Collapsed state */
.bb-sidebar.collapsed {
    width: var(--bb-sidebar-collapsed-w);
    min-width: var(--bb-sidebar-collapsed-w);
}
.bb-sidebar.collapsed .bb-sidebar-text { display: none; }
.bb-sidebar.collapsed .bb-sidebar-section { display: none; }
.bb-sidebar.collapsed .bb-sidebar-event-name span { display: none; }
.bb-sidebar.collapsed .bb-sidebar-back span { display: none; }
.bb-sidebar.collapsed .list-group-item {
    justify-content: center;
    padding: 0.55rem 0;
    margin: 1px 4px;
}
.bb-sidebar.collapsed .list-group-item i { width: auto; font-size: 1.1rem; }
.bb-sidebar.collapsed .bb-sidebar-collapse-btn { text-align: center; padding: 0.35rem 0; }

/* ===== MAIN CONTENT ===== */
.bb-admin-main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2rem;
    overflow-x: hidden;
}

/* Event header (replaces old pill nav) */
.bb-event-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

/* ===== HERO ===== */
.bb-hero-title { font-size: 2.5rem; font-weight: 700; }

/* ===== CARDS (softer, cleaner) ===== */
.bb-card {
    background: var(--bb-card);
    border: 1px solid var(--bb-border-soft);
    border-radius: var(--bb-radius);
}
.bb-card .card-body { padding: 1.25rem; }
.bb-card .card-header {
    padding: 0.85rem 1.25rem;
    background: transparent;
    border-bottom: 1px solid var(--bb-border-soft);
}
.bb-card .card-header h5 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--bb-text);
}

/* Card header override */
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bb-border-soft);
}

/* ===== BUTTONS ===== */
.bb-btn { background: var(--bb-primary); border: none; font-weight: 600; }
.btn-xs { padding: 2px 6px; font-size: 0.75rem; }
.btn { border-radius: var(--bb-radius-sm); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.825rem; }
.btn-outline-primary, .btn-outline-danger, .btn-outline-info,
.btn-outline-success, .btn-outline-warning, .btn-outline-secondary {
    border-width: 1px;
}

/* ===== FORMS ===== */
.form-control, .form-select {
    background: #282c34;
    border-color: var(--bb-border);
    color: var(--bb-text);
    border-radius: var(--bb-radius-sm);
}
.form-control:focus, .form-select:focus {
    background: #282c34;
    border-color: var(--bb-primary);
    color: var(--bb-text);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
}
.form-label { font-size: 0.85rem; margin-bottom: 0.35rem; color: var(--bb-text-secondary); font-weight: 500; }

/* ===== TABLES (cleaner) ===== */
.table { font-size: 0.875rem; }
.table td, .table th { padding: 0.65rem 0.85rem; vertical-align: middle; }
.table-dark { --bs-table-bg: transparent; }
.table > thead > tr > th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bb-text-secondary);
    border-bottom: 1px solid var(--bb-border);
}
.table > tbody > tr > td {
    border-bottom: 1px solid var(--bb-border-soft);
}
.table > tbody > tr:last-child > td { border-bottom: none; }
.table-hover > tbody > tr:hover > td {
    background: var(--bb-hover);
}

/* ===== STATUS BADGES ===== */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.3em 0.6em;
    border-radius: 4px;
}
.bb-status-draft { background: #4b5563; }
.bb-status-registration { background: #2563eb; }
.bb-status-running { background: #dc2626; }
.bb-status-finished { background: #16a34a; }
.bb-status-archived { background: #4b5563; }
.bb-status-pending { background: #4b5563; }
.bb-status-live { background: #dc2626; }
.bb-status-active { background: #ea580c; }
.bb-status-completed { background: #16a34a; }
.bb-status-approved { background: #16a34a; }
.bb-status-rejected { background: #dc2626; }
.bb-status-withdrawn { background: #4b5563; }
.bb-status-waitlist { background: #ea580c; }
.bb-status-bye { background: #4b5563; }

/* ===== NAV PILLS (if still used anywhere) ===== */
.nav-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
}
.nav-pills::-webkit-scrollbar { display: none; }
.nav-pills .nav-item { flex-shrink: 0; }
.nav-pills .nav-link {
    color: var(--bb-text-secondary);
    border-radius: var(--bb-radius-sm);
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
    transition: background 0.15s;
}
.nav-pills .nav-link:hover { background: var(--bb-hover); color: var(--bb-text); }
.nav-pills .nav-link.active { background: var(--bb-primary); color: #fff; }

/* ===== BRACKET ===== */
.bb-bracket-container {
    overflow-x: auto;
    padding: 20px;
    background: var(--bb-bg);
    border-radius: var(--bb-radius);
    border: 1px solid var(--bb-border-soft);
}
.bb-bracket-svg { width: 100%; height: auto; min-height: 300px; }

/* ===== VOTE BUTTONS ===== */
.vote-btn { min-height: 80px; min-width: 48px; touch-action: manipulation; }

/* ===== MODAL ===== */
.modal-content {
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius);
    background: var(--bb-card);
}

/* ===== FOOTER ===== */
.bb-footer { border-top: 1px solid var(--bb-border-soft); }

/* ===== LIST GROUP (sidebar-compatible) ===== */
.list-group-item-action:focus,
.list-group-item-action:active {
    background: var(--bb-hover) !important;
    color: var(--bb-text) !important;
}

/* ===== ALERTS ===== */
.alert { border-radius: var(--bb-radius-sm); font-size: 0.9rem; }

/* ===== MOBILE SIDEBAR ===== */
.bb-mobile-sidebar-bar {
    background: var(--bb-sidebar-bg);
    border-bottom: 1px solid var(--bb-border);
    padding: 0.5rem 1rem;
}
.bb-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}
.bb-sidebar-overlay.open { display: block; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bb-bg); }
::-webkit-scrollbar-thumb { background: var(--bb-border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 991.98px) {
    .bb-admin-main { padding: 1.25rem; }
    .nav-pills .nav-link { font-size: 0.8rem; padding: 0.35rem 0.6rem; }
    .bb-hero-title { font-size: 2rem; }
}

/* Mobile */
@media (max-width: 767.98px) {
    .bb-admin-layout { display: block; }
    .bb-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        z-index: 1040;
        padding-top: 0.75rem;
        box-shadow: 4px 0 24px rgba(0,0,0,0.6);
    }
    .bb-sidebar.open { display: block !important; }
    .bb-sidebar.collapsed { width: 280px; min-width: 280px; }
    .bb-sidebar.collapsed .bb-sidebar-text { display: inline; }
    .bb-sidebar.collapsed .bb-sidebar-section { display: block; }
    .bb-sidebar.collapsed .list-group-item { justify-content: flex-start; padding: 0.5rem 0.85rem; margin: 1px 8px; }
    .bb-admin-main { padding: 1rem; }
    .bb-hero-title { font-size: 1.75rem; }
    .table-responsive { font-size: 0.85rem; }
    .bb-card .card-body { padding: 0.85rem; }
}

@media (min-width: 768px) {
    .bb-mobile-sidebar-bar { display: none; }
}

/* Small phones */
@media (max-width: 575.98px) {
    .bb-admin-main { padding: 0.75rem; }
    .nav-pills .nav-link { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
}
