/* =========================================================
   Domini Manager - overrides Tabler
   Sidebar bianca, brand dot blu Apple, focus ring accessibile
   ========================================================= */

:root {
    --tblr-primary: #0071e3;
    --tblr-primary-rgb: 0, 113, 227;
    --tblr-link-color: #0071e3;
    --brand-dot: linear-gradient(135deg, #0071e3 0%, #5e5ce6 100%);
    --tblr-font-sans-serif: -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "Inter", "Helvetica Neue", system-ui, sans-serif;
}

body {
    font-feature-settings: "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Brand dot blu Apple/indigo */
.brand-dot {
    width: 10px;
    height: 10px;
    background: var(--brand-dot);
}

/* Sidebar bianca con bordo a destra */
.navbar-vertical.navbar-light {
    background: #ffffff !important;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}
.navbar-vertical .navbar-brand {
    padding-block: 1.25rem;
}
.navbar-vertical .nav-link {
    color: #424245;
    border-radius: 8px;
    margin: 1px 8px;
    padding: 0.55rem 0.75rem;
}
.navbar-vertical .nav-link:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}
.navbar-vertical .nav-item.active > .nav-link {
    background: rgba(0, 113, 227, 0.10);
    color: #0071e3;
    font-weight: 500;
}
.navbar-vertical .nav-link-icon i {
    color: inherit;
}
.nav-section-title {
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* Topbar bianca con bordo bottom sottile */
.navbar:not(.navbar-vertical) {
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* Page header: testo a sinistra, azioni a destra, sulla stessa riga.
   Le regole sono volutamente aggressive (!important + margin-left:auto)
   per vincere su qualsiasi default Tabler. */
.page-header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: .75rem 1rem !important;
    text-align: left !important;
    width: 100% !important;
}
.page-header > * { text-align: left; min-width: 0; }
.page-header > *:first-child {
    text-align: left !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    flex: 0 1 auto !important;
}
.page-header > *:not(:first-child) {
    margin-left: auto !important;
    margin-right: 0 !important;
    flex-shrink: 0 !important;
}
/* Solo l'ULTIMO non-primo figlio prende margin-left:auto, gli altri non-primi
   restano vicini all'ultimo (es. CSV+Cestino+Nuovo restano raggruppati) */
.page-header > *:not(:first-child) ~ *:not(:first-child) {
    margin-left: 0 !important;
}
.page-header .page-title { text-align: left !important; margin: 0 !important; }
.page-header .text-secondary { text-align: left !important; }

/* Pulsanti pillola alla Apple per primary */
.btn-primary {
    --tblr-btn-bg: #0071e3;
    --tblr-btn-border-color: #0071e3;
    --tblr-btn-hover-bg: #0058b9;
    --tblr-btn-hover-border-color: #0058b9;
    --tblr-btn-active-bg: #0058b9;
    border-radius: 980px;
    font-weight: 500;
}
.btn-outline-primary {
    --tblr-btn-color: #0071e3;
    --tblr-btn-border-color: #0071e3;
    border-radius: 980px;
}

/* Card con angoli morbidi */
.card {
    border-radius: 14px;
    border-color: rgba(0, 0, 0, 0.08);
}

/* Focus visibile chiaro per accessibilita - WCAG 2.4.7 / 2.4.11 */
*:focus-visible {
    outline: 2px solid #0071e3 !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Aumenta contrasto del testo secondario per WCAG AA */
.text-secondary {
    color: #6e6e73 !important;
}

/* Skip-link visibile in focus */
.visually-hidden-focusable:focus,
.visually-hidden-focusable:focus-within {
    z-index: 9999;
}

/* Campo password con toggle visibilita */
.password-field {
    position: relative;
}
.password-field .form-control {
    padding-right: 2.6rem;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    padding: 0.4rem;
    color: #6e6e73;
    border-radius: 6px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
}
.password-toggle:hover {
    color: #1d1d1f;
    background: rgba(0, 0, 0, 0.04);
}
.password-toggle:focus-visible {
    outline: 2px solid #0071e3;
    outline-offset: 2px;
}
.password-toggle i {
    font-size: 1.1rem;
    display: block;
}

/* Checklist requisiti password */
.password-checklist {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: grid;
    gap: 0.25rem;
    font-size: 0.85rem;
}
.password-checklist li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #6e6e73;
    transition: color 0.15s ease;
}
.password-checklist li::before {
    content: "";
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e6e6eb;
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    line-height: 1;
}
.password-checklist li::before {
    content: "×";
    background: #ffe5e5;
    color: #c0392b;
}
.password-checklist li.valid {
    color: #1f8a3a;
}
.password-checklist li.valid::before {
    content: "✓";
    background: #d4f4dd;
    color: #1f8a3a;
}
.password-checklist li.pending::before {
    content: "•";
    background: #e6e6eb;
    color: #6e6e73;
}
.password-checklist li.pending {
    color: #6e6e73;
}

/* OTP input: 6 box per codice TOTP a 6 cifre */
.otp-group {
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.otp-cell {
    width: 3.2rem;
    height: 3.8rem;
    font-size: 1.75rem;
    font-weight: 600;
    text-align: center;
    border: 1.5px solid rgba(0, 0, 0, 0.16);
    border-radius: 14px;
    background: #ffffff;
    color: #1d1d1f;
    padding: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.otp-cell::-webkit-outer-spin-button,
.otp-cell::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.otp-cell:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.18);
    transform: translateY(-1px);
}
.otp-cell:not(:placeholder-shown) {
    border-color: #1d1d1f;
    background: #fafafa;
}
.otp-cell.otp-error {
    border-color: #c0392b;
    box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.15);
}
@media (max-width: 480px) {
    .otp-cell {
        width: 2.6rem;
        height: 3.2rem;
        font-size: 1.4rem;
    }
}

/* Switch on/off Apple-style: grande, verde quando attivo, focus ring */
.form-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    cursor: pointer;
}
.form-switch .form-check-input {
    width: 3em;
    height: 1.7em;
    margin-top: 0;
    cursor: pointer;
    background-color: #d1d1d6;
    border-color: #d1d1d6;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ffffff'/%3e%3c/svg%3e");
    transition: background-color 0.18s ease, border-color 0.18s ease;
}
.form-switch .form-check-input:focus-visible {
    outline: 2px solid #0071e3;
    outline-offset: 2px;
    box-shadow: none;
}
.form-switch .form-check-input:checked {
    background-color: #34c759; /* verde Apple */
    border-color: #34c759;
}
.form-switch .form-check-label {
    font-weight: 500;
    color: var(--tblr-body-color, #1d1d1f);
    line-height: 1.7em;
}

/* Wrapper per centrare verticalmente uno switch nelle colonne form */
.form-switch-vcentered {
    display: flex;
    align-items: center;
    height: 100%;
    min-height: 2.4rem;
}

/* Bottoni icona azioni tabella - stile uniforme con lamercanti/menogas */
.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    background: #f3f4f6;
    border: 1px solid #e6e7e9;
    border-radius: 0.375rem;
    color: #4b5563;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    aspect-ratio: 1;
    text-decoration: none;
    font-size: 1.1rem;
}
.btn-icon-only:hover,
.btn-icon-only:focus-visible {
    background: #e5e7eb;
    color: #1f2937;
    border-color: #d1d5db;
    outline: none;
}
.btn-icon-only.btn-icon-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}
.btn-icon-only.btn-icon-danger:hover,
.btn-icon-only.btn-icon-danger:focus-visible {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}
.btn-icon-only.btn-icon-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #16a34a;
}
.btn-icon-only.btn-icon-success:hover,
.btn-icon-only.btn-icon-success:focus-visible {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}
.btn-icon-only:disabled,
.btn-icon-only[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
/* Gruppo di btn-icon-only nelle tabelle */
.actions-row {
    display: inline-flex;
    gap: 4px;
    flex-wrap: nowrap;
}
