﻿/* ========================================
   🎾 TENNIS RANKING - TEMA PRINCIPAL
   ======================================== */

:root {
    /* Cores principais - Tema Tênis */
    --primary: #1e6f5c;
    --primary-dark: #145246;
    --primary-light: #289672;
    --secondary: #e8871e;
    --secondary-light: #f5a623;
    --accent: #ffc93c;
    /* Cores de fundo */
    --bg-main: #f0f4f3;
    --bg-card: #ffffff;
    --bg-dark: #1a1a2e;
    /* Cores de texto */
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-light: #b2bec3;
    --text-muted: #a0a0a0;
    /* Cores de status */
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;
    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.16);
    /* Bordas */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;
}

/* ========================================
   RESET E BASE
   ======================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   LAYOUT - SIDEBAR
   ======================================== */
.sidebar {
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%) !important;
}

    .sidebar .navbar-brand {
        font-weight: 700;
        font-size: 1.1rem;
    }

    .sidebar .nav-link {
        color: rgba(255, 255, 255, 0.85) !important;
        border-radius: var(--radius-sm);
        margin: 4px 8px;
        transition: all 0.2s ease;
    }

        .sidebar .nav-link:hover {
            background: rgba(255, 255, 255, 0.15);
            color: white !important;
            transform: translateX(4px);
        }

        .sidebar .nav-link.active {
            background: var(--secondary) !important;
            color: white !important;
            font-weight: 600;
        }

/* ========================================
   CABEÇALHO DA PÁGINA (Padrão Global)
   ======================================== */
.page-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    color: white;
    position: relative;
    overflow: hidden;
}

    .page-header::before {
        content: '🎾';
        position: absolute;
        font-size: 8rem;
        opacity: 0.1;
        right: -20px;
        top: -20px;
    }

    .page-header h1, .page-header h2 {
        color: white;
        margin-bottom: 0.5rem;
        font-weight: 700;
        font-size: 2rem;
    }

    .page-header .text-muted {
        color: rgba(255, 255, 255, 0.8) !important;
    }

.season-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* ========================================
   CARDS DE ESTATÍSTICAS
   ======================================== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

    .stat-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    }

    .stat-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-md);
    }

.stat-number, .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

    .stats-grid .stat-card {
        padding: 1.25rem;
    }

    .stats-grid .stat-icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .stats-grid.mini {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
        margin-bottom: 2rem;
    }

