/* =========================================================
   G.S. CRIS — Stili area amministrativa
   ========================================================= */

:root {
    --green: #1f8a4c;
    --green-dark: #156638;
    --ink: #1a1f24;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f6f5;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.muted { color: var(--muted); }

/* --- Bottoni --- */
.btn { display: inline-block; padding: .6rem 1.2rem; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; background: #e5e7eb; color: var(--ink); }
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }

/* --- Login --- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.auth-wrap { width: 100%; max-width: 380px; padding: 1.5rem; }
.auth-card { background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.auth-title { margin: 0 0 .25rem; }
.auth-sub { margin: 0 0 1.5rem; color: var(--muted); font-size: .9rem; }
.field { display: block; margin-bottom: 1rem; }
.field span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.field input, .field textarea { width: 100%; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; font-family: inherit; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
.field-check { flex-direction: row; align-items: center; gap: .6rem; }
.field-check input { width: auto; }
.field-check span { margin: 0; font-weight: 600; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* --- Layout admin --- */
.admin-body { display: flex; min-height: 100vh; }
.admin-sidebar { width: 230px; background: var(--ink); color: #cbd5e1; flex-shrink: 0; }
.admin-brand { padding: 1.25rem 1.5rem; font-weight: 800; font-size: 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-brand small { display: block; font-size: .7rem; font-weight: 500; opacity: .6; text-transform: uppercase; letter-spacing: 1px; }
.admin-nav { display: flex; flex-direction: column; padding: .75rem 0; }
.admin-nav a { color: #cbd5e1; padding: .7rem 1.5rem; }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.admin-nav a.disabled { opacity: .4; pointer-events: none; }

.admin-main { flex: 1; display: flex; flex-direction: column; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.admin-page-title { font-weight: 600; }
.admin-user { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.admin-content { padding: 1.75rem 1.5rem; }

/* --- Dashboard --- */
.welcome h1 { margin: 0 0 .25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--green); }
.stat-label { color: var(--muted); font-size: .85rem; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }

/* --- Toolbar pagina --- */
.page-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.page-toolbar h1 { margin: 0; font-size: 1.5rem; }

/* --- Filtri --- */
.filterbar { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.field-inline { display: flex; flex-direction: column; gap: .3rem; }
.field-inline label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field-inline select, .field-inline input { padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; min-width: 200px; }

/* --- Tabelle dati --- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: #fafafa; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table tr:last-child td { border-bottom: 0; }
.ta-right { text-align: right; }
.actions { white-space: nowrap; }
.actions .btn { margin-left: .25rem; }
form.inline { display: inline; }

/* --- Badge --- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.badge-bozza { background: #fef3c7; color: #92400e; }
.badge-validata { background: #dbeafe; color: #1e40af; }
.badge-completata { background: #dcfce7; color: #166534; }
.badge-pub { background: var(--green); color: #fff; }

/* --- Bottoni colorati --- */
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }

/* --- Form di dettaglio / modifica --- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .25rem 2rem; }
.form-row { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); }
.form-row .lbl { color: var(--muted); font-size: .85rem; }
.form-row .val { font-weight: 600; text-align: right; }
.form-grid.editable { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-grid.editable .field { display: flex; flex-direction: column; gap: .35rem; }
.form-grid.editable .field span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-grid.editable input, .form-grid.editable select { padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.hint { color: #92400e; font-size: .78rem; margin-top: .25rem; }

/* --- Colonne affiancate (gestione squadre/allenatori) --- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.panel + .panel { margin-top: 1.25rem; }
.cols .panel + .panel { margin-top: 0; }
.add-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.add-row select { flex: 1; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* --- Documenti --- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.doc-item { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.doc-label { font-weight: 700; margin-bottom: .35rem; }
.doc-current { font-size: .85rem; margin-bottom: .6rem; }

.alert-success { background: #dcfce7; color: #166534; }

/* --- Condivisione link/QR upload documenti --- */
.upload-share { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; margin-top: 1rem; }
.upload-share-main { flex: 1; min-width: 280px; }
.upload-share-qr { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.upload-share-qr #qrcode { padding: .6rem; background: #fff; border: 1px solid var(--border); border-radius: 10px; line-height: 0; }
.copy-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.copy-input { flex: 1; min-width: 220px; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; background: #f9fafb; color: var(--ink); }
.share-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .9rem 0 .25rem; }
.btn-whatsapp { display: inline-flex; align-items: center; gap: .5rem; background: #25d366; color: #fff; }
.btn-whatsapp svg { display: block; }
.btn-whatsapp:hover { background: #1ebe5d; color: #fff; filter: none; text-decoration: none; }

a.stat-card { color: inherit; text-decoration: none; transition: box-shadow .18s ease, border-color .18s ease; }
a.stat-card:hover { text-decoration: none; border-color: var(--green); box-shadow: 0 6px 18px rgba(16,40,28,.09); }

/* --- Anteprima copertina news --- */
.cover-current { display: flex; gap: 1rem; align-items: flex-start; margin: .5rem 0 .9rem; flex-wrap: wrap; }
.cover-current img { width: 240px; aspect-ratio: 16 / 9; object-fit: contain; background: #f1f5f9;
    border: 1px solid var(--border); border-radius: 10px; }

/* --- Galleria fotografica --- */
.panel-title { margin: 0 0 1rem; font-size: 1.05rem; }
.small { font-size: .82rem; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.upload-form .upload-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.upload-form .field { flex: 1; min-width: 240px; margin-bottom: 0; }
.upload-form .btn { flex-shrink: 0; }
.upload-form .muted { margin: .9rem 0 0; }

.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; margin-top: 1rem; }
.foto-card { margin: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.foto-card.is-hidden { opacity: .6; }
.foto-thumb { display: block; position: relative; aspect-ratio: 4 / 3; background: #f1f5f9; }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-flag { position: absolute; top: .5rem; left: .5rem; background: rgba(15,23,42,.82); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: .15rem .55rem; border-radius: 999px; }
.foto-body { padding: .9rem; display: flex; flex-direction: column; gap: .5rem; }
.foto-body .field { margin-bottom: .45rem; }
.foto-body .field span { font-size: .74rem; font-weight: 600; color: var(--muted); }
.foto-body .field input { padding: .45rem .6rem; font-size: .9rem; }
.foto-info { margin: 0; word-break: break-all; }
.foto-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); padding-top: .65rem; }
.foto-actions .btn { margin: 0; }

@media (max-width: 820px) {
    .form-grid, .form-grid.editable { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .admin-sidebar { width: 64px; }
    .admin-brand small { display: none; }
}
