/* style.css - Sistema de Diseño Premium y Estilos Visuales */

/* 1. Importación de Fuente Inter */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* 2. Variables de Diseño (Design Tokens) */
:root {
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* Colores */
    --bg-main: #0a0a0f;
    --bg-sidebar: #0e0e15;
    --bg-card: rgba(20, 20, 31, 0.6);
    --bg-card-hover: rgba(30, 30, 47, 0.8);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.15);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --btn-secondary-bg: rgba(255, 255, 255, 0.05);
    --btn-secondary-hover: rgba(255, 255, 255, 0.1);

    /* Acentos */
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-violet: #8b5cf6;
    --accent-violet-glow: rgba(139, 92, 246, 0.3);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.3);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.3);
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);

    /* Medidas y Bordes */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. Estilos Globales y Normalización */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* Barra de Scroll Estilizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 4. Layout Principal (Sidebar + Main Content) */
#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
aside.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    transition: var(--transition-smooth);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.sidebar-header .logo-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--accent-emerald-glow));
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 15px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.menu-item i {
    font-size: 18px;
    width: 20px;
    display: flex;
    justify-content: center;
}

.menu-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.menu-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.1);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* Área de Contenido Principal */
main.main-content {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 40px;
    position: relative;
    background: radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 10% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 50%);
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.view-header h1 {
    font-size: 32px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.view-header p {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 15px;
}

/* 5. Componentes UI Premium */

/* Tarjetas (Glassmorphism) */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-premium);

    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    transition: var(--transition-smooth);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.card-title i {
    color: var(--accent-violet);
}

/* Botones Premium */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-violet) 0%, #7c3aed 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #9061f9 0%, #6d28d9 100%);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399 0%, #047857 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.3);
    color: var(--accent-rose);
}

.btn-danger:hover {
    background: rgba(244, 63, 94, 0.25);
    border-color: rgba(244, 63, 94, 0.4);
}

.btn-icon-only {
    padding: 10px;
    border-radius: var(--radius-sm);
    aspect-ratio: 1;
}

/* Formularios Elegantes */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: var(--bg-card-hover);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Tablas Premium */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table.premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

table.premium-table th {
    background-color: rgba(15, 15, 25, 0.8);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
}

table.premium-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: var(--transition-smooth);
    background-color: rgba(20, 20, 31, 0.2);
}

table.premium-table tr:last-child td {
    border-bottom: none;
}

table.premium-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Insignias (Badges) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* 6. VISTAS ESPECÍFICAS */

/* --- DASHBOARD VIEW --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-widget {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    font-size: 20px;
}

.stat-info .stat-val {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-heading);
}

.stat-info .stat-lbl {
    font-size: 12px;
    color: var(--text-secondary);
}

.dashboard-left {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* --- ACCESO QR VIEW (Doble Mockup) --- */
.qr-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

/* Mockup de Celular del Jugador */
.player-phone-mockup {
    width: 320px;
    height: 600px;
    background: #000;
    border: 12px solid #1a1a24;
    border-radius: 40px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Notch de Celular */
.player-phone-mockup::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 25px;
    background: #1a1a24;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    z-index: 100;
}

.phone-screen {
    flex-grow: 1;
    background: linear-gradient(180deg, #12121c 0%, #07070b 100%);
    padding: 30px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    justify-content: space-between;
}

.phone-header {
    width: 100%;
    text-align: center;
    margin-top: 15px;
}

.phone-header h4 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #fff;
}

.phone-header p {
    font-size: 11px;
    color: var(--text-secondary);
}

.phone-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
    gap: 20px;
}

.player-selector-container {
    width: 100%;
}

.qr-container-box {
    background: #ffffff;
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    position: relative;
}

#qrcode img, #qrcode canvas {
    max-width: 100%;
    max-height: 100%;
}

.qr-timer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Temporizador Circular */
.circular-timer {
    position: relative;
    width: 48px;
    height: 48px;
}

.circular-timer svg {
    transform: rotate(-90deg);
    width: 48px;
    height: 48px;
}

.circular-timer circle {
    fill: none;
    stroke-width: 4;
}

.circular-timer .bg-ring {
    stroke: rgba(255, 255, 255, 0.05);
}