@media (max-width: 768px) {
    .stats-grid.mini {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stats-grid.mini .stat-card {
    padding: 1rem;
}

.stats-grid.mini .stat-value {
    font-size: 1.75rem;
}

/* ========================================
   TABELA DE RANKING
   ======================================== */
.ranking-container {
    max-width: 950px;
    margin: 0 auto 2.5rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: var(--bg-card);
}

.ranking-header {
    display: grid;
    grid-template-columns: 70px 1fr 90px 110px 120px 110px;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #2d2d44 100%);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ranking-row {
    display: grid;
    grid-template-columns: 70px 1fr 90px 110px 120px 110px;
    padding: 1rem 1.5rem;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.25s ease;
}

    .ranking-row:last-child {
        border-bottom: none;
    }

    .ranking-row:hover {
        background: linear-gradient(90deg, rgba(30, 111, 92, 0.05) 0%, rgba(232, 135, 30, 0.05) 100%);
    }

    .ranking-row.top-three {
        background: linear-gradient(90deg, #fff9e6 0%, #fffbf0 100%);
        border-left: 4px solid var(--accent);
    }

    .ranking-row.paused {
        opacity: 0.5;
        background: #f9f9f9;
    }

.pos {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-secondary);
}

.ranking-row.top-three .pos {
    color: var(--secondary);
}

.medal {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.name a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    transition: color 0.2s ease;
}

    .name a:hover {
        color: var(--primary);
    }

.apt {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.points {
    font-weight: 600;
    color: var(--primary);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
}

    .badge.bg-success {
        background: var(--success) !important;
    }

    .badge.bg-warning {
        background: var(--warning) !important;
        color: var(--text-primary) !important;
    }

/* ========================================
   AÇÕES E BOTÕES
   ======================================== */
.actions {
    display: flex;
    gap: 0.5rem;
}

    .actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 1rem;
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
    }

        .actions .btn:hover {
            transform: scale(1.1);
        }

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.action-bar.centered {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn-success {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
    border: none !important;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

    .btn-success:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.btn-primary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%) !important;
    border: none !important;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.btn-outline {
    background: #f8f9fa !important;
    border: 2px solid var(--primary) !important;
    color: var(--primary) !important;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

    .btn-outline:hover {
        background: var(--primary) !important;
        color: white !important;
        transform: translateY(-2px);
        box-shadow: var(--shadow-sm);
    }

.btn-cancel {
    background: #fef2f2 !important;
    border: 2px solid #fca5a5 !important;
    color: #dc2626 !important;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

    .btn-cancel:hover {
        background: #fee2e2 !important;
        border-color: #f87171 !important;
        color: #b91c1c !important;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
    }

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

    .btn-link:hover {
        color: var(--primary-dark);
        text-decoration: underline;
    }

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

    .empty-state p {
        margin: 0.5rem 0;
    }

.empty-state-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   MODAL
   ======================================== */
.modal.show {
    backdrop-filter: blur(4px);
}

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    padding: 1.25rem 1.5rem;
}

    .modal-header .modal-title {
        font-weight: 600;
    }

    .modal-header .btn-close {
        filter: brightness(0) invert(1);
        opacity: 0.8;
    }

.modal-body {
    padding: 1.75rem;
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1rem 1.5rem;
    background: #f8f9fa;
}

/* ========================================
   FORMULÁRIOS
   ======================================== */
.form-control {
    border-radius: var(--radius-sm);
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

    .form-control:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(30, 111, 92, 0.15);
    }

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-actions {
    margin-top: 2.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ========================================
   PÁGINA DE REGRAS
   ======================================== */
.rules-container {
    max-width: 800px;
    margin: 0 auto;
}

.rule-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

.rule-header {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    background: var(--bg-card);
    transition: background 0.2s ease;
    border-left: 4px solid transparent;
}

    .rule-header:hover {
        background: #f8f9fa;
    }

.rule-card.expanded .rule-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-left-color: var(--secondary);
}

.rule-icon {
    font-size: 1.75rem;
    margin-right: 1rem;
    width: 40px;
    text-align: center;
}

.rule-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
}

.rule-toggle {
    font-size: 0.9rem;
    opacity: 0.6;
    transition: transform 0.3s ease;
}

.rule-card.expanded .rule-toggle {
    transform: rotate(180deg);
}

.rule-body {
    padding: 1.25rem;
    background: #fafbfc;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    animation: slideDown 0.3s ease;
}

    .rule-body ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .rule-body li {
        margin-bottom: 0.75rem;
        padding-left: 1.5rem;
        position: relative;
        line-height: 1.7;
    }

        .rule-body li::before {
            content: '✓';
            position: absolute;
            left: 0;
            color: var(--primary);
            font-weight: bold;
        }

        .rule-body li:last-child {
            margin-bottom: 0;
        }

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   PÁGINA DE REGISTRAR PARTIDA
   ======================================== */
.match-form-container {
    max-width: 900px;
    margin: 0 auto;
}

    .match-form-container .card {
        border: none;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
    }

.player-select-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

    .player-select-card.challenger {
        border-top: 4px solid var(--danger);
    }

    .player-select-card.challenged {
        border-top: 4px solid var(--info);
    }

    .player-select-card h5 {
        font-weight: 600;
        margin-bottom: 1rem;
    }

.vs-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vs {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-light);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-section, .result-section {
    margin-top: 2rem;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: var(--radius-md);
}

    .score-section h5, .result-section h5 {
        font-weight: 600;
        margin-bottom: 1.5rem;
        color: var(--text-primary);
    }

.sets-container {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.set-input {
    text-align: center;
}

    .set-input label {
        display: block;
        margin-bottom: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.9rem;
    }

.set-scores {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .set-scores input {
        width: 65px;
        height: 65px;
        text-align: center;
        font-size: 1.5rem;
        font-weight: 700;
        border: 2px solid #e9ecef;
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
    }

        .set-scores input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(30, 111, 92, 0.15);
        }

    .set-scores span {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-light);
    }

.result-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

    .result-options .form-check {
        padding: 1rem 1rem 1rem 2.5rem;
        background: var(--bg-card);
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
        border: 2px solid transparent;
    }

        .result-options .form-check:hover {
            background: #f0f4f3;
        }

    .result-options .form-check-input:checked + .form-check-label {
        font-weight: 600;
    }

/* ========================================
   PAGE CONTAINER
   ======================================== */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.page-content {
    width: 100%;
}

/* ========================================
   RESPONSIVIDADE GLOBAL
   ======================================== */
@media (max-width: 768px) {
    .empty-state-inline {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .page-container {
        padding: 1rem;
    }

    .action-bar.centered {
        flex-direction: column;
    }

        .action-bar.centered .btn {
            width: 100%;
        }
}

/* Responsividade do Page Header */
@media (max-width: 480px) {
    .page-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        padding: 1.5rem 1rem;
    }

        .page-header h1, .page-header h2 {
            font-size: 1.5rem;
            margin-bottom: 0;
        }

    .season-badge {
        position: relative;
        font-size: 0.75rem;
        padding: 0.3rem 0.75rem;
        white-space: nowrap;
    }
}

/* Indicador de conexão */
#connection-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: #f59e0b;
    color: white;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 9999;
    overflow: hidden;
    transition: height 0.3s ease;
}

#connection-indicator.disconnected {
    height: 32px;
    line-height: 32px;
}

/* Modal de reconexão */
.reconnect-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}

.reconnect-modal.show {
    display: flex;
}

.reconnect-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.reconnect-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top-color: #198754;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.reconnect-content p {
    margin: 0 0 1rem;
    color: #333;
    font-weight: 500;
}

.reconnect-btn {
    background: #198754;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.reconnect-btn:hover {
    background: #157347;
}
