/* =============================================================
   Lista Cinture Nere BJJ Italia — Stylesheet
   Basato sul design system Grappling Italia
   ============================================================= */

:root {
    --bg:           #f5f3ef;
    --surface:      #fff;
    --surface-2:    #f0ece6;
    --surface-3:    #e8e4dc;
    --border:       #ddd8d0;
    --border-hover: #c8c3b8;
    --text:         #1a1816;
    --text-dim:     #5c5650;
    --text-muted:   #9a9490;
    --accent:       #9a7b2e;
    --accent-dim:   rgba(154,123,46,.12);

    --success-bg: #dcf5e0;
    --success-text: #1d5b2c;
    --error-bg:   #f8e0e0;
    --error-text: #842020;
    --warning-bg: #fbf1d0;
    --warning-text: #7a5e10;

    --radius:    8px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow:    0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.10);

    --max-w: 1100px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

/* ============= SITE NAVBAR (top bar nera) ============= */
.site-nav {
    background: #1a1816;
    border-bottom: 1px solid #2a2724;
    position: sticky;
    top: 0;
    z-index: 300;
}
.site-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 20px;
}
.site-nav-logo {
    color: var(--accent);
    font-family: 'Instrument Serif', serif;
    font-size: 22px;
    font-style: italic;
    text-decoration: none;
    letter-spacing: -0.01em;
}
.site-nav-logo:hover { text-decoration: none; }
.site-nav-links { display: flex; gap: 4px; flex: 1; }
.site-nav-links a {
    color: #b0aaa0;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all .2s;
    white-space: nowrap;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.site-nav-links a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.site-nav-links a.active { color: #fff; background: rgba(255,255,255,.1); }

@media (max-width: 768px) {
    .site-nav-inner { padding: 0 16px; gap: 12px; }
    .site-nav-links { display: none; }
}

/* ============= USER BAR (sotto la navbar) ============= */
.user-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
}
.user-bar-inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.user-bar-greeting {
    font-size: 13px;
    color: var(--text-dim);
}
.user-bar-greeting strong {
    color: var(--text);
    font-weight: 500;
}
.user-bar-link, .user-bar-login {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    padding: 6px 16px;
    border: 1px solid var(--accent);
    border-radius: 100px;
    transition: all .2s;
    line-height: 1;
}
.user-bar-link:hover, .user-bar-login:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}
.user-bar-logout {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
}
.user-bar-logout:hover { color: var(--text); text-decoration: underline; }

/* ============= MAIN ============= */
.site-main { padding: 24px 0 60px; min-height: 60vh; }

h1 {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(32px, 4.5vw, 48px);
    font-weight: 400;
    letter-spacing: -.02em;
    line-height: 1.1;
    margin: 0 0 12px;
    color: var(--text);
}
h1 span.accent { color: var(--accent); font-style: italic; }

h2 {
    font-family: 'Instrument Serif', serif;
    font-size: 26px;
    font-weight: 400;
    letter-spacing: -.01em;
    margin: 32px 0 14px;
    color: var(--text);
}

h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 10px;
    color: var(--text);
}

.lead {
    color: var(--text-dim);
    font-size: 16px;
    margin: 0 0 28px;
    line-height: 1.6;
    max-width: 680px;
}

p { margin: 0 0 12px; }

/* ============= BUTTONS ============= */
.btn {
    display: inline-block;
    padding: 11px 20px;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 100px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    line-height: 1;
}
.btn:hover {
    background: #7d6324;
    border-color: #7d6324;
    text-decoration: none;
    color: #fff;
}
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-outline {
    background: transparent;
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-hover); color: var(--text); }
.btn-danger {
    background: #b53030;
    border-color: #b53030;
}
.btn-danger:hover { background: #931e1e; border-color: #931e1e; }

/* ============= ALERTS ============= */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin: 0 0 18px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: rgba(29,91,44,.15); }
.alert-error   { background: var(--error-bg);   color: var(--error-text);   border-color: rgba(132,32,32,.15); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: rgba(122,94,16,.15); }

