/* ==========================================================================
   DESIGN SYSTEM UNIFICATO - GARE PODISTICHE ABRUZZO
   Copre 100% delle pagine pubbliche e pannello amministrativo
   ========================================================================== */

:root {
    --primary: #1e3a8a;
    --primary-light: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #10b981;
    --accent-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg-body: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base & Tipografia */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 0;
}

/* Container Principali */
.container {
    max-width: 1100px;
    margin: 20px auto;
    background: var(--card-bg);
    padding: 35px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.form-card {
    max-width: 680px;
    margin: 25px auto;
    background: var(--card-bg);
    padding: 35px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* Login Card (admin/login.php) */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    margin: 60px auto;
    border: 1px solid var(--border-color);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 25px;
}

/* Navigazione, Header & Breadcrumb */
.nav-links {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a, .back-link, .btn-back {
    color: var(--primary-light);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 15px;
    transition: var(--transition);
}

.nav-links a {
    margin-bottom: 0;
}

.nav-links a:hover, .back-link:hover, .btn-back:hover {
    color: var(--primary);
}

.header, .top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 18px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1, .top-bar h2 {
    margin: 0;
}

/* Dashboard Admin Grid (admin/dashboard.php) */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.menu-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 25px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.menu-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
    background: #ffffff;
}

.menu-card .icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.menu-card h3 {
    margin: 8px 0;
    font-size: 17px;
}

.menu-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Badge Provinciali */
.badge-prov {
    display: inline-block;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #3730a3;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Form, Input e Filtri */
.filter-box, .filter-bar {
    background: #f8fafc;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid var(--border-color);
}

.filter-box select, .filter-bar select {
    width: auto;
    min-width: 170px;
}

.form-group {
    margin-bottom: 18px;
}

label {
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    color: var(--text-main);
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="url"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
    font-size: 14px;
    background: #ffffff;
    color: var(--text-main);
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* ==========================================================================
   PULSANTI UNIFICATI (Pubblico + Admin)
   ========================================================================== */
button, .btn, .btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

button, .btn {
    background-color: var(--primary-light);
    color: #ffffff;
}

button:hover, .btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.form-card button[type="submit"],
.login-card button[type="submit"] {
    width: 100%;
    padding: 13px;
    font-size: 16px;
    margin-top: 8px;
}

/* Varianti Bottoni Specifici */
.btn-success, .btn-iscrizione, .btn-link.iscrizione {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    border: 1px solid #86efac;
}
.btn-success:hover, .btn-iscrizione:hover, .btn-link.iscrizione:hover {
    background: #22c55e;
    color: #ffffff;
}

.btn-regolamento, .btn-link.regolamento {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}
.btn-regolamento:hover, .btn-link.regolamento:hover {
    background: #ef4444;
    color: #ffffff;
}

.btn-link.classifica {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
}
.btn-link.classifica:hover {
    background: #047857;
}

.btn-modifica {
    background-color: var(--primary-light);
    color: #ffffff;
    padding: 7px 14px;
    font-size: 13px;
}

.btn-elimina, .btn-logout, .btn-danger {
    background-color: var(--danger);
    color: #ffffff;
    padding: 7px 14px;
    font-size: 13px;
}
.btn-elimina:hover, .btn-logout:hover, .btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-back {
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
}
.btn-back:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-calendar {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}
.btn-calendar:hover {
    background: #c7d2fe;
    color: #1e1b4b;
}

.btn-share {
    background: #f8fafc;
    color: var(--text-main);
    border: 1px solid #cbd5e1;
}
.btn-share:hover {
    background: #e2e8f0;
}

/* Bottoni Divisioni (gara.php) */
.btn-div {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 10px;
}
.btn-div.active {
    background-color: var(--primary-light);
    color: #ffffff;
}
.btn-div.inactive {
    background-color: #e2e8f0;
    color: #334155;
}

/* Dropdown Calendario (gara.php) */
.dropdown-container {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    display: none;
    position: absolute;
    background: #ffffff;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 0;
    z-index: 100;
    top: calc(100% + 5px);
    left: 0;
    min-width: 190px;
}
.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.dropdown-menu a:hover {
    background: #f1f5f9;
    color: var(--primary-light);
}

/* Card Gare & Sezioni (index.php) */
.section-title {
    margin-top: 35px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.card-gara {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card-gara:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.card-gara.svolta {
    border-left: 5px solid var(--text-muted);
}

/* Accordion Gare Svolte */
details.accordion-passate {
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
details.accordion-passate summary {
    background-color: #f8fafc;
    color: var(--primary);
    padding: 16px 22px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}
details.accordion-passate summary:hover {
    background-color: #f1f5f9;
}
.accordion-content {
    padding: 20px;
    background-color: var(--bg-body);
}

/* Dettagli Gara, Locandina Responsive & Lightbox (gara.php) */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
    background: #f8fafc;
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.content-section {
    display: flex;
    gap: 25px;
    margin: 25px 0;
    align-items: flex-start;
    flex-direction: column;
}

.descrizione-box {
    flex: 1;
    background: #f8fafc;
    border-left: 4px solid var(--primary-light);
    padding: 20px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    line-height: 1.65;
    width: 100%;
}

.locandina-wrapper {
    width: 100%;
    text-align: center;
}
.locandina-wrapper img {
    max-width: 100%;
    max-height: 360px;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.2s ease;
}
.locandina-wrapper img:hover {
    transform: scale(1.02);
}

@media (min-width: 768px) {
    .content-section {
        flex-direction: row;
    }
    .locandina-wrapper {
        width: 300px;
        flex-shrink: 0;
        order: 2;
        text-align: right;
    }
    .descrizione-box {
        order: 1;
    }
}

/* Mappa Leaflet */
.map-section {
    margin-top: 30px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
}
#map {
    height: 320px;
    width: 100%;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    z-index: 1;
}

/* Modal Lightbox */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    align-items: center;
    justify-content: center;
}
.modal img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: var(--radius-md);
}
.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Tabelle Classifiche e Gestione Gare */
.section-classifiche {
    margin-top: 40px;
    border-top: 2px solid var(--border-color);
    padding-top: 25px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    font-size: 14px;
    margin-top: 15px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

th, td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

th {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
}

th a {
    color: #ffffff;
    text-decoration: none;
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) {
    background-color: #f8fafc;
}

tr:hover {
    background-color: #f1f5f9;
}

tr.tr-donna {
    background-color: #fdf2f8 !important;
}
tr.tr-donna:hover {
    background-color: #fce7f3 !important;
}

.text-center { text-align: center; }
.atleta-link { color: var(--primary-light); text-decoration: none; font-weight: 600; }
.flag-cell { font-size: 18px; text-align: center; }

/* Alert & Notifiche */
.alert, .error {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
}
.alert.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.alert.error, .error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}