.circular-timer .progress-ring {
    stroke: var(--accent-violet);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

.circular-timer .timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-heading);
}

/* Toggle de Acción Entrada/Salida */
.action-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 9999px;
    width: 100%;
    border: 1px solid var(--border-color);
}

.toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.toggle-btn.active {
    background: var(--accent-violet);
    color: #fff;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.25);
}

/* Mockup de Terminal de Escáner */
.scanner-gate-mockup {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.scanner-viewfinder {
    aspect-ratio: 4/3;
    background: #07070b;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9);
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 40px solid rgba(0, 0, 0, 0.6);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-laser {
    position: absolute;
    width: calc(100% - 80px);
    height: 2px;
    background: var(--accent-rose);
    box-shadow: 0 0 12px 2px var(--accent-rose);
    animation: scanAnimation 2s linear infinite;
    z-index: 5;
    left: 40px;
}

/* Cámara Web Real */
#webcam-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.scanner-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    text-align: center;
    padding: 24px;
    z-index: 2;
}

.scanner-placeholder-content i {
    font-size: 48px;
    color: var(--accent-violet);
    animation: pulseGlow 2s infinite;
}

/* Resultado del Escaneo */
.scan-result-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    min-height: 80px;
    transition: var(--transition-smooth);
}

.scan-result-panel.scan-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
}

.scan-result-panel.scan-error {
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.3);
}

.scan-result-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.scan-result-info h5 {
    font-size: 15px;
    margin-bottom: 2px;
}
.scan-result-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- EQUIPOS VIEW --- */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.team-card {
    border-top: 4px solid var(--accent-color, var(--accent-violet));
}

.team-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.team-badge-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--accent-color, var(--accent-violet));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.team-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

.team-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

/* --- JUGADORES VIEW --- */
.players-table-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.search-wrapper {
    flex-grow: 1;
    position: relative;
}

.search-wrapper i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    padding-left: 44px;
}

/* --- PARTIDOS Y ROLES VIEW --- */
.fixtures-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 32px;
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.match-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.match-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

.match-teams {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 60%;
}

.match-team {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    width: 40%;
}

.match-team.team-a {
    justify-content: flex-end;
    text-align: right;
}

.match-team.team-b {
    justify-content: flex-start;
}

.match-score-pill {
    background: rgba(15, 15, 25, 0.9);
    padding: 6px 14px;
    border-radius: 9999px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    min-width: 70px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.match-score-pill.live {
    border-color: var(--accent-rose);
    color: var(--accent-rose);
    animation: livePulse 1.5s infinite;
}

.match-meta-info {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.match-meta-info i {
    margin-right: 4px;
}

/* Marcador en Vivo (Live Console) */
.live-console {
    border-top: 4px solid var(--accent-rose);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.live-console-scoreboard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    text-align: center;
}

.scoreboard-team {
    width: 40%;
}

.scoreboard-team .team-badge {
    font-size: 40px;
    margin-bottom: 8px;
}

.scoreboard-team h4 {
    font-size: 16px;
    font-weight: 700;
}

.scoreboard-score {
    font-family: var(--font-heading);
    font-size: 48px;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-status-badge {
    font-size: 11px;
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 3px 8px;
    border-radius: 9999px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.live-status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-rose);
    animation: livePulse 1.5s infinite;
}

.live-events-log {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-color);
}

.live-event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 6px;
    border-bottom: 1px dotted var(--border-color);
}

.live-event-item:last-child {
    border-bottom: none;
}

.live-event-item .min {
    font-weight: 700;
    color: var(--text-muted);
}

.live-event-item i {
    width: 16px;
    text-align: center;
}

/* Modales / Paneles de Acción */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);

    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: translateY(20px);
    transition: var(--transition-smooth);
}

.modal-backdrop.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

/* --- TABLA Y ESTADÍSTICAS VIEW --- */
.stats-layout {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    gap: 32px;
}

.podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    height: 180px;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    position: relative;
}

