/* ========================================
   AutoricambiPrime - Design System
   Bianco + rosso logo (#C81818)
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@500;600;700;800;900&display=swap');

:root {
    --primary: #c81818;
    --primary-light: #e23a3a;
    --primary-dark: #9a1212;
    --primary-glow: rgba(200, 24, 24, 0.14);
    --accent: #c81818;
    --accent-light: #e85c5c;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #dc2626;
    --dark: #1a2228;
    --dark-2: #243038;
    --dark-3: #33404a;
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --white: #ffffff;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 1px 2px rgba(26, 34, 40, 0.05);
    --shadow: 0 4px 6px -1px rgba(26, 34, 40, 0.07), 0 2px 4px -2px rgba(26, 34, 40, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(26, 34, 40, 0.08), 0 8px 10px -6px rgba(26, 34, 40, 0.04);
    --shadow-lg: 0 20px 50px -12px rgba(26, 34, 40, 0.12);
    --shadow-glow: 0 0 40px rgba(200, 24, 24, 0.12);
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --bs-primary: #c81818;
    --bs-primary-rgb: 200, 24, 24;
    --bs-link-color: #c81818;
    --bs-link-hover-color: #9a1212;
}

/* ---- RESET & BASE ---- */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--white);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
}

::selection {
    background: var(--primary);
    color: var(--white);
}

/* ---- ANIMAZIONI ---- */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.animate-fadeInUp { animation: fadeInUp 0.6s ease-out both; }
.animate-fadeIn   { animation: fadeIn 0.5s ease-out both; }

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

/* ---- NAVBAR ---- */

.navbar-custom {
    background: var(--white) !important;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 0 rgba(200, 24, 24, 0.08);
    padding: 0.55rem 0;
    transition: var(--transition);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    text-decoration: none;
}

.brand-mark img {
    display: block;
    height: 40px;
    width: auto;
    max-width: min(240px, 58vw);
    object-fit: contain;
}

.navbar-custom .brand-mark img {
    height: 40px;
}

.navbar-custom .navbar-brand {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.footer-modern .brand-mark img {
    height: 48px;
    max-width: 280px;
}

.auth-brand .brand-mark img,
.auth-brand img {
    height: 56px;
    max-width: 320px;
}

/* Spaziatura uniforme tra le voci di menu */
.navbar-custom .navbar-nav {
    gap: 0.4rem;
}

.navbar-custom .nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--dark-2) !important;
    padding: 0.55rem 1.1rem !important;
    border-radius: 50px;
    transition: var(--transition);
    position: relative;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.navbar-custom .nav-link:hover {
    color: var(--primary) !important;
    background: var(--primary-glow);
    transform: translateY(-1px);
}

.navbar-custom .nav-link.active {
    color: var(--white) !important;
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(200, 24, 24, 0.25);
}

/* Voce utente / badge non cliccabile: nessun effetto hover */
.navbar-custom .nav-link.disabled {
    color: var(--gray-500) !important;
}

.navbar-custom .nav-link.disabled:hover {
    background: transparent;
    transform: none;
}

.navbar-custom .navbar-toggler {
    border: 1px solid var(--gray-200);
}

.navbar-custom .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%231a2228' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Dropdown profilo (area cliente) */
.navbar-custom .dropdown-menu {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    margin-top: 0.6rem;
}

.navbar-custom .dropdown-item {
    border-radius: var(--radius);
    padding: 0.55rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.navbar-custom .dropdown-item:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.navbar-custom .dropdown-item.text-danger:hover {
    background: #fef2f2;
    color: var(--danger) !important;
}

.navbar-custom .navbar-toggler {
    border-radius: var(--radius);
    padding: 0.35rem 0.6rem;
    transition: var(--transition);
}

.navbar-custom .navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}

/* Su mobile, il menu collassato respira con un po' di spazio verticale */
@media (max-width: 991.98px) {
    .navbar-custom .navbar-nav {
        gap: 0.25rem;
        padding: 0.5rem 0;
    }
    /* Azzera i margini orizzontali pensati per il menu desktop */
    .navbar-custom .navbar-nav.ms-3 { margin-left: 0 !important; }
    .navbar-custom .navbar-nav .nav-item.ms-2 { margin-left: 0 !important; }
    .navbar-custom .navbar-nav.align-items-center {
        align-items: stretch !important;
        border-top: 1px solid var(--gray-200);
        margin-top: 0.5rem;
        padding-top: 0.75rem;
    }
    /* I pulsanti del menu (Accedi/Registrati/Esci) a tutta larghezza e ben tappabili */
    .navbar-custom .navbar-nav .btn {
        width: 100%;
        padding: 0.6rem 1rem;
        margin-top: 0.25rem;
    }
    .navbar-custom .navbar-nav .nav-link {
        padding: 0.6rem 0.5rem;
    }
}

