/* ============================================================
   RepoWeb — Base CSS (v9)
   ============================================================ */

/* --- Variabili ------------------------------------------------ */
:root {
    --c-primary:    #0f1923;
    --c-primary-h:  #1a2840;
    --c-accent:     #c9a84c;
    --c-bg:         #f0f2f5;
    --c-card:       #ffffff;
    --c-border:     #dde1e7;
    --c-text:       #1a2332;
    --c-text-soft:  #5a6478;
    --c-text-muted: #8a93a2;
    --c-ok:         #1a7a3c;
    --c-warn:       #a05c00;
    --c-error:      #b52a2a;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --radius:       8px;
}

/* --- Reset base ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
}

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

h1 { font-size: 22px; font-weight: 700; margin: 0 0 20px; color: var(--c-text); }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 16px; color: var(--c-text); }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }

p { margin: 0 0 12px; }

/* --- Topbar ---------------------------------------------------- */
header.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 0 24px;
    background: var(--c-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.28);
    border-bottom: 3px solid #c9a84c;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.02em;
    text-decoration: none;
    flex-shrink: 0;
}
.brand:hover { opacity: 0.9; text-decoration: none; color: #fff; }
.brand-logo { height: 38px; width: auto; display: block; filter: brightness(0) invert(1); }

/* Nav principale */
.mainnav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    margin-left: 16px;
    justify-content: center;
}

/* Voci nav di primo livello — bianco su sfondo blu */
.mainnav > a.navitem,
.mainnav > .navgroup > button.navitem {
    color: rgba(255,255,255,0.90) !important;
    background: transparent;
}
.mainnav > a.navitem:hover,
.mainnav > .navgroup > button.navitem:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.12);
    text-decoration: none;
}
.mainnav > a.navitem.active,
.mainnav > .navgroup > button.navitem.active {
    color: #fff !important;
    background: rgba(255,255,255,0.20);
    font-weight: 600;
}

/* Sottovoci dropdown — testo scuro su sfondo bianco */
.navmenu a {
    color: var(--c-text);
    background: transparent;
}
.navmenu a:hover {
    color: var(--c-text);
    background: var(--c-bg);
    text-decoration: none;
}
.navmenu a.active {
    color: #fff;
    background: var(--c-primary);
    font-weight: 600;
}

/* Hamburger (mobile) */
.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 8px;
    color: #fff;
}

/* User box */
.userbox {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}
.user-name {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
}
.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
}
.help-btn:hover { background: rgba(255,255,255,0.28); text-decoration: none; color: #fff; }

/* --- Container principale ------------------------------------- */
main.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* --- Card ----------------------------------------------------- */
.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card:last-child { margin-bottom: 0; }

/* --- KPI grid ------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.kpi {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 14px 16px;
}
.kpi .label {
    font-size: 12px;
    color: var(--c-text-soft);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kpi .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--c-primary);
    line-height: 1.2;
}

/* --- Tabelle -------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table, th, td {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
table.data th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--c-border);
    white-space: nowrap;
    background: var(--c-card);
    font-family: inherit;
}
table.data td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text);
    vertical-align: middle;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f7f9fc; }
table.data th.num,
table.data td.num { text-align: right; }
table.data td.mono,
table.data th.mono,
td.mono, th.mono {
    font-family: inherit !important;
    font-size: 13px !important;
}
table.data td code {
    font-family: inherit !important;
    font-size: inherit !important;
}

/* --- Badge ---------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--c-border);
    color: var(--c-text-soft);
    white-space: nowrap;
}
.badge.ok,
.badge-success {
    background: #d4edda;
    color: #155724;
}
.badge.warn,
.badge-warn {
    background: #fff3cd;
    color: #856404;
}
.badge.error,
.badge-error {
    background: #f8d7da;
    color: #721c24;
}
.badge.info,
.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* --- Pulsanti ------------------------------------------------- */
summary.btn {
    display: inline-flex;
    list-style: none;
    box-sizing: border-box;
}
summary.btn::-webkit-details-marker { display: none; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    background: var(--c-primary);
    color: #fff;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--c-primary-h); text-decoration: none; color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    background: var(--c-card);
    color: var(--c-text);
    border-color: var(--c-border);
}
.btn-secondary:hover { background: var(--c-bg); color: var(--c-text); }

.btn-ghost {
    background: rgba(255,255,255,0.12);
    color: #fff !important;
    border-color: rgba(255,255,255,0.25);
    padding: 6px 12px;
    font-size: 12px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.22); color: #fff !important; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* --- Form elementi -------------------------------------------- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    font-family: inherit;
    font-size: 13px;
    color: var(--c-text);
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 7px 10px;
    outline: none;
    width: 100%;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(10,61,107,0.1);
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-soft);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-row { margin-bottom: 16px; }

/* --- Form grid (filtri multi-colonna) ------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-items: start;
}
.form-grid .form-row { margin-bottom: 0; }

/* --- Alert ---------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-warn  { background: #fff8e1; border-color: #ffe082; color: #7a5200; }
.alert-error { background: #fdecea; border-color: #f5c6cb; color: #7a1a1a; }
.alert-ok    { background: #e8f5e9; border-color: #c8e6c9; color: #1b5e20; }
.alert-info  { background: #e3f2fd; border-color: #b3d9f7; color: #0d3c61; }

/* --- Utility -------------------------------------------------- */
.hidden { display: none !important; }
.mono { font-family: 'Courier New', Courier, monospace; font-size: 12px; }
.num { text-align: right; }
.text-soft  { color: var(--c-text-soft); }
.text-ok    { color: var(--c-ok); }
.text-error { color: var(--c-error); }
.text-warn  { color: var(--c-warn); }

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--c-primary);
}

pre {
    background: #1a2332;
    color: #d4dae4;
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 12px;
    overflow-x: auto;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

/* --- Row actions (tabella sync) ------------------------------- */
.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* --- Footer --------------------------------------------------- */
footer.appfoot {
    text-align: center;
    padding: 28px 20px;
    margin-top: 32px;
    border-top: 1px solid var(--c-border);
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-soft);
    letter-spacing: 0.03em;
}

/* --- Login page ----------------------------------------------- */
.login-wrap,
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
    padding: 24px 16px;
    box-sizing: border-box;
    overflow-y: auto;
}
.login-box {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 24px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-box .brand-logo {
    height: 36px;
    margin: 0 auto 12px;
}
.login-box h1 { font-size: 20px; margin-bottom: 16px; }
.login-box .form-row { margin-bottom: 10px; }
.login-hint {
    font-size: 12px;
    color: var(--c-text-soft);
    margin-top: 20px;
}

/* =====================================================================
   Selettore lingua — posizionato nel .userbox della topbar,
   a sinistra del nome utente.
   ===================================================================== */

/* Wrapper che tiene i link lingua inline */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 4px;
}

/* Ogni link lingua */
.lang-btn {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--c-topbar-text, #e8e0d0);
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 3px;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
    line-height: 1.6;
}

.lang-btn:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.5);
    color: #fff;
    text-decoration: none;
}

/* NOTA: il fix del menu mobile (hamburger + voci + sottomenù) vive
   nella sezione @media (max-width: 900px) di style-repoweb.css. */
