/* SD Glitch brand font */
@font-face {
    font-family: 'SD Glitch';
    src: url('/static/fonts/gpro-brand.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* Color palette — matches GPro */
:root {
    --bs-primary: #2F055A;
    --bs-primary-rgb: 47, 5, 90;
    --bs-info: #5a7a8a;
    --bs-info-rgb: 90, 122, 138;
    --bs-success: #5a8a6e;
    --bs-success-rgb: 90, 138, 110;
    --bs-warning: #c9a87c;
    --bs-warning-rgb: 201, 168, 124;
    --bs-danger: #a85a6e;
    --bs-danger-rgb: 168, 90, 110;

    --purple-glow: rgba(47, 5, 90, 0.15);
    --purple-tint: rgba(47, 5, 90, 0.04);
    --transition-smooth: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Avenir', 'Nunito', sans-serif;
    background-color: #f4f0f8;
}

/* Brand logo */
.brand-logo {
    font-family: 'SD Glitch', sans-serif;
    font-size: 1.5rem;
    color: #fff !important;
    text-decoration: none;
    letter-spacing: 0.5px;
}

/* ─── Navbar ─── */
.navbar {
    background: linear-gradient(135deg, #2F055A 0%, #4a1a7a 100%) !important;
    box-shadow: 0 2px 12px rgba(47, 5, 90, 0.3);
    padding: 0.6rem 0;
}

.navbar .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    transition: color var(--transition-smooth);
}

.navbar .nav-link:hover {
    color: #fff !important;
}

.navbar .navbar-text {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.8rem;
}

.navbar .btn-outline-light {
    border-color: rgba(255,255,255,0.3);
    transition: all var(--transition-smooth);
}

.navbar .btn-outline-light:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
}

/* ─── Bootstrap button overrides ─── */
.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-primary:hover {
    background-color: #3d0a75;
    border-color: #3d0a75;
}

.btn-outline-primary {
    color: var(--bs-primary);
    border-color: var(--bs-primary);
}

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

.btn-info {
    background-color: var(--bs-info);
    border-color: var(--bs-info);
    color: #fff;
}

.btn-info:hover {
    background-color: #4d6976;
    border-color: #4d6976;
    color: #fff;
}

.btn-success {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.btn-success:hover {
    background-color: #4d775e;
    border-color: #4d775e;
}

.btn-warning {
    background-color: var(--bs-warning);
    border-color: var(--bs-warning);
    color: #fff;
}

.btn-warning:hover {
    background-color: #b8956a;
    border-color: #b8956a;
    color: #fff;
}

.btn-danger {
    background-color: var(--bs-danger);
    border-color: var(--bs-danger);
}

.btn-danger:hover {
    background-color: #944d5e;
    border-color: #944d5e;
}

/* ─── Mobile-first: large touch targets ─── */
.btn {
    min-height: 48px;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    border-radius: 0.6rem;
    transition: all var(--transition-smooth);
}

.btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

/* ─── Form controls ─── */
.form-control, .form-select {
    min-height: 48px;
    font-size: 1rem;
    border-radius: 0.6rem;
    border-color: #ddd;
    transition: all var(--transition-smooth);
}

.form-control:focus, .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(47, 5, 90, 0.2);
}

.input-group .form-control {
    border-radius: 0.6rem 0 0 0.6rem;
}

.input-group .btn {
    border-radius: 0 0.6rem 0.6rem 0;
}

/* ─── Cards ─── */
.card {
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    border-radius: 0.75rem;
    transition: all var(--transition-smooth);
    overflow: hidden;
}

.card-header {
    background-color: var(--purple-tint);
    border-bottom: 1px solid rgba(47, 5, 90, 0.08);
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
}

/* ─── Select cards (events, login) ─── */
.select-card {
    cursor: pointer;
    transition: all var(--transition-smooth);
    border: 2px solid transparent !important;
}

.select-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--purple-glow);
    border-color: rgba(47, 5, 90, 0.2) !important;
}

.select-card.active {
    border: 2px solid var(--bs-primary) !important;
    box-shadow: 0 4px 16px var(--purple-glow);
}

