/* ═══════════════════════════════════════════════════
   AUTH SERVER — Olivo Group Design System
   ═══════════════════════════════════════════════════ */

:root {
    /* ── Typography ──────────────────────── */
    --font-display: 'Sora', sans-serif;
    --font-body: 'DM Sans', sans-serif;

    /* ── Accent: Warm Amber ──────────────── */
    --accent: #e8a838;
    --accent-warm: #d4782f;
    --accent-muted: rgba(232, 168, 56, 0.35);

    /* ── Surfaces ────────────────────────── */
    --bg-surface: #f4f5f7;
    --bg-card: #ffffff;
    --sidebar-bg: #0c1322;

    /* ── Text ────────────────────────────── */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;

    /* ── Borders ─────────────────────────── */
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-default: rgba(0, 0, 0, 0.12);

    /* ── Status ──────────────────────────── */
    --success: #10b981;
    --danger: #ef4444;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

/* ── Login page ──────────────────────────── */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 2rem;
    text-align: center;
}

.login-header .brand-logo {
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-header .brand-logo img {
    width: 190px;
    height: 86px;
    object-fit: contain;
}

.login-header h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.login-header p {
    font-size: 0.85rem;
    opacity: 0.5;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.login-body {
    padding: 2rem;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-google:hover {
    background-color: var(--bg-surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-muted);
}

.btn-google:active {
    background-color: #eee;
}

.google-icon {
    flex-shrink: 0;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1rem;
    color: var(--accent-warm);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color 0.18s ease;
}

.btn-link:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Admin pages ─────────────────────────── */

.admin-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.admin-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.admin-header {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 1.5rem 2rem;
}

.admin-header h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.admin-header p {
    font-size: 0.85rem;
    opacity: 0.5;
}

.admin-body {
    padding: 1.5rem 2rem;
}

.admin-footer-links {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

/* ── Barra di navigazione ────────────────── */

.app-nav {
    background: var(--sidebar-bg);
    color: #fff;
}

/* Stessi limiti di .admin-container, così il logo si allinea al bordo della scheda */
.app-nav-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-height: 56px;
    flex-wrap: wrap;
}

.app-nav-brand {
    display: flex;
    align-items: center;
}

.app-nav-brand img {
    height: 26px;
    width: auto;
    display: block;
}

/* Accanto al logo, attenuata come l'email: un'informazione, non una voce di menu */
.app-nav-version {
    margin-left: -0.75rem;
    font-family: var(--font-display);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
}

.app-nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: auto;
}

.nav-link {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.18s ease;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}

.nav-link.active {
    color: #fff;
    background: rgba(232, 168, 56, 0.16);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.app-nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-nav-email {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.btn-logout {
    padding: 0.35rem 0.75rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.07);
}

/* ── Panoramica ──────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.stat-tile {
    padding: 1rem 1.125rem;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--bg-surface);
}

.stat-tile.stat-warn {
    border-color: rgba(232, 168, 56, 0.35);
    background: rgba(232, 168, 56, 0.06);
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-tile.stat-warn .stat-value {
    color: var(--accent-warm);
}

.stat-label {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

.role-bars,
.attention-list {
    list-style: none;
    margin: 0 0 2rem;
    padding: 0;
}

.role-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
}

.role-bar-row .badge {
    flex: 0 0 auto;
    min-width: 5.5rem;
    text-align: center;
}

.role-bar-track {
    flex: 1 1 auto;
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.role-bar-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
}

.role-bar-count {
    flex: 0 0 auto;
    min-width: 6.5rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.attention-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.attention-who {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.9375rem;
}

.attention-who .text-muted {
    font-size: 0.8rem;
}

.badge-warn { background: rgba(232, 168, 56, 0.14); color: var(--accent-warm); }

/* ── Users table ─────────────────────────── */

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 2px solid var(--border-default);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.users-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9375rem;
}

.users-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ── Badges ──────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Fallback per i ruoli personalizzati; le regole seguenti lo sovrascrivono */
.badge-role { background: var(--accent-muted); color: var(--accent-warm); }

.badge-admin { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.badge-editor { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.badge-viewer { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge-none { background: rgba(0, 0, 0, 0.04); color: var(--text-tertiary); }
.badge-system { background: rgba(232, 168, 56, 0.12); color: var(--accent-warm); }

.badge-list {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ── Forms ────────────────────────────────── */

.role-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.18s ease;
}

.role-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.btn-save {
    padding: 0.4rem 0.85rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-save:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 12px var(--accent-muted);
}

.role-input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.18s ease;
}

.role-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.role-create-form {
    margin-bottom: 1.5rem;
}

.role-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-delete {
    padding: 0.4rem 0.85rem;
    background: transparent;
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-secondary {
    padding: 0.4rem 0.85rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.admin-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.25rem;
}

.text-muted {
    color: var(--text-tertiary);
}

/* ── Modali ──────────────────────────────── */

dialog.app-modal {
    /* Il reset globale (* { margin: 0 }) sovrascrive il margin:auto dello user agent
       con cui una dialog modale si centra: senza questo finisce in alto a sinistra. */
    margin: auto;
    width: min(440px, calc(100vw - 2rem));
    padding: 0;
    border: none;
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 24px 60px rgba(12, 19, 34, 0.28);
    overflow: hidden;
}

dialog.app-modal::backdrop {
    background: rgba(12, 19, 34, 0.55);
    backdrop-filter: blur(2px);
}

.modal-header {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 1.125rem 1.5rem;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.modal-header p {
    font-size: 0.8rem;
    opacity: 0.5;
    word-break: break-all;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: min(60vh, 26rem);
    overflow-y: auto;
}

/* display:block anche per fieldset: un <legend> in un contenitore flex non è affidabile */
.modal-field {
    display: block;
    border: none;
    padding: 0;
    margin: 0;
}

.modal-field > span,
.modal-field > legend {
    display: block;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0;
    margin-bottom: 0.375rem;
}

.modal-field .role-input {
    width: 100%;
}

/* Conferme: paragrafi ravvicinati, non campi distanziati */
.modal-confirm {
    gap: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

/* In una conferma l'eliminazione è l'azione principale: pieno, non solo bordato */
.modal-footer .btn-delete {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.modal-footer .btn-delete:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.checkbox-item:hover {
    background: var(--bg-surface);
}

.checkbox-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Alerts ──────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Scrollbar ───────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

::selection {
    background: var(--accent-muted);
    color: var(--text-primary);
}
