/* Override Bootstrap e layout app — vedi claude/DESIGN.md per il design system completo. */

:root {
    --bs-primary: #1F4E79;
    --bs-primary-rgb: 31, 78, 121;
    --bs-body-bg: #F5F6F8;
    --bs-body-color: #1A1F2B;
    --bs-border-color: #D8DCE3;
    --bs-border-radius: 0.375rem;
    --bs-link-color: #1F4E79;
    --bs-link-hover-color: #163A5C;
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-font-monospace: 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace;

    --color-surface: #FFFFFF;
    --color-surface-muted: #ECEEF2;
    --color-border: #D8DCE3;
    --color-text-secondary: #5A6473;

    --header-height: 56px;
    --sidebar-width: 232px;
}

body {
    font-family: var(--bs-font-sans-serif), serif;
    font-size: 0.95rem;
    line-height: 1.4;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.numeric,
.table .numeric,
td.numeric,
th.numeric {
    font-family: var(--bs-font-monospace), serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.input-group-stepper .btn {
    min-width: 2.5rem;
    font-weight: 600;
    line-height: 1;
}

.input-group-stepper input[type=number].numeric {
    text-align: center;
    -moz-appearance: textfield;
}

.input-group-stepper input[type=number].numeric::-webkit-outer-spin-button,
.input-group-stepper input[type=number].numeric::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.btn-primary {
    --bs-btn-bg: #1F4E79;
    --bs-btn-border-color: #1F4E79;
    --bs-btn-hover-bg: #163A5C;
    --bs-btn-hover-border-color: #163A5C;
    --bs-btn-active-bg: #163A5C;
    --bs-btn-active-border-color: #163A5C;
    font-weight: 600;
}

.material-symbols-outlined {
    font-size: 1.1em;
    vertical-align: middle;
    color: currentColor;
}

/* ------------------------------------------------------------------
   Layout pubblico (home, login)
------------------------------------------------------------------ */
.public-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.public-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}

.login-card__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card__header .material-symbols-outlined {
    font-size: 2.25rem;
    color: var(--bs-primary);
    margin-bottom: 0.5rem;
    display: block;
}

/* ------------------------------------------------------------------
   Layout app (header + sidebar + main)
------------------------------------------------------------------ */
.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bs-primary);
    text-decoration: none;
}

.app-header__brand:hover {
    color: var(--bs-link-hover-color);
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-header__user-name {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.app-header__logout {
    margin: 0;
}

.app-shell {
    display: flex;
    flex: 1;
    min-height: 0;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface-muted);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    flex-shrink: 0;
}

.app-sidebar__group + .app-sidebar__group {
    margin-top: 1.25rem;
}

.app-sidebar__group-title {
    padding: 0 1rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
}

.app-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-sidebar__item a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.app-sidebar__item a:hover {
    background: var(--color-surface);
}

.app-sidebar__item.is-active a {
    background: var(--color-surface);
    color: var(--bs-primary);
    font-weight: 600;
    border-left-color: var(--bs-primary);
}

.app-main {
    flex: 1;
    padding: 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------------
   Componenti
------------------------------------------------------------------ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 0.375rem;
    background: var(--color-surface-muted);
    color: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card__icon .material-symbols-outlined {
    font-size: 1.4rem;
}

.stat-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
}

.stat-card__value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--bs-body-color);
}

.empty-state {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-text-secondary);
}

.empty-state .material-symbols-outlined {
    color: var(--bs-primary);
    font-size: 1.5rem;
}

.alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ------------------------------------------------------------------
   Risultati: barre proporzionali
------------------------------------------------------------------ */
.bar-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 3fr minmax(120px, auto);
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
}

.bar-row:last-child {
    border-bottom: none;
}

.bar-row__bar {
    background: var(--color-surface-muted);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.bar {
    height: 100%;
    background: var(--color-text-secondary);
    transition: width 0.3s ease;
}

.bar.bar--nostro {
    background: var(--bs-primary);
}

.bar-row__value {
    text-align: right;
    white-space: nowrap;
}

.display-stat {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--bs-primary);
    text-align: center;
    padding: 1rem 0;
}

.display-stat .numeric {
    font-family: var(--bs-font-monospace), serif;
}

/* ------------------------------------------------------------------
   Responsive
------------------------------------------------------------------ */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }
    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .app-main {
        padding: 1rem;
    }
}
