/*
 * WuguanManager — tema sopra Bootstrap 5.
 * Identità: inchiostro e blu notte, accento "cintura d'oro" usato con parsimonia
 * (voce di menu attiva, stat card, hairline delle card). Tutto il resto quieto.
 */

:root {
    --bp-ink: #212b36;
    --bp-night: #22313f;
    --bp-night-deep: #1a2530;
    --bp-blue: #4a90e2;
    --bp-blue-dark: #3673b8;
    --bp-gold: #d9a441;
    --bp-paper: #f4f6f8;
    --bp-muted: #64707c;
    --bs-body-bg: var(--bp-paper);
    --bs-body-color: var(--bp-ink);
    --bs-link-color: var(--bp-blue);
    --bs-link-hover-color: var(--bp-blue-dark);
    --bs-link-color-rgb: 74, 144, 226;
    --bs-link-hover-color-rgb: 54, 115, 184;
}

body { font-size: 0.95rem; }

.btn-primary {
    --bs-btn-bg: var(--bp-blue);
    --bs-btn-border-color: var(--bp-blue);
    --bs-btn-hover-bg: var(--bp-blue-dark);
    --bs-btn-hover-border-color: var(--bp-blue-dark);
    --bs-btn-active-bg: var(--bp-blue-dark);
    --bs-btn-active-border-color: var(--bp-blue-dark);
}
.btn-outline-primary {
    --bs-btn-color: var(--bp-blue);
    --bs-btn-border-color: var(--bp-blue);
    --bs-btn-hover-bg: var(--bp-blue);
    --bs-btn-hover-border-color: var(--bp-blue);
    --bs-btn-active-bg: var(--bp-blue-dark);
    --bs-btn-active-border-color: var(--bp-blue-dark);
}

/* ---------------------------------------------------------------- layout */
.app-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: 64px 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    min-height: 100vh;
}

.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--bp-night) 0%, var(--bp-night-deep) 100%);
    color: #eef1f4;
    display: flex;
    flex-direction: column;
    --bs-offcanvas-width: 270px; /* larghezza del drawer su mobile */
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; }
.sidebar-brand .brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    line-height: 1.1;
}
.sidebar-brand .brand-sub {
    display: block;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bp-gold);
}

.sidebar-nav { flex: 1; padding: 14px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #aeb9c2;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.sidebar-nav a.active {
    background: rgba(74, 144, 226, 0.16);
    color: #fff;
    border-left-color: var(--bp-gold); /* la "cintura" */
}
.sidebar-nav .nav-ico { width: 1.3em; text-align: center; }

.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.btn-esci {
    background: none;
    border: none;
    padding: 0;
    color: #aeb9c2;
    font-size: 0.9rem;
}
.btn-esci:hover { color: #fff; }

.header {
    grid-area: header;
    background: #fff;
    border-bottom: 1px solid #e4e8ec;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px;
}
.page-title {
    flex: 1;
    min-width: 0;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.burger {
    border: 0;
    background: none;
    padding: 4px 8px;
    font-size: 1.45rem;
    line-height: 1;
    color: var(--bp-ink);
}
.user-profile {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bp-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.15s ease, background-color 0.15s ease;
}
.user-profile:hover { background: var(--bp-blue-dark); color: #fff; transform: scale(1.06); }

.main { grid-area: main; padding: 28px; width: 100%; min-width: 0; }

/* ----------------------------------------------------------------- cards */
.card {
    border: 1px solid #e4e8ec;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(33, 43, 54, 0.05);
    margin-bottom: 24px;
}
.card > .card-body { padding: 22px; }

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bp-muted);
    margin-bottom: 2px;
}
.card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.card-heading h2, .card-heading h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.card-heading h3 { font-size: 1.1rem; }

/* ---------------------------------------------------------------- tables */
.table { --bs-table-hover-bg: #f6f9fd; margin-bottom: 0; }
.table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bp-muted);
    border-bottom-width: 2px;
    white-space: nowrap;
}
.table td { font-variant-numeric: tabular-nums; }
.table td.num, .table th.num { text-align: right; }
.table td.empty {
    text-align: center;
    color: var(--bp-muted);
    padding: 36px 12px;
}

.sort-link { color: var(--bp-muted); text-decoration: none; }
.sort-link:hover { color: var(--bp-blue); }
.sort-link.active { color: var(--bp-blue); }
.sort-arrow { font-size: 0.7em; margin-left: 4px; vertical-align: middle; }

