
body {
    --admin-topbar-height: 64px;
    --admin-sidebar-width: 288px;
    --admin-sidebar-collapsed-width: 80px;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 16% -10%, rgba(13, 110, 253, 0.10), transparent 32rem),
        linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
    color: #182230;
}

.admin-frame {
    padding-top: var(--admin-topbar-height);
}

.admin-brand-logo,
.admin-user-avatar {
    width: 42px;
    height: 42px;
    object-fit: cover;
}

.admin-user-name {
    margin-left: 20px;
    cursor: default;
}

.global-toast-stack {
    z-index: 1060;
}

/* Sidebar Styles */
.sidebar {
    width: var(--admin-sidebar-width);
    transition: all 0.25s ease;
    z-index: 1000;
    height: calc(100vh - var(--admin-topbar-height));
    top: var(--admin-topbar-height);
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    overflow-y: auto;
}
.sidebar .nav-link[data-page] {
    cursor: pointer;
}
.sidebar.collapsed {
    width: var(--admin-sidebar-collapsed-width);
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 0.9rem;
    color: #475467;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 10px !important;
    font-weight: 600;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.sidebar .nav-link:hover {
    background-color: #f2f6fc;
    color: #0d6efd;
}
.sidebar .nav-link.active {
    background: linear-gradient(135deg, #0d6efd 0%, #0f766e 100%);
    color: white;
    box-shadow: 0 10px 22px rgba(13, 110, 253, 0.22);
}
.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    flex: 0 0 20px;
}
.sidebar .navbar-text {
    display: block;
    margin: 1.15rem 0 0.45rem;
    padding: 0 0.9rem;
    color: #8a94a6;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.8rem 0;
}
.sidebar.collapsed .nav-link span {
    display: none;
}
.sidebar.collapsed .nav-link i {
    margin-right: 0;
}
.sidebar.collapsed .brand-name,
.sidebar.collapsed .navbar-text {
    display: none;
}
/* When collapsed AND hovered, expand back to 300px */
.sidebar.collapsed:hover {
    width: var(--admin-sidebar-width);
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.12);
}
.sidebar.collapsed:hover .nav-link {
    justify-content: flex-start;
    padding: 0.8rem 1rem;
}

/* Ensure text and brand name reappear on hover */
.sidebar.collapsed:hover .nav-link span,
.sidebar.collapsed:hover .brand-name,
.sidebar.collapsed:hover .navbar-text {
    display: inline-block !important;
}

/* Fix icon alignment during hover-expansion */
.sidebar.collapsed:hover .nav-link i {
    margin-right: 10px;
}

/* Keep the main content margin at 80px even when sidebar 'peeks' */
/* This prevents the whole page from shaking/jumping while hovering */
.sidebar.collapsed ~ .main-content {
    margin-left: var(--admin-sidebar-collapsed-width) !important;
}

/* Top Bar Styles */
.top-bar {
    height: var(--admin-topbar-height);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(14px);
    z-index: 1001;
}
.top-bar .brand-name {
    color: #101828;
    font-size: clamp(1rem, 1.6vw, 1.25rem) !important;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0;
}
.top-bar .dropdown-toggle {
    border: 1px solid transparent;
    border-radius: 999px;
}
.top-bar .dropdown-toggle:hover,
.top-bar .dropdown-toggle:focus {
    background: #f2f6fc;
    border-color: #d7dee9;
}
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.7rem;
}

/* Main Content */
.main-content {
    margin-left: var(--admin-sidebar-width);
    padding-top: 1.25rem !important;
    min-width: 0;
    transition: margin-left 0.25s ease-in-out;
}
.main-content.expanded {
    margin-left: var(--admin-sidebar-collapsed-width);
}
#mainContent.fade {
    transition: opacity 0.1s linear;
    opacity: 0;
}
#mainContent.fade.show {
    opacity: 1;
}


/* Loading Indicator */
#loading {
    position: fixed;
    top: 78px;
    right: 20px;
    z-index: 1050;
    transition: opacity 0.1s linear;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

/* Dropdown Menu */
.notification-dropdown {
    width: 300px;
}
.user-dropdown {
    width: 200px;
}

.dropdown-menu,
.modal-content,
.card {
    border-color: rgba(148, 163, 184, 0.22);
}