/* ─── List groups ─── */
.list-group {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.list-group-item {
    padding: 0.875rem 1.25rem;
    border-color: rgba(0, 0, 0, 0.06);
    transition: all var(--transition-smooth);
}

.list-group-item-action:hover {
    background-color: var(--purple-tint);
    transform: translateX(2px);
}

/* ─── Flash messages ─── */
.alert {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ─── Footer ─── */
.footer {
    color: #999;
    font-size: 0.8rem;
    padding: 1.5rem 0;
    text-align: center;
}

/* ─── Login page ─── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #f4f0f8 0%, #e8e0f0 100%);
}

.login-card {
    max-width: 420px;
    width: 100%;
}

.login-card .card {
    box-shadow: 0 8px 32px rgba(47, 5, 90, 0.12);
}

/* ─── Badge overrides ─── */
.bg-primary {
    background-color: var(--bs-primary) !important;
}

.badge {
    border-radius: 0.5rem;
    font-weight: 600;
    padding: 0.35em 0.65em;
}

/* ─── Page headers ─── */
.page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h2 {
    font-weight: 700;
    color: var(--bs-primary);
    margin: 0;
    font-size: 1.4rem;
}

.back-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--bs-primary);
    border-color: rgba(47, 5, 90, 0.2);
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.back-btn:hover {
    background-color: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
    box-shadow: 0 2px 8px var(--purple-glow);
}

/* ─── Home screen action cards ─── */
.action-card {
    cursor: pointer;
    transition: all var(--transition-smooth);
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--purple-glow);
    border-color: rgba(47, 5, 90, 0.12);
}

.action-card:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--purple-glow);
}

.action-card-disabled {
    cursor: default;
    opacity: 0.5;
}

.action-card-disabled:hover {
    transform: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.action-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.action-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--bs-primary);
    letter-spacing: 0.2px;
}

/* ─── Tabs (cleaner look) ─── */
.nav-tabs {
    border-bottom: 2px solid rgba(47, 5, 90, 0.1);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    color: #888;
    font-weight: 600;
    padding: 0.6rem 1.25rem;
    border-radius: 0.6rem 0.6rem 0 0;
    transition: all var(--transition-smooth);
    min-height: auto;
}

.nav-tabs .nav-link:hover {
    color: var(--bs-primary);
    background-color: var(--purple-tint);
}

.nav-tabs .nav-link.active {
    color: var(--bs-primary);
    background-color: #fff;
    border-bottom: 3px solid var(--bs-primary);
    margin-bottom: -2px;
}

/* ─── Scouting button groups ─── */
.btn-group-toggle {
    gap: 0.4rem !important;
}

.btn-group-toggle .btn {
    border-radius: 0.6rem !important;
    font-weight: 700;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Ball indicator (yellow circles) ─── */
.ball-dots {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
}

.ball-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f5c542;
    display: inline-block;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Outlined version for unselected state */
.btn-outline-warning .ball-dot,
.btn-outline-success .ball-dot {
    background: #c9a87c;
    opacity: 0.5;
}

.btn-warning .ball-dot,
.btn-success .ball-dot {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Smaller dots when 4-5 to fit */
.ball-dots.dots-4 .ball-dot,
.ball-dots.dots-5 .ball-dot {
    width: 10px;
    height: 10px;
}

/* ─── Match grid buttons ─── */
.match-btn {
    min-height: 52px;
    font-size: 1rem;
    border-radius: 0.6rem;
}

/* ─── Alliance cards ─── */
.alliance-card {
    border-radius: 0.75rem;
    overflow: hidden;
}

.alliance-card .card-header {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
}

.alliance-red {
    border: 2px solid var(--bs-danger) !important;
}

.alliance-red .card-header {
    background-color: var(--bs-danger);
    color: #fff;
}

.alliance-blue {
    border: 2px solid var(--bs-primary) !important;
}

.alliance-blue .card-header {
    background-color: var(--bs-primary);
    color: #fff;
}

/* ─── Modals ─── */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* ─── Tables ─── */
.table {
    font-size: 0.9rem;
}

.table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-weight: 700;
    border-bottom: 2px solid rgba(47, 5, 90, 0.1);
}

.table td {
    vertical-align: middle;
}

.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    color: var(--bs-primary);
}

/* ─── Empty states ─── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #999;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ─── Save button (scouting) ─── */
.save-btn {
    min-height: 56px;
    font-size: 1.1rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(90, 138, 110, 0.3);
}

.save-btn:hover {
    box-shadow: 0 6px 20px rgba(90, 138, 110, 0.4);
    transform: translateY(-1px);
}

.save-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(90, 138, 110, 0.3);
}