.podium-bar {
    width: 100%;
    background: linear-gradient(180deg, var(--accent-violet) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
}

.podium-place.second .podium-bar {
    height: 80px;
    background: linear-gradient(180deg, var(--text-secondary) 0%, rgba(148, 163, 184, 0.2) 100%);
}

.podium-place.first .podium-bar {
    height: 110px;
    background: linear-gradient(180deg, var(--accent-amber) 0%, rgba(245, 158, 11, 0.2) 100%);
}

.podium-place.third .podium-bar {
    height: 55px;
    background: linear-gradient(180deg, #b45309 0%, rgba(180, 83, 9, 0.2) 100%);
}

.podium-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 2px solid var(--accent-color, var(--text-muted));
    margin-bottom: 8px;
}

.podium-name {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100px;
    margin-top: 4px;
}

/* SVG Chart Visuals */
.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 220px;
    padding: 10px;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

/* 7. ANIMACIONES */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scanAnimation {
    0% {
        top: 40px;
    }
    50% {
        top: calc(100% - 42px);
    }
    100% {
        top: 40px;
    }
}

@keyframes pulseGlow {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
        text-shadow: 0 0 10px var(--accent-violet-glow);
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

@keyframes livePulse {
    0% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.4;
    }
}

/* ==========================================
   8. ESTILOS RESPONSIVOS UNIVERSALES (Móvil, Tableta y Escritorio)
   ========================================== */

/* Barra de Navegación Móvil Superior */
.mobile-header {
    display: none; /* Oculta en pantallas grandes */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(14, 14, 21, 0.85);


    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 990;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mobile-header .btn-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
}

.mobile-header .btn-toggle:active {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-header .mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header .mobile-logo .logo-icon {
    font-size: 22px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--accent-emerald-glow));
}

.mobile-header .mobile-logo h2 {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

/* Fondo Oscuro para Menú Deslizable Móvil */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 7, 11, 0.6);


    z-index: 995;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Media Query General: Celulares y Tabletas (<= 768px) */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    #app-container {
        flex-direction: column;
    }

    /* Convertir barra lateral en cajón deslizable */
    aside.sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
        background-color: #0e0e15; /* Asegura fondo opaco */
        border-right: 1px solid var(--border-color);
        transition: var(--transition-smooth);
    }

    aside.sidebar.active {
        transform: translateX(0);
    }

    /* Ajustar área de contenido principal */
    main.main-content {
        padding: 20px 16px;
        padding-top: 84px; /* Espacio para la barra superior móvil fija */
        width: 100%;
        height: 100vh;
        overflow-y: auto;
    }

    /* Ajuste de Vistas y Encabezados */
    .view-header {
        margin-bottom: 24px;
    }

    .view-header h1 {
        font-size: 26px;
    }

    .view-header p {
        font-size: 13px;
    }

    /* Apilar layouts de dos columnas de las vistas */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .qr-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .fixtures-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .stats-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    /* Estadísticas Rápidas a 2 columnas */
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 24px;
    }

    /* Tabla de jugadores: buscador y selectores */
    .players-table-actions {
        flex-direction: column;
        gap: 12px;
    }

    .players-table-actions select {
        width: 100%;
    }

    .search-wrapper {
        width: 100%;
    }

    /* Modales adaptados */
    .modal-content {
        width: 92%;
        margin: 0 auto;
        padding: 24px 20px;
    }
}