.card {
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.admin-page-shell {
    max-width: 1600px;
    margin: 0 auto;
}

.admin-page-card {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.45rem 1.55rem;
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 35%),
        radial-gradient(circle at left center, rgba(37, 99, 235, 0.12), transparent 30%),
        #ffffff;
    border: 1px solid rgba(217, 226, 236, 0.85);
    border-radius: 18px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.admin-page-title {
    color: #101828;
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: 0;
    margin: 0;
}

.admin-page-subtitle {
    color: #667085;
    margin: 0.35rem 0 0;
    max-width: 820px;
}

.admin-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
}

.admin-page-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.48rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: #ffffff;
    color: #475467;
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}


.admin-page-body {
    padding: 1.25rem 0 0;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid rgba(217, 226, 236, 0.90);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.admin-toolbar-label {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-right: 0.15rem;
}

.admin-toolbar .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 38px;
}

.admin-stat-card {
    height: 100%;
    border: 0;
    color: #fff;
    background: linear-gradient(135deg, #0d6efd 0%, #0f766e 100%);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.admin-stat-card.stat-participant, .admin-stat-card.stat-competition {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.28), transparent 38%),
        linear-gradient(135deg, #2563eb 0%, #0f766e 100%);
}

.admin-stat-card.stat-team, .admin-stat-card.stat-contingent {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 38%),
        linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
}

.admin-stat-card.stat-couple, .admin-stat-card.stat-users {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 38%),
        linear-gradient(135deg, #db2777 0%, #7c3aed 100%);
}

.admin-stat-card.stat-ring {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.26), transparent 38%),
        linear-gradient(135deg, #0f766e 0%, #22c55e 100%);
}

.admin-stat-card.stat-umpire {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.26), transparent 38%),
        linear-gradient(135deg, #b45309 0%, #ef4444 100%);
}

.admin-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    margin-bottom: 0.8rem;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.3rem;
}

.admin-dashboard-section {
    border: 1px solid rgba(217, 226, 236, 0.90);
    border-radius: 18px;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}

.admin-stat-card .card-title {
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.88;
}

.admin-stat-card .display-4 {
    font-weight: 750;
    line-height: 1;
}

.admin-dashboard-meta {
    color: #475467;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.4rem;
    margin-top: 0.75rem;
}

.admin-dashboard-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn {
    border-radius: 9px;
    font-weight: 600;
}

.btn-outline-primary {
    border-color: #b9cdfb;
}

.form-control,
.form-select,
.input-group-text,
.ts-wrapper .ts-control {
    border-radius: 9px;
}

.modal-content {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 72px rgba(15, 23, 42, 0.24);
}

.modal-header {
    background: #f8fafc;
    border-bottom-color: rgba(148, 163, 184, 0.20);
}

.modal-footer {
    background: #fbfcfe;
    border-top-color: rgba(148, 163, 184, 0.20);
}

.tabulator {
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.tabulator .tabulator-header {
    background: #f8fafc;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
    color: #344054;
    font-weight: 700;
}

.tabulator .tabulator-row {
    border-bottom-color: rgba(148, 163, 184, 0.18);
}

.tabulator .tabulator-row.tabulator-row-even {
    background-color: #fbfdff;
}

.tabulator .tabulator-row:hover {
    background-color: #f0f6ff;
}

.tabulator .tabulator-footer {
    background: #fbfcfe;
    border-top-color: rgba(148, 163, 184, 0.24);
}

.table-surface,
#viewerCanvas {
    min-height: 220px;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    min-height: 38px;
    display: flex;
    align-items: center;
}

.participant-cell {
    cursor: pointer;
    border-left: 10px solid transparent;
}

.participant-cell--male {
    border-left-color: #00bfff;
}

.participant-cell--female {
    border-left-color: #ffb6c1;
}

.participant-cell-summary {
    line-height: 1;
}

#resultPage,
#medalPage {
    --result-ink: #183153;
    --result-muted: #64748b;
    --result-line: #d9e2ec;
    --result-soft: linear-gradient(135deg, #f7fbff 0%, #eef6ff 100%);
    --result-accent: #0f766e;
    --result-warning: #b45309;
}

#resultPage .result-shell,
#medalPage .result-shell {
    border: 0;
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

#resultPage .result-hero,
#medalPage .result-hero {
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 35%),
        radial-gradient(circle at left center, rgba(37, 99, 235, 0.12), transparent 28%),
        #ffffff;
    border-bottom: 1px solid rgba(217, 226, 236, 0.85);
    padding: 1.5rem;
}

#resultPage .result-hero h1,
#medalPage .result-hero h1 {
    color: var(--result-ink);
    font-weight: 700;
    letter-spacing: -0.03em;
}