.navbar-client,
.navbar-admin {
    background: var(--white) !important;
}

.navbar-admin {
    border-bottom: 2px solid var(--primary);
}

.navbar-admin-badge {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    background: var(--primary) !important;
    color: var(--white) !important;
}

/* ---- HERO SECTION ---- */

.hero-section {
    background: var(--white);
    position: relative;
    overflow: hidden;
    padding: 4.5rem 0 4rem;
    border-bottom: 1px solid var(--gray-200);
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -15%;
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(200, 24, 24, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -35%;
    left: -10%;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, rgba(26, 34, 40, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite reverse;
}

.hero-section h1 {
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--dark);
}

.hero-section .lead {
    color: var(--gray-600);
}

.hero-highlight {
    color: var(--primary);
}

.hero-stats .fs-3 {
    color: var(--primary);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--primary-glow);
    border: 1px solid rgba(200, 24, 24, 0.18);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--primary);
    backdrop-filter: blur(10px);
    margin-bottom: 1.5rem;
}

.hero-icon-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 280px;
    margin: 0 auto;
}

.hero-icon-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.hero-icon-card:hover {
    background: var(--white);
    transform: translateY(-4px);
    border-color: var(--primary-light);
}

.hero-icon-card i {
    font-size: 2rem;
    color: var(--primary);
}

/* ---- BUTTONS ---- */

/* Tutti i pulsanti in stile "pill" arrotondato, ovunque nel sito */
.btn {
    border-radius: 50px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    line-height: 1.4;
    white-space: nowrap;
}

/* Dimensioni / aree di tocco più comode */
.btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* Feedback di focus accessibile (tastiera) */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.dropdown-item:focus-visible,
a:focus-visible {
    outline: 3px solid var(--primary-glow);
    outline-offset: 1px;
}

/* Stato disabilitato uniforme */
.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Riempimento all'hover per i pulsanti outline (più leggibili) */
.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover,
.btn-outline-secondary:hover {
    box-shadow: var(--shadow-sm);
}

/* Icone dentro i pulsanti perfettamente allineate */
.btn > i.bi {
    line-height: 1;
}

/* Pulsanti dentro input-group: niente lift che sfalsa l'allineamento */
.input-group .btn {
    transform: none !important;
}

/* Gruppi di pulsanti: mantiene gli angoli interni squadrati per coerenza visiva */
.btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-glow {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 50px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(200, 24, 24, 0.28);
    color: var(--white);
}

.btn-glow:hover::before {
    left: 100%;
}

.btn-glass {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--white);
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.btn-glass:hover {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    border: none !important;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(200, 24, 24, 0.22);
}

/* ---- CARDS ---- */

.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

/* Bordo laterale colorato: stesso raggio della card, così prende gli angoli */
.card-accent::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border-left: 4px solid var(--card-accent, var(--primary));
    pointer-events: none;
    z-index: 1;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border-top: 3px solid var(--primary);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- STEP CARDS (Come funziona) ---- */

.step-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    position: relative;
}

.step-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.step-number {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(200, 24, 24, 0.28);
}

.step-card h3,
.step-card h5 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

/* ---- PRICING CARDS ---- */

.pricing-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.pricing-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: calc(var(--radius-xl) - 2px);
    border-top: 4px solid var(--gray-200);
    pointer-events: none;
}

.pricing-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.pricing-card.featured {
    border-color: var(--primary);
    box-shadow: 0 18px 45px rgba(200, 24, 24, 0.16);
    background: linear-gradient(180deg, rgba(200, 24, 24, 0.05), var(--white) 55%);
}

.pricing-card.featured::before {
    border-top-color: var(--primary);
    border-top-width: 5px;
}

.pricing-featured-wrap {
    position: relative;
    display: flex;
    width: 100%;
    padding-top: 0.85rem;
}