/* ---------------------------------------------------------------- badges */
.badge-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}
.badge-on { background: #e5f4eb; color: #187a45; }
.badge-off { background: #fdecec; color: #b02a2a; }
.badge-warn { background: #fdf1de; color: #8a5800; }
.badge-scope { background: #eaf2fd; color: var(--bp-blue-dark); border-radius: 20px; padding: 3px 10px; font-size: 0.75rem; font-weight: 600; }

/* -------------------------------------------------------------- dashboard */
.welcome { margin-bottom: 20px; font-size: 1.02rem; color: var(--bp-muted); }
.welcome strong { color: var(--bp-ink); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 20px;
}
.stat-card {
    position: relative;
    background: #fff;
    border: 1px solid #e4e8ec;
    border-radius: 12px;
    padding: 26px 22px 22px;
    text-decoration: none;
    color: var(--bp-ink);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: var(--bp-gold); /* la "cintura" */
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(33, 43, 54, 0.1);
    color: var(--bp-ink);
}
.stat-card:hover::after { transform: scaleX(1); }
.stat-card-static:hover {
    transform: none;
    box-shadow: none;
}
.stat-card-static:hover::after { transform: scaleX(0); }
.stat-value {
    display: block;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--bp-blue);
    line-height: 1.1;
}
.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bp-muted);
}

/* -------------------------------------------------------------- toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.toolbar .breadcrumb-line { margin: 0; }
.search-bar { display: flex; gap: 8px; align-items: center; flex: 1; max-width: 560px; }

.breadcrumb-line { color: var(--bp-muted); font-size: 0.88rem; margin-bottom: 16px; }
.breadcrumb-line a { text-decoration: none; }

/* ---------------------------------------------------------------- detail */
.detail-list {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 10px 18px;
    margin: 14px 0 4px;
}
.detail-list dt {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bp-muted);
    align-self: center;
}
.detail-list dd { margin: 0; }

.role-list { list-style: none; padding: 0; margin: 0; }
.role-list li { padding: 7px 0; border-bottom: 1px dashed #e4e8ec; }
.role-list li:last-child { border-bottom: none; }

.practice { margin: 8px 0; border: 1px solid #e4e8ec; border-radius: 8px; padding: 0 14px; }
.practice summary { cursor: pointer; padding: 11px 0; font-weight: 600; }
.practice[open] { padding-bottom: 10px; }

/* ------------------------------------------------------------------ form */
.form-card { max-width: 680px; }
.form-label { font-weight: 600; font-size: 0.85rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--bp-blue);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.15);
}
.static-value { padding: 8px 0; }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px dashed #e4e8ec; }

.team-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.team-row select { flex: 1; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 4px 16px;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e4e8ec;
    border-radius: 8px;
    padding: 10px 12px;
}

.att-table input[type="checkbox"] { width: 18px; height: 18px; }
.att-table input[type="checkbox"]:disabled { opacity: 0.25; }

.report-fields { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.report-fields > div { min-width: 150px; }
.report-submit { margin-left: auto; }

.hint { font-size: 0.83rem; color: var(--bp-muted); }

/* ------------------------------------------------------------------ login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(217, 164, 65, 0.25), transparent 60%),
        linear-gradient(160deg, #204a3d 0%, #10231c 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: "☯";
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 62vw;
    line-height: 1;
    color: rgba(255, 255, 255, 0.05);
    transform: translate(-50%, -50%) rotate(-12deg);
    pointer-events: none;
    user-select: none;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    border-top: 4px solid var(--bp-gold); /* la "cintura" */
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 1;
}
.login-card h1 { text-align: center; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 2px; }
.login-subtitle {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bp-muted);
    margin-bottom: 26px;
}

/* -------------------------------------------------------------- vari */
.export-row { display: flex; gap: 8px; }
.muted { color: var(--bp-muted); }

.alert { border-radius: 10px; }

.nav-tabs .nav-link { color: var(--bp-muted); font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--bp-blue); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- mobile */
/* Sotto lg la sidebar diventa un drawer (offcanvas Bootstrap) aperto dal
   burger nell'header; la griglia perde la colonna di sinistra. */
@media (max-width: 991.98px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr;
        grid-template-areas:
            "header"
            "main";
    }
    .header { padding: 0 14px; }
    .main { padding: 16px; }
    /* Le tabelle larghe scorrono dentro la card, la pagina no */
    .card > .card-body { overflow-x: auto; }
}

@media (max-width: 768px) {
    .detail-list { grid-template-columns: 1fr; gap: 2px; }
    .detail-list dd { margin-bottom: 12px; }
    .report-submit { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-bar { max-width: none; }
}
