/* TecnoCric Ultra-Compact 20-Team Auction Controller Layout */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #1769d2;
    --primary-dark: #082a72;
    --brand-gradient: linear-gradient(110deg, #06183f 0%, #082a72 68%, #0a3a8f 100%);
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --dark: #08152f;
    --light: #f4f7fb;
    --card-bg: #ffffff;
    --line: #dfe7f2;
    --muted: #64748b;
    --shadow: 0 4px 16px rgba(8,28,65,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.3;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 70px;
}

button, input, select { font-family: inherit; }

/* NAVBAR */
.navbar {
    background: var(--brand-gradient);
    color: white;
    padding: 8px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(6, 24, 63, 0.2);
    sticky: top;
    top: 0;
    z-index: 1000;
    height: 52px;
}

.navbar-left { display: flex; align-items: center; gap: 12px; }
.navbar-brand { 
    font-family: 'Space Grotesk', sans-serif; 
    font-size: 1.25rem; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}
.navbar-brand i { color: #55b8ff; }
.auction-tag { font-size: 0.75rem; opacity: 0.85; font-weight: 500; background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 4px; }

.nav-select { padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: #fff; font-size: 0.8rem; outline: none; }
.nav-select option { background: var(--dark); color: #fff; }

.wa-lang-wrapper { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; }
.nav-select-sm { padding: 3px 6px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: #fff; font-size: 0.75rem; }

.btn-danger-reset {
    background: rgba(220, 38, 38, 0.18); color: #fecaca; font-size: 0.7rem; padding: 4px 9px;
    border-radius: 5px; font-weight: 700; border: 1px solid rgba(252, 165, 165, 0.3);
    cursor: pointer; display: flex; align-items: center; gap: 4px; transition: 0.2s;
}
.btn-danger-reset:hover { background: var(--danger); color: white; }

.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a, .btn-stats-toggle { 
    color: #d7e4f7; text-decoration: none; font-weight: 600; font-size: 0.78rem; 
    padding: 5px 9px; border-radius: 6px; background: transparent; border: none; cursor: pointer; display: flex; align-items: center; gap: 5px;
}
.nav-links a:hover, .btn-stats-toggle:hover { color: white; background: rgba(255,255,255,0.1); }
.btn-reset-unsold { background: #dc2626 !important; color: white !important; }
.logout-link { color: #fca5a5 !important; }

/* STATS OVERVIEW PANEL */
.auction-overview { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 20px; display: none; }
.auction-overview.open { display: block; }
.overview-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.overview-eyebrow { font-size: 0.65rem; font-weight: 700; color: var(--primary); letter-spacing: 0.05em; }
.overview-heading h2 { font-size: 1.1rem; font-family: 'Space Grotesk', sans-serif; }
.overview-actions { display: flex; gap: 8px; }
.overview-refresh { background: var(--light); border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; cursor: pointer; }
.overview-stats { display: flex; gap: 15px; margin-bottom: 10px; flex-wrap: wrap; }
.overview-stat { background: var(--light); padding: 8px 14px; border-radius: 8px; flex: 1; min-width: 110px; border: 1px solid var(--line); }
.overview-stat span { display: block; font-size: 0.7rem; color: var(--muted); }
.overview-stat strong { font-size: 1.1rem; font-family: 'Space Grotesk', sans-serif; }
.overview-stat small { display: block; font-size: 0.65rem; color: var(--muted); }
.progress-area { margin-top: 5px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.75rem; margin-bottom: 4px; }
.progress-track { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.progress-foot { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--muted); margin-top: 3px; }

/* MAIN CONTAINER GRID */
.main-container {
    display: grid; 
    grid-template-columns: 290px 1fr; 
    gap: 12px;
    padding: 10px 14px; 
    align-items: start;
    max-width: 100vw;
}

/* SIDEBAR */
.player-sidebar {
    background: var(--card-bg); 
    border-radius: 12px; 
    padding: 12px;
    box-shadow: var(--shadow); 
    border: 1px solid var(--line);
    display: flex; 
    flex-direction: column;
    height: calc(100vh - 74px);
    overflow-y: auto;
    position: relative;
}

/* SEARCH WRAPPER */
.search-wrapper { position: relative; margin-bottom: 10px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.8rem; }
#searchBox {
    width: 100%; padding: 8px 30px 8px 28px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 0.85rem; background: #fff; color: var(--dark); outline: none; transition: 0.2s;
}
#searchBox:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(23,105,210,0.12); }
.search-clear-btn {
    position: absolute; right: 42px; top: 50%; transform: translateY(-50%); background: none; border: none;
    font-size: 1.1rem; color: var(--muted); cursor: pointer; display: none; line-height: 1;
}
.search-hint { 
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%); 
    font-size: 0.65rem; color: var(--primary); background: #edf5ff; padding: 2px 5px; border-radius: 4px; border: 1px solid #cfe5fb;
}

.suggestions {
    position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--line); border-radius: 8px;
    max-height: 280px; overflow-y: auto; z-index: 2500; box-shadow: 0 10px 25px rgba(8,28,65,0.15); margin-top: 4px;
}
.suggestion-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9; display: flex; flex-direction: column; gap: 2px; }
.suggestion-item:hover, .suggestion-item.kbd-active { background: #edf5ff; }
.sugg-header { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.8rem; color: var(--dark); }
.sugg-price { font-family: 'Space Grotesk', sans-serif; color: var(--primary); }
.sugg-meta { display: flex; justify-content: space-between; font-size: 0.7rem; align-items: center; }

.status-badge { padding: 2px 6px; border-radius: 4px; font-weight: 700; font-size: 0.65rem; text-transform: uppercase; }
.bg-success { background: #dcfce7; color: #166534; }
.bg-danger { background: #fee2e2; color: #991b1b; }
.bg-primary { background: #dbeafe; color: #1e40af; }

/* SELECTION TOOLS */
.selection-tools { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; }
.selection-tools-heading { font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.selection-mode-switch { display: flex; gap: 4px; margin-bottom: 6px; }
.mode-btn { flex: 1; padding: 4px; font-size: 0.72rem; border-radius: 5px; border: 1px solid var(--line); background: white; cursor: pointer; font-weight: 600; }
.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.selection-actions { display: flex; gap: 6px; }
.pick-random-btn, .next-player-btn { flex: 1; padding: 6px; border-radius: 6px; border: 1px solid var(--line); font-size: 0.75rem; font-weight: 700; cursor: pointer; background: white; }
.pick-random-btn:hover, .next-player-btn:hover { background: #edf5ff; color: var(--primary); }

/* PLAYER PHOTO & INFO */
.player-photo-wrapper {
    width: 100%; height: 160px; background: #f8fafc; border-radius: 8px;
    overflow: hidden; margin-bottom: 8px; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
}
.player-photo { width: 100%; height: 100%; object-fit: contain; }
.empty-state { text-align: center; color: var(--muted); font-size: 0.75rem; }
.empty-state i { font-size: 2.5rem; margin-bottom: 4px; opacity: 0.3; }

.player-serial { font-size: 0.7rem; font-weight: 700; color: var(--primary); text-align: center; letter-spacing: 0.05em; }
.player-name { font-size: 1.15rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; text-align: center; margin-bottom: 6px; color: var(--dark); line-height: 1.2; }
.player-meta { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.badge { padding: 3px 8px; border-radius: 4px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.badge-role { background: #edf5ff; color: var(--primary); }
.badge-address { background: #eef2ff; color: #4f46e5; }

/* BID DASHBOARD */
.bid-dashboard {
    background: #f7faff; border-radius: 10px; padding: 10px; text-align: center;
    border: 1px solid var(--line); margin-top: auto;
}
.bid-label { font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.current-bid-display { font-size: 1.8rem; font-weight: 800; color: var(--primary); font-family: 'Space Grotesk', sans-serif; line-height: 1.1; margin: 2px 0; }
.current-holder { font-size: 0.85rem; font-weight: 700; color: var(--dark); min-height: 1.2rem; }
.base-price-info { font-size: 0.72rem; color: var(--muted); margin-bottom: 8px; }

.custom-bid-wrapper { display: flex; gap: 6px; margin-bottom: 8px; }
#customBidInput { flex: 1; padding: 6px; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; text-align: center; font-size: 0.88rem; outline: none; }
.btn-custom-set { background: var(--primary-dark); color: white; border: none; padding: 0 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.btn-custom-set:hover { background: var(--primary); }

.special-assign-row { display: flex; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }
.btn-assign { flex: 1; padding: 5px; border-radius: 6px; font-size: 0.68rem; font-weight: 700; cursor: pointer; border: 1px solid; background: white; }
.btn-assign-captain { border-color: var(--primary); color: var(--primary); }
.btn-assign-captain:hover { background: var(--primary); color: white; }
.btn-assign-icon { border-color: var(--warning); color: var(--warning); }
.btn-assign-icon:hover { background: var(--warning); color: white; }

/* STATUS BANNERS */
.status-banner { border-radius: 10px; padding: 12px; text-align: center; margin-top: auto; border: 1px solid; }
.banner-sold { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.banner-unsold { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.banner-title { font-weight: 800; text-transform: uppercase; font-size: 0.8rem; margin-top: 4px; }
.banner-team { font-size: 1rem; font-weight: 700; }
.banner-price { font-size: 1.4rem; font-weight: 800; font-family: 'Space Grotesk', sans-serif; margin: 4px 0; }
.action-buttons { display: flex; gap: 6px; margin-top: 8px; }
.btn-outline { flex: 1; padding: 6px; border-radius: 6px; font-weight: 700; font-size: 0.72rem; cursor: pointer; background: white; border: 1px solid; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }
.btn-outline-warning { border-color: var(--warning); color: var(--warning); }
.btn-outline-warning:hover { background: var(--warning); color: white; }

/* ================= TEAMS GRID (20 TEAMS COMPACT VIEW) ================= */
.team-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)); /* 5 columns x 4 rows = 20 cards */
    gap: 8px;
    align-content: start;
}

.team-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 88px;
    box-shadow: var(--shadow);
}

.team-card:hover {
    transform: translateY(-2px);
    border-color: #b8d8f5;
    box-shadow: 0 6px 16px rgba(8,28,65,0.1);
}

/* Leading Team Glow */
.team-card.highest {
    border: 2px solid var(--success) !important;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
    background: #f0fdf4 !important;
}
.team-card.highest::after {
    content: 'LEADING';
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--success);
    color: white;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.key-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: #edf5ff;
    color: var(--primary);
    font-size: 0.6rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #cfe5fb;
    line-height: 1;
}

.team-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px; /* clearance for key badge */
}

.team-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    border: 1px solid var(--line);
    background: #f8fafc;
    flex-shrink: 0;
}

.team-info { flex: 1; min-width: 0; }
.team-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.team-squad {
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 600;
}

.team-card-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px solid #f1f5f9;
    gap: 4px;
}

.stat-box { display: flex; flex-direction: column; }
.stat-lbl { font-size: 0.58rem; font-weight: 700; color: var(--muted); letter-spacing: 0.03em; }
.stat-val { font-size: 0.78rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--dark); white-space: nowrap; }

.stat-box-max { text-align: right; }
.stat-box-max .stat-lbl { color: var(--primary); }
.stat-box-max .stat-val { color: var(--primary); }

.team-card.disabled {
    opacity: 0.45;
    filter: grayscale(0.8);
    pointer-events: none;
    background: #f1f5f9 !important;
    border: 1px dashed #cbd5e1;
}

/* BOTTOM ACTION BAR */
.bottom-action-bar {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #06183f;
    padding: 6px 14px;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(6, 24, 63, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2000;
    border: 1px solid rgba(255,255,255,0.15);
}

.bar-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.2); }

.btn-action {
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.18s;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.btn-sold { background: var(--success); color: white; }
.btn-sold:hover { background: #15803d; transform: translateY(-1px); }
.btn-unsold { background: var(--danger); color: white; }
.btn-unsold:hover { background: #b91c1c; transform: translateY(-1px); }
.btn-util { background: rgba(255,255,255,0.15); color: white; }
.btn-util:hover { background: rgba(255,255,255,0.25); }
.btn-screen { background: var(--primary); }

.shortcut-hint {
    font-size: 0.6rem;
    opacity: 0.75;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 1px 4px;
    border-radius: 3px;
}

/* MODALS */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(8, 21, 47, 0.65); backdrop-filter: blur(4px);
    z-index: 3000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-content {
    background: white; padding: 22px; border-radius: 14px; width: 380px; max-width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25); border: 1px solid var(--line);
}
.modal-title { font-size: 1.2rem; font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--dark); margin-bottom: 8px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-weight: 600; font-size: 0.8rem; margin-bottom: 4px; color: var(--muted); }
.form-control { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.btn-cancel { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: white; font-weight: 700; cursor: pointer; }
.btn-ok { flex: 1; padding: 8px; border-radius: 6px; border: none; background: var(--primary); color: white; font-weight: 700; cursor: pointer; }
.btn-ok.danger { background: var(--danger); }
.modal-hint { font-size: 0.7rem; color: var(--muted); text-align: center; margin-top: 10px; }

/* TOASTS */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; }
.toast {
    background: white; color: var(--dark); padding: 10px 16px; border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12); margin-bottom: 10px; font-weight: 600; font-size: 0.82rem;
    display: flex; align-items: center; gap: 8px; border-left: 4px solid var(--primary); min-width: 250px;
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1500px) {
    .team-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
    .main-container { grid-template-columns: 260px 1fr; }
    .team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
    .main-container { grid-template-columns: 1fr; }
    .player-sidebar { height: auto; }
    .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 500px) {
    .team-grid { grid-template-columns: 1fr; }
    .shortcut-hint { display: none; }
}