.pricing-featured-wrap .pricing-card {
    flex: 1 1 auto;
    width: 100%;
}

@media (min-width: 992px) {
    .pricing-featured-wrap {
        transform: scale(1.06);
        z-index: 2;
    }
    .pricing-featured-wrap:hover {
        transform: scale(1.06) translateY(-8px);
    }
    .pricing-featured-wrap:hover .pricing-card {
        transform: none;
    }
}

/* Badge "più scelto" a metà sul bordo superiore della card */
.pricing-ribbon {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(200, 24, 24, 0.22);
    white-space: nowrap;
    line-height: 1.2;
}

.pricing-amount {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.pricing-period {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ---- FEATURE SECTION ---- */

.feature-item {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.feature-item:hover {
    background: var(--white);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* ---- TABLES ---- */

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table thead th {
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    white-space: nowrap;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200) !important;
    padding: 0.85rem 1rem;
}

.table td {
    vertical-align: middle;
    font-size: 0.875rem;
    padding: 0.85rem 1rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
}

/* Zebra leggera per leggibilità su tabelle lunghe */
.table-hover tbody tr:nth-child(even) {
    background-color: rgba(241, 245, 249, 0.4);
}

.table-hover tbody tr {
    transition: background-color 0.15s ease;
}

.table-hover tbody tr:hover {
    background-color: var(--primary-glow) !important;
}

/* Ultima colonna = azioni: allineata a destra e senza a capo */
.table td:last-child,
.table th:last-child {
    white-space: nowrap;
}

/* Link cliccabili nelle celle */
.table a.text-decoration-none:hover {
    color: var(--primary) !important;
    text-decoration: underline !important;
}

/* Contenitore scrollabile: angoli arrotondati ereditati dalla card,
   scroll fluido su mobile e suggerimento visivo di scroll orizzontale */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Tabelle "compatte" usate nei dettagli */
.table-sm td,
.table-sm th {
    padding: 0.55rem 0.75rem;
}

/* Niente doppio bordo sull'ultima riga dentro una card */
.card .table tbody tr:last-child td {
    border-bottom: 0;
}

/* Le tabelle borderless (dettagli) non mostrano righe divisorie */
.table-borderless td,
.table-borderless th {
    border: 0 !important;
}

/* ---- BADGES ---- */

.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.4em 0.75em;
    border-radius: 50px;
    letter-spacing: 0.02em;
}

/* ---- FORMS ---- */

.form-control, .form-select {
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.65rem 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.92rem;
    color: var(--dark);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) {
    border-color: var(--gray-300);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Stato di errore */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Stato disabilitato/readonly */
.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--dark-2);
    margin-bottom: 0.4rem;
}

.recaptcha-wrap {
    overflow: auto;
    max-width: 100%;
}

@media (max-width: 400px) {
    .recaptcha-wrap {
        transform: scale(0.92);
        transform-origin: left top;
    }
}

.form-text {
    font-size: 0.78rem;
    color: var(--gray-400);
}

/* Input-group: bordi coerenti con i campi */
.input-group-text {
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 600;
}

/* Checkbox/radio più visibili e con focus accessibile */
.form-check-input {
    width: 1.1em;
    height: 1.1em;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-check-label {
    cursor: pointer;
    font-size: 0.92rem;
}

/* Switch un po' più grandi (toggle stato) */
.form-switch .form-check-input {
    width: 2.4em;
    height: 1.25em;
}

/* ---- AUTH PAGES ---- */

.auth-card {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-card .card-body {
    padding: 2.5rem;
}

.auth-card .auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .auth-header h1,
.auth-card .auth-header h3 {
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
}

.auth-card .auth-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(200, 24, 24, 0.28);
}

/* ---- TARGA CODE ---- */

code {
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
    padding: 0.2em 0.55em;
    border-radius: 6px;
    color: var(--dark);
    font-size: 0.85em;
    font-weight: 700;
    font-family: 'Inter', monospace;
    border: 1px solid var(--gray-200);
}

/* ---- FOOTER ---- */

.footer-modern {
    background: var(--white);
    color: var(--gray-600);
    border-top: 1px solid var(--gray-200);
}

.footer-modern h6 {
    color: var(--dark);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.footer-modern a {
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
}

.footer-modern a:hover {
    color: var(--primary);
}

/* ---- ALERTS ---- */

.alert {
    border-radius: var(--radius);
    border: none;
    font-weight: 500;
    font-size: 0.9rem;
    animation: fadeInUp 0.3s ease-out;
}

.alert-success {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #065f46;
}

.alert-danger {
    background: linear-gradient(135deg, #fef2f2, #fecaca);
    color: #991b1b;
}

.alert-warning {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    color: #92400e;
}

.alert-secondary {
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
    color: var(--gray-600);
}

/* ---- SECTION HEADERS ---- */

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-weight: 800;
    font-size: 2.2rem;
    letter-spacing: -0.03em;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--gray-500);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.section-divider {
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    margin: 1rem auto;
}

/* ---- CTA SECTION ---- */

.cta-section {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-radius: var(--radius-xl);
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.cta-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

/* ---- DASHBOARD SPECIFIC ---- */

.welcome-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: var(--radius-xl);
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
}

/* ---- ACCORDION FAQ ---- */

.accordion-button {
    font-weight: 600;
    color: var(--dark);
    border-radius: var(--radius) !important;
}

.accordion-button:not(.collapsed) {
    background: var(--primary-glow);
    color: var(--primary);
    box-shadow: none;
}

.accordion-button:focus {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.accordion-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius) !important;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

/* ---- DROPDOWN (menu azioni, es. "Gestisci") ---- */

.dropdown-menu {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    font-size: 0.9rem;
}

.dropdown-item {
    border-radius: var(--radius);
    padding: 0.55rem 0.9rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--gray-100);
}

/* I form dentro i dropdown (azioni con POST) occupano tutta la larghezza */
.dropdown-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
}

/* ---- PAGE HEADER (titolo pagina + azioni) ---- */

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- TOOLTIP HELPERS ---- */

.cursor-pointer { cursor: pointer; }

/* ---- RESPONSIVE OVERRIDES ---- */

@media (max-width: 768px) {
    .hero-section { padding: 3rem 0; }
    .hero-section h1 { font-size: 2rem; }
    .pricing-amount { font-size: 2.5rem; }
    .section-header h2 { font-size: 1.7rem; }
}

/* Usabilità su tablet/mobile */
@media (max-width: 991.98px) {
    /* Riduce i padding delle celle per far stare più dati */
    .table td, .table thead th { padding: 0.7rem 0.75rem; }

    /* Header di pagina: titolo e pulsanti vanno a capo con spazio */
    .d-flex.justify-content-between.align-items-center.flex-wrap { row-gap: 0.75rem; }
}

@media (max-width: 575.98px) {
    /* Card e contenuti più compatti */
    .card-body { padding: 1rem; }
    .card-body.p-4 { padding: 1.25rem !important; }

    /* Barre di filtri scrollabili orizzontalmente invece di accavallarsi */
    .filter-bar,
    .d-flex.flex-wrap.gap-2[role="group"] {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.4rem;
    }
    .filter-bar .btn,
    .d-flex.flex-wrap.gap-2[role="group"] .btn {
        flex: 0 0 auto;
    }

    /* Pulsanti a tutta larghezza negli header di pagina su schermi piccoli */
    .page-actions .btn { flex: 1 1 auto; }

    /* Titoli un filo più piccoli */
    h4.fw-bold { font-size: 1.25rem; }

    /* Stat number più contenuti */
    .stat-card .stat-number { font-size: 1.6rem; }
}

/* ============================================================
   TABELLE RESPONSIVE: su mobile ogni riga diventa una "scheda"
   con etichetta + valore. Applicare class="table-stack" alla
   <table> e data-label="..." su ogni <td>.
   ============================================================ */
@media (max-width: 767.98px) {
    table.table-stack,
    table.table-stack thead,
    table.table-stack tbody,
    table.table-stack tr,
    table.table-stack td {
        display: block;
        width: 100%;
    }

    /* Nasconde l'intestazione: le etichette arrivano da data-label */
    table.table-stack thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    table.table-stack tbody tr {
        margin-bottom: 1rem;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-lg);
        padding: 0.35rem 0.9rem;
        background: var(--white);
        box-shadow: var(--shadow-sm);
    }

    /* Annulla bordi/hover/striping delle celle in modalità scheda */
    table.table-stack.table-hover tbody tr:hover { background: var(--white); }
    table.table-stack tbody tr > td {
        border: none !important;
        border-bottom: 1px solid var(--gray-100) !important;
        padding: 0.55rem 0;
        text-align: right;
        min-height: 0;
    }
    /* Clearfix: la riga deve contenere l'etichetta in float */
    table.table-stack tbody tr > td::after {
        content: "";
        display: block;
        clear: both;
    }
    table.table-stack tbody tr > td:last-child {
        border-bottom: none !important;
    }

    /* Etichetta a sinistra (float) così i valori multi-riga restano a destra */
    table.table-stack tbody tr > td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--gray-500);
        text-align: left;
        margin-right: 1rem;
        max-width: 45%;
    }

    /* Celle senza etichetta (azioni / stato vuoto): niente label */
    table.table-stack tbody tr > td[data-label=""]::before {
        content: none;
    }

    /* Celle azioni: pulsanti a tutta larghezza e ben tappabili */
    table.table-stack tbody tr > td.td-actions { padding: 0.75rem 0 0.4rem; }
    table.table-stack tbody tr > td.td-actions > .btn { display: block; width: 100%; }
    table.table-stack tbody tr > td.td-actions > .d-flex { display: flex; width: 100%; gap: 0.4rem; }
    table.table-stack tbody tr > td.td-actions > .d-flex > .btn,
    table.table-stack tbody tr > td.td-actions > .d-flex > form { flex: 1 1 auto; }
    table.table-stack tbody tr > td.td-actions > .d-flex > form > .btn { width: 100%; }
    table.table-stack tbody tr > td.td-actions > .dropdown { display: inline-block; }

    /* Celle di "stato vuoto" (colspan) centrate e a tutta larghezza */
    table.table-stack tbody tr > td.text-center {
        text-align: center;
    }
    table.table-stack tbody tr > td.text-center::before { content: none; }

    /* La cella "principale" può essere evidenziata */
    table.table-stack tbody tr > td.td-primary {
        font-weight: 700;
        font-size: 1.02rem;
    }
}

