/* =============================================================================
   ASTRA NUOTO ROMA - STYLESHEET
   Colori: Nero, Verde Astra, Bianco
   ============================================================================= */

/* --- Reset e Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --nero: #111111;
    --nero-chiaro: #1e1e1e;
    --grigio-scuro: #2a2a2a;
    --grigio: #3a3a3a;
    --grigio-chiaro: #888888;
    --verde: #00a651;
    --verde-scuro: #008c44;
    --verde-chiaro: #00c95f;
    --bianco: #ffffff;
    --rosso: #e74c3c;
    --giallo: #f1c40f;
    --oro: #ffd700;
    --argento: #c0c0c0;
    --bronzo: #cd7f32;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--nero);
    color: var(--bianco);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

a {
    color: var(--verde);
    text-decoration: none;
}
a:hover {
    color: var(--verde-chiaro);
}

/* --- Header --- */
.header {
    background: var(--nero-chiaro);
    border-bottom: 2px solid var(--verde);
    padding: 0.6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--bianco);
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--verde);
}

.logo-text h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--verde);
    line-height: 1.2;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--grigio-chiaro);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.nav {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    color: var(--bianco);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--grigio-scuro);
    color: var(--verde);
}

.nav-link.active {
    background: var(--verde);
    color: var(--bianco);
}

.nav-logout {
    color: var(--grigio-chiaro);
    font-size: 0.8rem;
}

/* --- Main --- */
.main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* --- Flash Messages --- */
.flash-container {
    max-width: 1200px;
    margin: 0.5rem auto;
    padding: 0 1.5rem;
}

.flash {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.flash-success {
    background: rgba(0, 166, 81, 0.15);
    border: 1px solid var(--verde);
    color: var(--verde-chiaro);
}

.flash-error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--rosso);
    color: var(--rosso);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.3rem;
}

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

/* --- Card --- */
.card {
    background: var(--nero-chiaro);
    border: 1px solid var(--grigio);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--verde);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--grigio);
}

/* --- Forms --- */
.form-row {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-width: 120px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--grigio-chiaro);
    font-weight: 500;
}

.form-group input,
.form-group select {
    padding: 0.6rem 0.8rem;
    background: var(--grigio-scuro);
    border: 1px solid var(--grigio);
    border-radius: 6px;
    color: var(--bianco);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--verde);
}

.form-group select option {
    background: var(--grigio-scuro);
}

/* --- Buttons --- */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.btn-verde {
    background: var(--verde);
    color: var(--bianco);
}
.btn-verde:hover {
    background: var(--verde-chiaro);
}

.btn-rosso {
    background: var(--rosso);
    color: var(--bianco);
}
.btn-rosso:hover {
    background: #c0392b;
}

.btn-grigio {
    background: var(--grigio);
    color: var(--bianco);
}
.btn-grigio:hover {
    background: var(--grigio-chiaro);
}

.btn-piccolo {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
}

/* --- Tabella Classifica --- */
.classifica-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}

.classifica-table th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--grigio-chiaro);
    border-bottom: 1px solid var(--grigio);
}

.classifica-table td {
    padding: 0.7rem 1rem;
    background: var(--grigio-scuro);
    font-size: 0.95rem;
}

.classifica-table tr td:first-child {
    border-radius: 8px 0 0 8px;
}

.classifica-table tr td:last-child {
    border-radius: 0 8px 8px 0;
}

.classifica-table .posizione {
    font-weight: 700;
    font-size: 1.1rem;
    width: 50px;
    text-align: center;
}

.classifica-table .numero {
    width: 60px;
    text-align: center;
    color: var(--grigio-chiaro);
}

.classifica-table .nome {
    font-weight: 500;
}

.classifica-table .votazione {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--verde);
    text-align: right;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

/* Medaglie per le prime 3 posizioni */
.pos-1 td { background: rgba(255, 215, 0, 0.1); }
.pos-1 .posizione { color: var(--oro); }
.pos-2 td { background: rgba(255, 215, 0, 0.1); }
.pos-2 .posizione { color: var(--oro); }
.pos-3 td { background: rgba(255, 215, 0, 0.1); }
.pos-3 .posizione { color: var(--oro); }