/* ─── Admin panel ─── */
.admin-item {
    padding: 1rem 1.25rem;
}

.admin-item i {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    font-size: 1.2rem;
}

.admin-icon-primary { background: rgba(47, 5, 90, 0.08); color: var(--bs-primary); }
.admin-icon-info { background: rgba(90, 122, 138, 0.1); color: var(--bs-info); }
.admin-icon-success { background: rgba(90, 138, 110, 0.1); color: var(--bs-success); }
.admin-icon-warning { background: rgba(201, 168, 124, 0.1); color: var(--bs-warning); }
.admin-icon-danger { background: rgba(168, 90, 110, 0.1); color: var(--bs-danger); }

/* ─── Stat badge (for averages/prep) ─── */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(47, 5, 90, 0.06);
    color: #444;
}

.stat-pill .ball-dot {
    width: 8px;
    height: 8px;
}

/* ─── Subtle scroll indicator ─── */
.table-responsive {
    border-radius: 0.5rem;
}

/* Wide tables keep their first column (team / match number) in view while
   the rest scrolls sideways on a phone */
.table-sticky-first th:first-child,
.table-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--bs-card-bg, #fff);
    box-shadow: inset -1px 0 0 var(--bs-border-color);
}
.table-sticky-first thead.table-light th:first-child {
    background-color: var(--bs-table-bg);
}