/* Media Query Específica: Celulares Pequeños (<= 480px) */
@media (max-width: 480px) {
    /* Estadísticas rápidas en una sola columna */
    .stats-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Inputs de formulario en una sola columna */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Adaptación de la tarjeta de partido */
    .match-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
    }

    .match-teams {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .match-team {
        width: 44%;
        font-size: 13px;
    }

    .match-team.team-a {
        text-align: right;
        justify-content: flex-end;
    }

    .match-team.team-b {
        text-align: left;
        justify-content: flex-start;
    }

    .match-score-pill {
        min-width: 56px;
        padding: 4px 8px;
        font-size: 13px;
    }

    .match-meta-info {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding-top: 8px;
        border-top: 1px solid var(--border-color);
        font-size: 11px;
    }

    /* Marcador en vivo (Consola) */
    .live-console-scoreboard {
        flex-direction: column;
        gap: 16px;
        padding: 16px 12px;
    }

    .scoreboard-team {
        width: 100%;
    }

    .scoreboard-team .team-badge {
        font-size: 32px;
        margin-bottom: 4px;
    }

    .scoreboard-team h4 {
        font-size: 14px;
    }

    .scoreboard-score {
        font-size: 36px;
        gap: 12px;
        justify-content: center;
    }

    /* Ajuste de Podio en estadísticas */
    .podium-container {
        height: 150px;
        gap: 8px;
        margin-bottom: 20px;
    }

    .podium-place {
        width: 64px;
    }

    .podium-name {
        font-size: 11px;
        width: 76px;
    }

    .podium-avatar {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    /* Celular del Jugador (Mockup QR) */
    .player-phone-mockup {
        width: 100%;
        max-width: 300px;
        height: 520px;
        border-width: 8px;
        border-radius: 28px;
    }

    .player-phone-mockup::after {
        width: 90px;
        height: 16px;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
    }

    .phone-screen {
        padding: 20px 12px 12px;
    }

    .phone-header h4 {
        font-size: 14px;
    }

    .qr-container-box {
        width: 160px;
        height: 160px;
        padding: 10px;
    }

    /* Escáner de Cancha */
    .scanner-viewfinder {
        aspect-ratio: 1; /* Cuadrado */
    }

    /* Botones de acción QR */
    #btn-simulate-scan {
        width: 100% !important;
        max-width: 300px;
    }
}

/* ==========================================
   TEMAS VISUALES
   ========================================== */
[data-theme="white"] {
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-color: rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-violet: #6366f1;
    --btn-secondary-bg: rgba(0, 0, 0, 0.05);
    --btn-secondary-hover: rgba(0, 0, 0, 0.1);
    color-scheme: light;
}

[data-theme="violet"] {
    --bg-main: #1e1b4b;
    --bg-sidebar: #2e1065;
    --bg-card: rgba(76, 29, 149, 0.4);
    --bg-card-hover: rgba(91, 33, 182, 0.6);
    --border-color: rgba(139, 92, 246, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #c4b5fd;
    --text-muted: #8b5cf6;
    --btn-secondary-bg: rgba(255, 255, 255, 0.1);
    --btn-secondary-hover: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   CUSTOM ALERT MODAL
   ========================================== */
#custom-alert-modal .modal-content {
    max-width: 400px;
    text-align: center;
}

#custom-alert-message {
    font-size: 16px;
    color: var(--text-primary);
    margin: 20px 0;
    line-height: 1.5;
}

#custom-alert-modal .modal-header h3 {
    width: 100%;
    text-align: center;
    color: var(--accent-violet);
}

/* Proteccion de tablas */
table, .premium-table {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Ticker Animado (Suscripciones) */
.trial-ticker-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 6px 0;
    overflow: hidden;
    white-space: nowrap;
    z-index: 1000;
}

.trial-ticker-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 20s linear 2 forwards;
    color: var(--text-primary);
    font-size: 12px;
}

@keyframes marquee {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-100%, 0); }
}

.trial-ticker-container.expired .trial-ticker-content {
    animation: none;
    padding-left: 0;
    width: 100%;
    text-align: center;
    color: var(--accent-rose);
    font-weight: bold;
}

/* --- TOUR ONBOARDING --- */
.tour-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    z-index: 9998;
}

.tour-highlight {
    position: relative !important;
    z-index: 9999 !important;
    background: var(--bg-surface) !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4) !important;
    border-radius: 8px !important;
}

.tour-tooltip {
    position: absolute;
    z-index: 10000;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    width: 320px;
    color: var(--text-primary);
    transform: translate(-50%, 15px);
    opacity: 0;
    animation: fadeInTour 0.3s forwards;
}

.tour-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 8px 8px 8px;
    border-style: solid;
    border-color: transparent transparent var(--bg-card) transparent;
}

@keyframes fadeInTour {
    to { opacity: 1; transform: translate(-50%, 15px); }
}

.tour-tooltip h4 {
    margin: 0 0 8px 0;
    color: var(--accent-violet);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tour-tooltip p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.tour-tooltip-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}


/* Owner Role (Solo Lectura) */
body.role-owner_complejo .admin-action, body.role-owner_complejo button:not(.close-modal):not(.view-toggle):not([onclick*='showModal']):not([onclick*='closeModal']):not(.btn-secondary) { display: none !important; }