/* Fascia argento: posizioni 4-6 (solo Singolo e Duo, classe aggiunta via JS/template) */
.fascia-argento .pos-4 td { background: rgba(192, 192, 192, 0.1); }
.fascia-argento .pos-4 .posizione { color: var(--argento); }
.fascia-argento .pos-5 td { background: rgba(192, 192, 192, 0.1); }
.fascia-argento .pos-5 .posizione { color: var(--argento); }
.fascia-argento .pos-6 td { background: rgba(192, 192, 192, 0.1); }
.fascia-argento .pos-6 .posizione { color: var(--argento); }

/* Fascia bronzo: posizioni 7-9 (solo Singolo e Duo) */
.fascia-argento .pos-7 td { background: rgba(205, 127, 50, 0.1); }
.fascia-argento .pos-7 .posizione { color: var(--bronzo); }
.fascia-argento .pos-8 td { background: rgba(205, 127, 50, 0.1); }
.fascia-argento .pos-8 .posizione { color: var(--bronzo); }
.fascia-argento .pos-9 td { background: rgba(205, 127, 50, 0.1); }
.fascia-argento .pos-9 .posizione { color: var(--bronzo); }

/* Separatore tra fasce */
.fascia-argento .fascia-sep td {
    border-top: 2px solid var(--grigio);
}

/* Animazione classifica live */
.classifica-row {
    transition: all 0.5s ease;
}

.classifica-row.new-entry {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Titolo Esercizio Live --- */
.live-header {
    text-align: center;
    margin-bottom: 2rem;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--rosso);
    color: var(--rosso);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--rosso);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.live-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bianco);
    margin-bottom: 0.3rem;
}

.live-subtitle {
    color: var(--grigio-chiaro);
    font-size: 1rem;
}

/* --- Stato attesa --- */
.waiting {
    text-align: center;
    padding: 4rem 1rem;
}

.waiting-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bob 3s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.waiting h2 {
    font-size: 1.4rem;
    color: var(--verde);
    margin-bottom: 0.5rem;
}

.waiting p {
    color: var(--grigio-chiaro);
    font-size: 0.95rem;
}

/* --- Archivio --- */
.archivio-grid {
    display: grid;
    gap: 0.8rem;
}

.archivio-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--grigio-scuro);
    padding: 1rem 1.2rem;
    border-radius: 8px;
    border-left: 3px solid var(--verde);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: var(--bianco);
}

.archivio-item:hover {
    background: var(--grigio);
    color: var(--bianco);
    transform: translateX(4px);
}

.archivio-item-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.archivio-item-info span {
    font-size: 0.8rem;
    color: var(--grigio-chiaro);
}

.archivio-item-arrow {
    color: var(--verde);
    font-size: 1.2rem;
}

/* --- Filtri Archivio --- */
.filtri {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filtro-btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--grigio);
    border-radius: 20px;
    background: transparent;
    color: var(--grigio-chiaro);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filtro-btn:hover,
.filtro-btn.active {
    border-color: var(--verde);
    color: var(--verde);
    background: rgba(0, 166, 81, 0.1);
}

/* --- Login --- */
.login-container {
    max-width: 380px;
    margin: 4rem auto;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--verde);
}

.login-logo h2 {
    color: var(--verde);
    margin-top: 0.8rem;
    font-size: 1.3rem;
}

/* --- Admin: Esercizi terminati --- */
.terminati-list {
    display: grid;
    gap: 0.5rem;
}

.terminato-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--grigio-scuro);
    padding: 0.7rem 1rem;
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.terminato-item span {
    font-size: 0.9rem;
}

.terminato-actions {
    display: flex;
    gap: 0.3rem;
}

/* --- Admin: Tabella inline edit --- */
.edit-input {
    background: var(--nero);
    border: 1px solid var(--grigio);
    color: var(--bianco);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    width: 100%;
}

.edit-input:focus {
    border-color: var(--verde);
    outline: none;
}

/* --- Password Card --- */
.password-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--grigio);
}

.password-toggle {
    background: none;
    border: none;
    color: var(--grigio-chiaro);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.password-toggle:hover {
    color: var(--verde);
}

.password-form {
    display: none;
    margin-top: 1rem;
}

.password-form.visible {
    display: block;
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--grigio-chiaro);
    font-size: 0.8rem;
    border-top: 1px solid var(--grigio);
    margin-top: 2rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav {
        justify-content: center;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .live-title {
        font-size: 1.4rem;
    }

    .classifica-table th,
    .classifica-table td {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }

    .classifica-table .posizione {
        font-size: 0.95rem;
    }

    .classifica-table .votazione {
        font-size: 0.95rem;
    }

    .terminato-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
