:root {
    /* Padel Theme Colors */
    --color-bg-dark: #0f172a;
    --color-bg-darker: #020617;
    --color-padel-neon: #ccff00; /* Typical padel ball yellow/green */
    --color-padel-neon-glow: rgba(204, 255, 0, 0.4);
    --color-primary: #3b82f6; /* Padel court blue */
    --color-primary-dark: #2563eb;
    
    --color-surface: rgba(30, 41, 59, 0.7);
    --color-surface-hover: rgba(30, 41, 59, 0.9);
    --color-border: rgba(255, 255, 255, 0.1);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-darker);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effects */
.app-background {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at center, var(--color-bg-dark) 0%, var(--color-bg-darker) 100%);
}

.glow { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.5; }
.glow-1 { top: -10%; left: -10%; width: 500px; height: 500px; background: var(--color-primary); opacity: 0.2; }
.glow-2 { bottom: -20%; right: -10%; width: 600px; height: 600px; background: var(--color-padel-neon); opacity: 0.1; }

.glass-effect {
    background: var(--color-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; }

.navbar { position: sticky; top: 0; z-index: 100; padding: 1rem 0; border-bottom: 1px solid var(--color-border); }
.nav-content { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; transition: var(--transition); }
.logo:hover { transform: scale(1.05); }
.ball-icon { color: var(--color-padel-neon); font-size: 2rem; filter: drop-shadow(0 0 8px var(--color-padel-neon-glow)); animation: spin 10s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.logo h1 { font-size: 1.5rem; letter-spacing: -0.5px; }
.logo span { color: var(--color-padel-neon); }
.nav-actions { display: flex; gap: 1rem; align-items: center; }

/* Utilities */
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); font-family: var(--font-heading);
    font-weight: 600; cursor: pointer; transition: var(--transition); border: none; font-size: 0.95rem;
}
.btn-primary { background: var(--color-padel-neon); color: var(--color-bg-darker); box-shadow: 0 4px 14px var(--color-padel-neon-glow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--color-padel-neon-glow); background: #d4ff33; }
.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text-main); border: 1px solid rgba(255, 255, 255, 0.2); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-main); }
.btn-icon { padding: 0.5rem; border-radius: 50%; background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.btn-icon:hover { background: var(--color-padel-neon); color: var(--color-bg-darker); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.container { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem; }

/* Animations */
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Dashboard */
.dashboard-header { text-align: center; margin-bottom: 3rem; }
.dashboard-header h2 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.dashboard-header p { color: var(--text-muted); font-size: 1.1rem; }
.leagues-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.league-card { padding: 1.5rem; border-radius: var(--radius-lg); transition: var(--transition); display: flex; flex-direction: column; gap: 1rem; }
.league-card:hover { transform: translateY(-5px); border-color: var(--color-padel-neon); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.league-card h3 { font-size: 1.4rem; color: var(--color-padel-neon); }
.league-dates { font-size: 0.85rem; color: var(--text-muted); display: flex; gap: 0.5rem; align-items: center; }
.league-card-stats { display: flex; gap: 1rem; color: var(--text-muted); font-size: 0.9rem; }

/* Forms */
.form-container { max-width: 600px; margin: 0 auto; padding: 2.5rem; border-radius: var(--radius-lg); }
.form-container h2 { margin-bottom: 2rem; text-align: center; color: var(--color-padel-neon); }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-muted); }

.form-control, select {
    width: 100%; padding: 0.8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
    background: rgba(0, 0, 0, 0.2); color: var(--text-main); font-family: var(--font-body); font-size: 1rem; transition: var(--transition);
}
.form-control:focus, select:focus { outline: none; border-color: var(--color-padel-neon); box-shadow: 0 0 0 2px var(--color-padel-neon-glow); }
select option { background: var(--color-bg-darker); color: var(--text-main); }

.dates-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pairs-container { display: flex; flex-direction: column; gap: 0.8rem; }
.pair-input-row { display: flex; gap: 0.5rem; align-items: center; background: rgba(0,0,0,0.2); padding: 1rem; border-radius: var(--radius-sm); }
.pair-selects { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem; align-items: center; }

.form-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }

