/* tournament_admin admin panel styles
 *
 * Phase 0 of docs/planning/tournament-admin-polish.md — extracted from
 * base.html's inline <style> block, with a flatter palette (less gradient
 * soup) and a tighter radius / spacing scale.
 *
 * Component-specific styles live with their templates; this file is the
 * shared layout + design-token layer.
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.08);

    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0ea5e9;

    --sidebar-bg: #1e293b;
    --sidebar-bg-end: #0f172a;
    --sidebar-hover: #334155;
    --sidebar-text: #cbd5e1;
    --sidebar-text-strong: #ffffff;
    --sidebar-border: #334155;

    --body-bg: #f5f7fa;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;

    --radius-md: 0.5rem;   /* inputs, buttons, badges */
    --radius-lg: 0.75rem;  /* cards */

    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);

    --sidebar-width: 220px;
}

body {
    background-color: var(--body-bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-end) 100%);
    border-right: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand h4 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    margin: 0.2rem 0.5rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-weight: 500;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover {
    color: var(--sidebar-text-strong);
    background-color: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: var(--sidebar-text-strong);
    background-color: var(--primary);
}

.sidebar-divider {
    margin: 0.75rem 0.5rem;
    border-top: 1px solid var(--sidebar-border);
    padding-top: 0.75rem;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: var(--sidebar-bg); }
.sidebar::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Mobile nav strip */
.mobile-nav {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    z-index: 1001;
    padding: 0.5rem 0.75rem;
}

.mobile-nav .mobile-nav-title {
    color: var(--sidebar-text-strong);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text-strong);
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
}

.sidebar-toggle:hover { background-color: rgba(255, 255, 255, 0.08); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* Main content area */
.main-content {
    flex: 1;
    min-width: 0; /* allow flex child to shrink so tables can overflow-scroll */
    background-color: var(--body-bg);
    display: flex;
    flex-direction: column;
}

.main-content > .container-fluid {
    flex: 1;
}

/* Mobile: drawer-style sidebar */
@media (max-width: 767.98px) {
    .admin-layout { display: block; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { width: 100%; }
}

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

/* ------------------------------------------------------------------ */
/* Page header (sticky on scroll, modern type)                         */
/* ------------------------------------------------------------------ */

.page-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--body-bg);
    padding: 1rem 0 0.875rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0 0 0.125rem;
}

.page-header p { font-size: 0.875rem; margin: 0; color: var(--text-muted); }

/* On mobile, the global mobile-nav strip is sticky at top; offset the
 * page header so it doesn't slide under it.
 */
@media (max-width: 767.98px) {
    .page-header {
        position: static;
        padding: 0.75rem 0 0.5rem;
        margin-bottom: 1rem;
    }
    .page-header h1 { font-size: 1.25rem; }
}

/* ------------------------------------------------------------------ */
/* Cards, buttons, forms — flattened (no gradients on commodity UI)    */
/* ------------------------------------------------------------------ */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    font-weight: 600;
    padding: 0.875rem 1.25rem;
}

.card-body { padding: 1.25rem; }

/* Stat cards keep colour — they're meant to pop */
.stat-card {
    background-color: var(--primary);
    border: none;
    color: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}
.stat-card.success { background-color: var(--success); }
.stat-card.warning { background-color: var(--warning); }
.stat-card.info    { background-color: var(--info); }

.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); color: #fff; }

.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

.table { color: var(--text); margin-bottom: 0; }

.table thead th {
    background-color: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.table tbody tr:hover { background-color: var(--surface-muted); }

/* ------------------------------------------------------------------ */
/* Toast container                                                     */
/* ------------------------------------------------------------------ */

.toast-container {
    z-index: 1080;
    pointer-events: none;
}
.toast-container .toast { pointer-events: auto; }

/* ------------------------------------------------------------------ */
/* Drift banner — sticky strip at top of main content                  */
/* ------------------------------------------------------------------ */

.drift-banner {
    border-radius: var(--radius-lg);
    border: 1px solid #facc15;
    background-color: #fffbeb;
    color: #713f12;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.drift-banner strong { color: #713f12; }

.drift-banner .btn-warning {
    background-color: #f59e0b;
    border-color: #f59e0b;
    color: #1f2937;
    font-weight: 600;
}
.drift-banner .btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
}

/* ------------------------------------------------------------------ */
/* Empty state                                                          */
/* ------------------------------------------------------------------ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state .empty-state-icon {
    font-size: 2.75rem;
    opacity: 0.45;
    margin-bottom: 1rem;
    display: block;
    color: var(--text-muted);
}

.empty-state h5 {
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state .btn { margin-top: 1rem; }

/* ------------------------------------------------------------------ */
/* Misc tweaks                                                          */
/* ------------------------------------------------------------------ */

code {
    background-color: var(--surface-muted);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-md);
    font-size: 0.875em;
    color: var(--text);
}

footer.admin-footer {
    margin-top: auto;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

@media (max-width: 767.98px) {
    .card { margin-bottom: 0.75rem; }
    .table-responsive { border-radius: var(--radius-md); }
    .btn-group { width: 100%; }
    .btn-group .btn { flex: 1; }

    /* Tap-target floor on mobile: nav + primary buttons hit ~44px height. */
    .sidebar .nav-link {
        padding: 0.875rem 1rem;
    }
    .sidebar-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    .btn:not(.btn-sm):not(.btn-link):not(.btn-close) {
        min-height: 44px;
    }
    /* Keep form controls reachable for fat fingers. */
    .form-control, .form-select {
        min-height: 44px;
    }
    /* Empty-state CTAs sit below 44px because of btn-default sizing — tighten. */
    .empty-state .btn { padding: 0.625rem 1.25rem; }

    /* Toast close button — Bootstrap default is 16x16; bump for mobile. */
    .toast-container .btn-close {
        padding: 0.875rem;
    }
}