/* ============= FORM ============= */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 200px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=file], select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    background: var(--surface);
    color: var(--text);
    transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Honeypot */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.checkbox-grid label {
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

/* ============= FILTRI ============= */
.filters {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

/* ============= LISTA ATLETI (paragrafata, stile Grappling Italia) ============= */
.results-meta {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.athlete-list {
    list-style: none;
    padding: 0;
    margin: 0 0 32px;
}
.athlete-item {
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.55;
}
.athlete-item:last-child { border-bottom: none; }

.athlete-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.athlete-name a {
    color: var(--text);
    text-decoration: none;
}
.athlete-name a:hover {
    color: var(--accent);
    text-decoration: none;
}
.athlete-nick {
    font-weight: 400;
    color: var(--text-muted);
    font-style: italic;
}

.athlete-info {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 2px;
}
.athlete-info a {
    color: var(--accent);
    text-decoration: none;
}
.athlete-info a:hover { text-decoration: underline; }

.athlete-lineage {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    word-break: break-word;
}
.lineage-label {
    color: var(--text-muted);
    font-weight: 500;
}

/* Badge verificato minimale: pallino verde con spunta */
.verified-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
}
.verified-dot svg { display: block; }

/* Badge "sincronizzata da WordPress": quadratino blu con W */
.wp-sync-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #21759b;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.wp-sync-dot::before { content: "W"; }

/* Logo Grappling Italia nella scheda atleta (accanto al nome palestra WP-sync) */
.gi-brand-badge {
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    object-fit: contain;
}

/* Claim in alto (duplicato del bottone in fondo scheda) */
.claim-top { margin: 16px 0 24px; }
.claim-top details[open] summary { margin-bottom: 4px; }

/* Nav badge (pallino rosso con numero su voce sidebar admin) */
.nav-badge {
    display: inline-block;
    min-width: 20px;
    padding: 2px 7px;
    margin-left: 6px;
    background: #c53030;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    vertical-align: middle;
}

/* Social icons nella scheda atleta */
.social-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s ease;
    background: var(--surface);
}
.social-icon:hover {
    border-color: var(--accent, #9a7b2e);
    color: var(--accent, #9a7b2e);
    transform: translateY(-1px);
}
.social-icon-external {
    width: auto;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.social-icon-external .external-label { white-space: nowrap; }

/* Badge generico (in memoriam ecc.) */
.badge {
    display: inline-block;
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.badge-memoriam { background: #f0ece6; color: #5c5650; }

/* ============= LISTA CARDS (deprecato, mantenuto per compat) ============= */
.person-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 700px)  { .person-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .person-grid { grid-template-columns: 1fr 1fr 1fr; } }

.person-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    background: var(--surface);
    transition: box-shadow .2s, border-color .2s, transform .15s;
}
.person-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}
.person-card a { color: var(--text); text-decoration: none; }
.person-card a:hover { text-decoration: none; }
.person-card h3 {
    margin: 0 0 6px;
    font-family: 'Instrument Serif', serif;
    font-size: 20px;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-transform: none;
}
.person-card .meta {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}
.person-card .meta .gym { display: block; margin-bottom: 2px; }
.person-card .badges { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }

/* ============= PAGINATION ============= */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin: 28px 0; justify-content: center; }
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    background: var(--surface);
    transition: all .2s;
}
.pagination a:hover { background: var(--surface-2); border-color: var(--border-hover); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============= SCHEDA ATLETA ============= */
.person-header { margin-bottom: 28px; }
.person-header h1 { margin: 0 0 6px; }
.person-nickname {
    color: var(--text-dim);
    font-style: italic;
    font-family: 'Instrument Serif', serif;
    font-size: 18px;
}
.person-section { margin: 32px 0; }
.person-section h2 {
    font-size: 22px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.lineage-chain {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.9;
    word-break: break-word;
    font-family: 'JetBrains Mono', monospace;
}
.lineage-chain .sep { color: var(--text-muted); margin: 0 6px; }
.lineage-chain a { color: var(--accent); font-weight: 500; }
.lineage-chain strong { color: var(--text); font-weight: 600; }

.info-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.info-table th, .info-table td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-table tr:last-child th, .info-table tr:last-child td { border-bottom: none; }
.info-table th {
    width: 35%;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.06em;
    background: var(--surface-2);
}

.results-list { padding-left: 22px; margin: 12px 0; }
.results-list li { margin-bottom: 6px; line-height: 1.5; }

.biography {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 18px 22px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 15px;
    line-height: 1.7;
}
.biography p { margin-bottom: 12px; }
.biography p:last-child { margin-bottom: 0; }

/* ============= LIGNAGGIO PAGE ============= */
.lineage-breadcrumb {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ============= FOOTER ============= */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 60px;
}
.site-footer a { color: var(--text-dim); }
.footer-credits { margin-top: 10px; }

/* ============= ADMIN ============= */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; min-height: 80vh; }
@media (max-width: 800px) { .admin-layout { grid-template-columns: 1fr; } }

.admin-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: var(--radius-lg);
    height: fit-content;
    box-shadow: var(--shadow-sm);
}
.admin-sidebar h3 {
    margin: 0 0 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}
.admin-sidebar nav a {
    display: block;
    padding: 9px 12px;
    color: var(--text);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all .15s;
    margin-bottom: 2px;
}
.admin-sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.admin-sidebar nav a.active { background: var(--accent-dim); color: var(--accent); }

.admin-content { min-width: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.kpi .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 32px;
    font-weight: 500;
    color: var(--accent);
    line-height: 1.2;
}
.kpi .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th, .data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table tr:last-child td { border-bottom: none; }
.data-table th {
    background: var(--surface-2);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}
.data-table tr:hover td { background: var(--surface-2); }

.diff-add { background: var(--success-bg); color: var(--success-text); padding: 2px 8px; border-radius: 3px; }
.diff-del { background: var(--error-bg); color: var(--error-text); padding: 2px 8px; border-radius: 3px; text-decoration: line-through; }

/* ============= AUTOCOMPLETE ============= */
.autocomplete-wrap { position: relative; }
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}
.autocomplete-results .item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--surface-2);
    transition: background .1s;
}
.autocomplete-results .item:last-child { border-bottom: none; }
.autocomplete-results .item:hover, .autocomplete-results .item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