/* Players Layout */
.players-layout { display: grid; grid-template-columns: 1fr 400px; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .players-layout { grid-template-columns: 1fr; } }
.players-list-section { padding: 2rem; border-radius: var(--radius-lg); }
.players-list-section h2 { color: var(--color-padel-neon); margin-bottom: 1rem; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { width: 90%; max-width: 450px; padding: 2rem; border-radius: var(--radius-lg); text-align: center; }
.modal-content h3 { color: var(--color-padel-neon); margin-bottom: 1rem; font-size: 1.5rem; }
.modal-content p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }
.modal-content .form-group { text-align: left; }

/* League View */
.league-header { margin-bottom: 2rem; }
.league-title-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.league-title-bar h2 { font-size: 2rem; color: var(--color-padel-neon); line-height: 1.2; }
.league-dates-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.2rem; }
.tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0; }
.tab-btn { background: transparent; border: none; color: var(--text-muted); padding: 0.8rem 1.5rem; font-family: var(--font-heading); font-size: 1.1rem; font-weight: 600; cursor: pointer; position: relative; transition: var(--transition); display: flex; align-items: center; gap: 0.5rem; }
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--color-padel-neon); }
.tab-btn.active::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--color-padel-neon); box-shadow: 0 -2px 10px var(--color-padel-neon-glow); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Standings Table */
.table-container { border-radius: var(--radius-lg); overflow-x: auto; }
.standings-table { width: 100%; border-collapse: collapse; text-align: left; }
.standings-table th, .standings-table td { padding: 1rem; border-bottom: 1px solid var(--color-border); }
.standings-table th { font-family: var(--font-heading); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.5px; }
.standings-table tbody tr { transition: var(--transition); }
.standings-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.standings-table td:nth-child(3) { font-weight: bold; color: var(--color-padel-neon); font-size: 1.1rem; }
.pos-1 { color: #ffd700; font-weight: bold; }
.pos-2 { color: #c0c0c0; font-weight: bold; }
.pos-3 { color: #cd7f32; font-weight: bold; }

/* Matches */
.rounds-container { display: flex; flex-direction: column; gap: 3rem; }
.round-section h3 { font-family: var(--font-heading); font-size: 1.3rem; color: var(--text-main); margin-bottom: 1rem; padding-left: 0.5rem; border-left: 3px solid var(--color-primary); }
.matches-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 1rem; }
.match-card { padding: 1.2rem; border-radius: var(--radius-md); display: flex; flex-direction: column; gap: 1rem; transition: var(--transition); }
.match-card:hover { border-color: rgba(255, 255, 255, 0.2); }
.match-teams { display: flex; align-items: center; justify-content: space-between; }
.team { flex: 1; text-align: center; font-weight: 500; font-size: 0.95rem; }
.vs-badge { background: var(--color-bg-darker); color: var(--color-padel-neon); padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-family: var(--font-heading); font-weight: 800; }
.match-score { display: flex; gap: 0.5rem; align-items: center; }
.score-inputs { flex: 1; }
.match-result-display { display: flex; justify-content: space-between; align-items: center; background: rgba(0, 0, 0, 0.3); padding: 0.6rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
.result-text { font-family: var(--font-heading); font-weight: 600; color: var(--color-padel-neon); letter-spacing: 1px; }

/* Responsiveness */
@media (max-width: 900px) {
    .players-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Header & Nav */
    .dashboard-header h2 { font-size: 2rem; }
    .nav-actions { gap: 0.2rem; }
    .nav-actions .btn { padding: 0.5rem; border-radius: 50%; width: 40px; height: 40px; }
    .nav-actions span { display: none; }
    .logo h1 { font-size: 1.2rem; }
    
    /* Layouts */
    .container { margin: 1rem auto; padding: 0 1rem; }
    .leagues-grid { grid-template-columns: 1fr; }
    /* Forms */
    .form-container { padding: 1.5rem; }
    .dates-row { grid-template-columns: 1fr; }
    .pair-selects { grid-template-columns: 1fr; text-align: center; gap: 0.2rem; }
    .pair-selects span { display: none; } /* Hide the 'vs' or '/' between selects if needed */
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; margin-bottom: 0.5rem; }
    
    /* League View */
    .league-title-bar { flex-direction: column; align-items: flex-start; text-align: left; gap: 0.5rem; }
    .league-title-bar h2 { font-size: 1.5rem; }
    
    /* Tabs */
    .tabs { flex-wrap: wrap; justify-content: center; gap: 0; }
    .tab-btn { font-size: 0.9rem; padding: 0.6rem 0.5rem; flex: 1; text-align: center; justify-content: center; }
    .tab-btn i { font-size: 1.2rem; margin-bottom: 0.2rem; }
    .tab-btn span { display: none; } /* Optional: Hide tab text, show only icons on very small screens, or keep text and stack */
    
    /* Standings Table */
    .table-container { margin: 0 -1rem; border-radius: 0; padding: 0 1rem; }
    .standings-table th, .standings-table td { padding: 0.8rem 0.5rem; font-size: 0.85rem; }
    
    /* Modals */
    .modal-content { width: 95%; padding: 1.5rem; }
}

@media (max-width: 480px) {
    /* Super small screens */
    .league-card h3 { font-size: 1.2rem; }
    .match-teams { flex-direction: column; gap: 0.5rem; }
    .vs-badge { margin: 0.5rem 0; }
    .match-result-display { flex-direction: column; gap: 0.5rem; }
    .match-score { flex-direction: column; align-items: stretch; }
    .match-score .btn { width: 100%; }
    .tab-btn { flex-direction: column; font-size: 0.75rem; padding: 0.5rem 0.2rem; }
    .tab-btn i { font-size: 1.4rem; }
}

/* Centered Leagues List */
.leagues-list-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.league-list-item {
    width: 100%;
    text-align: center;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.league-list-item:last-child {
    border-bottom: none;
}

.league-link {
    text-decoration: none;
    color: var(--color-padel-neon);
    display: block;
    transition: var(--transition);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

.league-link:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.league-link h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.league-link p {
    color: var(--text-muted);
    font-size: 1rem;
}

@media print {
    @page { size: A4; margin: 1cm; }
    body { background: white !important; color: black !important; font-size: 11px !important; }
    .navbar, .dashboard-header, .tabs, .print-controls, .btn, .btn-ghost, .btn-primary, .btn-secondary, .form-actions, .match-score, .edit-score-btn, .match-audit, .league-dates-subtitle { display: none !important; }
    
    .glass-effect { border: none !important; box-shadow: none !important; background: transparent !important; padding: 0 !important; }
    .container { margin: 0 !important; max-width: 100% !important; padding: 0 !important; }
    
    h2, h3 { color: black !important; margin-bottom: 0.5rem !important; }
    
    /* Matches Layout */
    .rounds-container { gap: 1rem !important; display: block !important; }
    .round-section { margin-bottom: 1.5rem !important; page-break-inside: avoid; }
    .round-section h3 { font-size: 1.1rem !important; border-left: 2px solid #ccc !important; padding-left: 0.5rem !important; }
    
    .matches-grid { 
        display: grid !important; 
        grid-template-columns: 1fr 1fr !important; 
        gap: 0.5rem !important; 
    }
    
    .match-card { 
        page-break-inside: avoid; 
        border: 1px solid #aaa !important; 
        padding: 0.5rem !important; 
        gap: 0.5rem !important; 
        border-radius: 4px !important;
    }
    
    .match-teams { font-size: 10px !important; }
    .team { font-size: 10px !important; font-weight: bold !important; }
    .vs-badge { display: none !important; } /* Ocultar VS para ahorrar espacio */
    
    .match-result-display {
        display: flex !important;
        padding: 0.2rem !important;
        border: none !important;
        background: transparent !important;
        justify-content: center !important;
    }
    .result-text { font-size: 12px !important; color: black !important; font-weight: bold !important; text-align: center; width: 100%; }

    /* Fix empty results */
    .result-text:empty::before { content: "Pendiente"; font-weight: normal; color: #666; font-style: italic; }
    
    /* Tables */
    table { width: 100% !important; border-collapse: collapse !important; font-size: 10px !important; margin-bottom: 1rem !important; }
    th, td { border: 1px solid #888 !important; padding: 0.3rem !important; text-align: left !important; color: black !important; }
    .standings-table th { background: #e5e5e5 !important; color: black !important; font-weight: bold !important; }
    
    /* Hide Actions column in Players list */
    .players-table th:last-child, 
    .players-table td:last-child { display: none !important; }
}