/* Su mobile evita che i contenuti delle card escano e migliora i tap target */
@media (max-width: 575.98px) {
    .btn { padding-top: 0.55rem; padding-bottom: 0.55rem; }
    .btn-sm { padding-top: 0.4rem; padding-bottom: 0.4rem; }
    .table-stack .badge { font-size: 0.75rem; }

    /* Header pagina: titolo sopra, azioni sotto a piena larghezza */
    .page-header-row { flex-direction: column; align-items: stretch !important; }
    .page-header-row .page-actions { width: 100%; }
    .page-header-row .page-actions .btn { width: 100%; }

    /* Evita overflow orizzontale generale */
    body { overflow-x: hidden; }
}

/* Migliora la leggibilità del focus su elementi interattivi via tastiera */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---- SCROLLBAR ---- */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- PAGINAZIONE TABELLE ---- */

.table-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    margin-top: 1rem;
    padding: 0.15rem 0.15rem 0;
}

.card > .table-pagination {
    margin-top: 0;
    padding: 0.75rem 1rem 1rem;
}

.table-pagination-summary {
    font-size: 0.82rem;
    color: var(--gray-500);
}

.table-pagination .pagination {
    --bs-pagination-color: var(--gray-600);
    --bs-pagination-bg: var(--white);
    --bs-pagination-border-color: var(--gray-200);
    --bs-pagination-hover-color: var(--primary);
    --bs-pagination-hover-bg: var(--primary-glow);
    --bs-pagination-hover-border-color: var(--primary-light);
    --bs-pagination-focus-box-shadow: 0 0 0 0.2rem var(--primary-glow);
    --bs-pagination-active-color: var(--white);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-disabled-color: var(--gray-400);
    --bs-pagination-disabled-bg: var(--gray-50);
    gap: 0.3rem;
    margin-left: auto;
}

.table-pagination .page-link {
    min-width: 2.25rem;
    text-align: center;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.65rem;
}

.table-pagination .page-item.active .page-link {
    box-shadow: 0 4px 12px rgba(200, 24, 24, 0.25);
}

@media (max-width: 575.98px) {
    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }
    .table-pagination .pagination {
        justify-content: center;
        margin-left: 0;
    }
    .table-pagination-summary {
        text-align: center;
    }
}

/* ---- PRINT ---- */

@media print {
    .navbar, .btn, footer, .no-print { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