/* ============= UTIL ============= */
.link-muted { color: var(--text-muted); font-size: 13px; }
.link-muted:hover { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 24px; }
.hidden { display: none; }

code, pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 3px;
    color: var(--text);
}
pre { padding: 14px 16px; overflow-x: auto; line-height: 1.5; }


/* Foto profilo atleta */
.person-header { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.athlete-photo, .athlete-photo-fallback {
    width: 140px; height: 140px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--border);
}
.athlete-photo-fallback {
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.athlete-photo-fallback svg { width: 70%; height: 70%; }
.person-header-text { flex: 1; min-width: 240px; }
@media (max-width: 600px) {
    .athlete-photo, .athlete-photo-fallback { width: 100px; height: 100px; }
}


/* Form row a 2 colonne (es. categorie peso nel person form) */
.form-row-2col .form-group { flex: 0 0 calc(50% - 7px); min-width: 220px; }

/* Featured section (home "in evidenza") */
.featured-section { margin: 24px 0 32px; }
.featured-section h2 { font-size: 18px; margin: 20px 0 12px; }
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.featured-card {
    display: block;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
}
.featured-card:hover {
    border-color: var(--accent, #9a7b2e);
    transform: translateY(-1px);
}
.featured-card-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}
.featured-card-info {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.4;
}