/* ─── Progress indicator for scouting ─── */
.scout-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.scout-status-done { background: var(--bs-success); }
.scout-status-none { background: #ddd; }

/* ─── Smooth page fade ─── */
main {
    animation: fadeUp 0.25s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Match scouting — 50/50 tabs, blue active state */
.match-tabs {
    display: flex;
}
.match-tabs .nav-item {
    flex: 1 1 0;
    min-width: 0;
}
.match-tabs .nav-link {
    width: 100%;
    text-align: center;
    color: var(--bs-primary);
}
.match-tabs .nav-link.active {
    background-color: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary) var(--bs-primary) #fff;
}

/* Fuel level buttons — keep balls on one line even on narrow phones */
.fuel-level-btn {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    white-space: nowrap;
    line-height: 1;
}

/* Fuel Scored — yellow buttons + larger hint text */
.fuel-scored .btn-warning,
.fuel-scored .btn-warning:hover {
    background-color: #ffd60a;
    border-color: #ffd60a;
    color: #3a2f00;
}

.fuel-scored .btn-outline-warning {
    color: #a88400;
    border-color: #ffd60a;
}

.fuel-scored .btn-outline-warning .ball-dot {
    background: #ffd60a;
    opacity: 0.5;
}

.fuel-scored .btn-warning .ball-dot {
    background: #fff;
}

.fuel-explainer {
    font-size: 1.3125rem !important;
}

/* Defense buttons — muscle-flex icons laid out horizontally */
.muscle-icons {
    display: inline-flex;
    gap: 2px;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

.muscle-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* Team summary — horizontal bar metrics */
.prep-label {
    font-size: 0.72rem;
    color: #6c757d;
    min-width: 42px;
    flex-shrink: 0;
}

.prep-value {
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 32px;
    flex-shrink: 0;
    text-align: right;
}

.prep-bar {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.prep-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.25s ease;
}

/* Compact ranks table in team summary */
.prep-ranks-table {
    font-size: 0.8rem;
    margin-bottom: 0.5rem !important;
}

.prep-ranks-table td {
    padding: 0.15rem 0.35rem;
    border: 0;
    max-width: 180px;
}

.prep-ranks-table tr + tr td {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Confidence indicator dot for analytics */
.score-with-confidence {
    white-space: nowrap;
}

.confidence-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 2px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ─── Priority highlighting (scout a match) ─── */
.priority-tile {
    background-color: rgba(var(--bs-primary-rgb), 0.18) !important;
    border-color: var(--bs-primary) !important;
    color: var(--bs-primary) !important;
}

.priority-tile:hover,
.priority-tile:focus {
    background-color: rgba(var(--bs-primary-rgb), 0.28) !important;
    color: var(--bs-primary) !important;
}

.priority-badge {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.1rem 0.35rem;
    border-radius: 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    margin-left: 0.4rem;
    vertical-align: middle;
    color: #fff;
    background: var(--bs-primary);
}

.priority-badge-opp {
    background: transparent;
    color: var(--bs-primary);
    border: 1.5px solid var(--bs-primary);
}

.next-match-banner {
    border: 2px solid;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.next-match-banner-primary {
    border-color: var(--bs-primary);
    background: var(--purple-tint);
}

.next-match-banner-primary .next-match-label,
.next-match-banner-primary .next-match-link {
    color: var(--bs-primary);
}

.next-match-banner-pink {
    border-color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.06);
}

.next-match-banner-pink .next-match-label,
.next-match-banner-pink .next-match-link {
    color: var(--bs-danger);
}

.next-match-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.next-match-label .bi {
    font-size: 1.6rem;
    line-height: 1;
}

/* Hide label text on narrow screens — icon alone is enough */
@media (max-width: 575.98px) {
    .next-match-label-text {
        display: none;
    }
}

.next-match-link {
    flex: 1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    text-decoration: none;
    font-weight: 700;
}

.next-match-number {
    font-size: 1.1rem;
}

.next-match-meta {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.75;
    margin-left: 0.25rem;
}

.next-match-time {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.8;
}


/* Scoring guide (rendered markdown) */
.scoring-guide h2 { font-size: 1.1rem; font-weight: 700; margin: 1rem 0 0.4rem; }
.scoring-guide table { width: 100%; margin-bottom: 0.5rem; }
.scoring-guide th, .scoring-guide td { padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--bs-border-color); }
.scoring-guide th { font-size: 0.8rem; text-transform: uppercase; color: var(--bs-secondary-color); }
.scoring-guide > :last-child { margin-bottom: 0; }

/* ─── Game-definition scouting controls ─── */
.scout-label {
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.scout-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.scout-badge {
    --badge-color: var(--bs-primary);
    flex: 1 1 auto;
    min-width: 3.5rem;
    min-height: 52px;
    padding: 0.4rem 0.75rem;
    border-radius: 0.6rem !important;
    font-weight: 700;
    line-height: 1.15;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scout-badge.btn-outline-success { --badge-color: var(--bs-success); }
.scout-badge.btn-outline-danger { --badge-color: var(--bs-danger); }

/* Colour comes only from the checked state, so a lingering touch "hover"
   never makes an unselected badge look selected. */
.scout-badge,
.scout-badge:hover {
    color: var(--badge-color);
    border-color: var(--badge-color);
    background-color: transparent;
}

.btn-check:checked + .scout-badge {
    color: #fff;
    border-color: var(--badge-color);
    background-color: var(--badge-color);
}

.scout-counter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scout-counter .counter-btn {
    flex: 1 1 0;
    min-height: 56px;
    border-radius: 0.6rem;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    touch-action: manipulation;
}

.scout-counter .counter-value {
    min-width: 3.5rem;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--bs-primary);
}

/* Large counters (the core numbers): value on top, big + in the middle */
.scout-counter-lg {
    flex-direction: column;
    align-items: stretch;
}

.scout-counter-lg .counter-value {
    order: 1;
    font-size: 3rem;
    line-height: 1.1;
}

.scout-counter-lg .counter-btn[data-step="1"] {
    order: 2;
    min-height: 110px;
    font-size: 3rem;
}

.scout-counter-lg .counter-btn[data-step="-1"] {
    order: 3;
    min-height: 44px;
}

.robot-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.robot-badges .badge {
    white-space: normal;
    text-align: left;
}

/* ─── Match prep: alliance comparison ─── */
.matchup-table {
    font-size: 0.85rem;
    text-align: right;
}

.matchup-table th:first-child,
.matchup-table td:first-child {
    text-align: left;
    padding-left: 0.75rem;
}

.matchup-table th:last-child,
.matchup-table td:last-child {
    padding-right: 0.75rem;
}

.matchup-table a {
    color: inherit;
}

.matchup-danger td:first-child { box-shadow: inset 4px 0 0 var(--bs-danger); }
.matchup-primary td:first-child { box-shadow: inset 4px 0 0 var(--bs-primary); }

.matchup-total td {
    font-weight: 800;
    border-bottom-width: 2px;
}

.matchup-danger .matchup-total td { color: var(--bs-danger); background-color: rgba(var(--bs-danger-rgb), 0.08); }
.matchup-primary .matchup-total td { color: var(--bs-primary); background-color: rgba(var(--bs-primary-rgb), 0.06); }
.matchup-table .matchup-us td { background-color: rgba(var(--bs-warning-rgb), 0.25); }