#resultPage .result-lead,
#medalPage .result-lead {
    color: var(--result-muted);
    max-width: 760px;
    margin-bottom: 0;
}

#resultPage .result-kpi,
#medalPage .result-kpi {
    border: 1px solid var(--result-line);
    border-radius: 18px;
    background: var(--result-soft);
    padding: 1rem 1.1rem;
    height: 100%;
}

#resultPage .result-kpi-label,
#medalPage .result-kpi-label {
    display: block;
    color: var(--result-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

#resultPage .result-kpi-value,
#medalPage .result-kpi-value {
    color: var(--result-ink);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}

#resultPage .result-toolbar,
#medalPage .result-toolbar {
    padding: 1.25rem 1.5rem 0;
}

#resultPage .result-panel,
#medalPage .result-panel {
    border: 1px solid var(--result-line);
    border-radius: 18px;
    background: #fff;
    padding: 1rem;
    height: 100%;
}

#resultPage .result-panel-title,
#medalPage .result-panel-title {
    color: var(--result-ink);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

#resultPage .result-panel-copy,
#medalPage .result-panel-copy {
    color: var(--result-muted);
    margin-bottom: 0;
}

#resultPage .result-status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: #eef2ff;
    color: #4338ca;
}

#resultPage .result-status-pill.pending {
    background: #fff7ed;
    color: var(--result-warning);
}

#resultPage .result-status-pill.completed {
    background: #ecfdf5;
    color: var(--result-accent);
}

#resultPage .result-status-pill.waiting {
    background: #eff6ff;
    color: #1d4ed8;
}

#resultPage .result-table-wrap,
#medalPage .result-table-wrap {
    padding: 1.25rem 1.5rem 1.5rem;
}

#resultPage .result-subtext {
    color: var(--result-muted);
    font-size: 0.86rem;
}

#resultPage .result-competitor {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

#resultPage .result-lane {
    width: 0.8rem;
    height: 2.4rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

#resultPage .result-lane.red {
    background: linear-gradient(180deg, #ef4444 0%, #fca5a5 100%);
}

#resultPage .result-lane.blue {
    background: linear-gradient(180deg, #2563eb 0%, #93c5fd 100%);
}

#resultPage .result-score {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--result-ink);
}

#resultPage .result-score.tie {
    color: var(--result-warning);
}

#resultPage .tabulator,
#medalPage .tabulator {
    border: 1px solid var(--result-line);
    border-radius: 18px;
    overflow: hidden;
}

#resultPage .tabulator .tabulator-header,
#medalPage .tabulator .tabulator-header {
    border-bottom: 1px solid var(--result-line);
    background: #f8fafc;
}

#resultMatchContext {
    border: 1px solid var(--result-line);
    border-radius: 16px;
    background: var(--result-soft);
    padding: 1rem;
}

@media (max-width: 991.98px) {
    .top-bar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .admin-brand-logo {
        width: 34px;
        height: 34px;
    }

    .top-bar .brand-name {
        max-width: 48vw;
        text-align: center;
    }

    .sidebar {
        width: var(--admin-sidebar-collapsed-width);
    }

    .sidebar .nav-link {
        justify-content: center;
        padding: 0.75rem 0;
    }

    .sidebar .nav-link span,
    .sidebar .navbar-text {
        display: none;
    }

    .main-content {
        margin-left: var(--admin-sidebar-collapsed-width);
        padding: 1rem !important;
        padding-top: 1rem !important;
    }

    .admin-page-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #resultPage .result-hero,
    #medalPage .result-hero,
    #resultPage .result-toolbar,
    #medalPage .result-toolbar,
    #resultPage .result-table-wrap,
    #medalPage .result-table-wrap {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 575.98px) {
    .top-bar .brand-name {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
        width: var(--admin-sidebar-width);
    }

    .sidebar.collapsed,
    .sidebar:not(.collapsed) {
        transform: translateX(-100%);
    }

    .sidebar.collapsed:hover,
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.mobile-open .nav-link {
        justify-content: flex-start;
        padding: 0.8rem 1rem;
    }

    .sidebar.mobile-open .nav-link span,
    .sidebar.mobile-open .navbar-text {
        display: inline-block;
    }

    .main-content,
    .main-content.expanded {
        margin-left: 0 !important;
    }

    .admin-page-header {
        display: block;
    }

    .admin-page-body {
        padding-top: 1rem;
    }

    .admin-toolbar {
        align-items: stretch;
    }

    .admin-toolbar .btn {
        flex: 1 1 100%;
    }
}
