/**
 * Bootstrap Italia Custom Styles
 * Design System della Pubblica Amministrazione Italiana
 *
 * Questo file applica i principi di design, colori e UX/UI di Bootstrap Italia
 * mantenendo la compatibilità con Bootstrap 5
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Palette Bootstrap Italia)
   ============================================ */
:root {
    /* Colori Primari */
    --bs-primary: #0066CC;
    --bs-primary-rgb: 0, 102, 204;
    --bs-secondary: #5C6F82;
    --bs-secondary-rgb: 92, 111, 130;
    --bs-success: #008758;
    --bs-success-rgb: 0, 135, 88;
    --bs-info: #0073E6;
    --bs-info-rgb: 0, 115, 230;
    --bs-warning: #A66300;
    --bs-warning-rgb: 166, 99, 0;
    --bs-danger: #D9364F;
    --bs-danger-rgb: 217, 54, 79;

    /* Colori di Supporto */
    --bi-analogue-1: #0059B3;
    --bi-analogue-2: #1A8CFF;
    --bi-complementary-1: #CC7A00;
    --bi-complementary-2: #E68A00;

    /* Grigi - WCAG AA Compliant */
    --bs-gray-100: #F5F6F7;
    --bs-gray-200: #E5E9EB;
    --bs-gray-300: #C1C7CD;
    --bs-gray-400: #919BA5;
    --bs-gray-500: #5C6F82;
    --bs-gray-600: #435A70;
    --bs-gray-700: #2D3E50;
    --bs-gray-800: #1C2A38;
    --bs-gray-900: #0D1821;

    /* Tipografia */
    --bs-font-sans-serif: "Titillium Web", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-font-monospace: "Roboto Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-font-size: 1rem;
    --bs-body-font-weight: 400;
    --bs-body-line-height: 1.5;

    /* Shadows */
    --bi-shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --bi-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
    --bi-shadow-lg: 0 8px 16px 0 rgba(0, 0, 0, 0.15);
    --bi-shadow-xl: 0 16px 32px 0 rgba(0, 0, 0, 0.2);

    /* Border Radius */
    --bs-border-radius: 4px;
    --bs-border-radius-sm: 2px;
    --bs-border-radius-lg: 8px;
    --bs-border-radius-xl: 16px;

    /* Transitions */
    --bi-transition-base: all 0.3s ease-in-out;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
body {
    font-family: var(--bs-font-sans-serif);
    font-size: var(--bs-body-font-size);
    font-weight: var(--bs-body-font-weight);
    line-height: var(--bs-body-line-height);
    color: var(--bs-gray-900);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--bs-gray-900);
}

h1, .h1 { font-size: 2.5rem; }
h2, .h2 { font-size: 2rem; }
h3, .h3 { font-size: 1.75rem; }
h4, .h4 { font-size: 1.5rem; }
h5, .h5 { font-size: 1.25rem; }
h6, .h6 { font-size: 1rem; }

/* ============================================
   NAVBAR (Bootstrap Italia Style)
   ============================================ */
.navbar {
    box-shadow: var(--bi-shadow);
    border-bottom: 2px solid var(--bs-primary);
    transition: var(--bi-transition-base);
}

.navbar-dark {
    background-color: var(--bs-primary) !important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    transition: var(--bi-transition-base);
}

.navbar-brand:hover {
    transform: translateY(-2px);
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--bi-transition-base);
    position: relative;
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after,
.navbar-nav .nav-link.active::after {
    width: 80%;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.95) !important;
    transform: translateY(-2px);
}

/* Icone navbar - dimensioni contenute */
.navbar-nav .nav-link i,
.navbar-brand i {
    font-size: 1rem;
    margin-right: 0.25rem;
}

.navbar .btn i {
    font-size: 0.95rem;
}

/* ============================================
   BUTTONS (Bootstrap Italia Style)
   ============================================ */
.btn {
    font-weight: 600;
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 1.5rem;
    transition: var(--bi-transition-base);
    border-width: 2px;
    text-transform: none;
}

.btn:focus,
.btn:active:focus {
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.25);
}

.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--bi-analogue-1);
    border-color: var(--bi-analogue-1);
    transform: translateY(-2px);
    box-shadow: var(--bi-shadow);
}

.btn-primary:active {
    background-color: var(--bi-analogue-1);
    border-color: var(--bi-analogue-1);
}

.btn-outline-primary {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.btn-outline-primary:hover {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--bi-shadow);
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.8);
    color: rgba(255, 255, 255, 0.9);
    border-width: 2px;
}

.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    color: #fff;
    transform: translateY(-2px);
}

.btn-outline-danger {
    border-color: var(--bs-danger);
    color: var(--bs-danger);
}

.btn-outline-danger:hover {
    background-color: var(--bs-danger);
    border-color: var(--bs-danger);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--bi-shadow);
}

.btn-success {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.btn-success:hover {
    background-color: #006644;
    border-color: #006644;
    transform: translateY(-2px);
    box-shadow: var(--bi-shadow);
}

/* ============================================
   CARDS (Bootstrap Italia Style)
   ============================================ */
.card {
    border: none;
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--bi-shadow);
    transition: var(--bi-transition-base);
    overflow: hidden;
}

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

.card-header {
    background-color: var(--bs-gray-100);
    border-bottom: 2px solid var(--bs-primary);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    color: var(--bs-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.card-footer {
    background-color: var(--bs-gray-100);
    border-top: 1px solid var(--bs-gray-300);
}

/* Card con icona */
.card .bi {
    font-size: 2.5rem;
    color: var(--bs-primary);
    margin-bottom: 1rem;
}

/* ============================================
   FORMS (Bootstrap Italia Style)
   ============================================ */
.form-label {
    font-weight: 600;
    color: var(--bs-gray-800);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    border: 2px solid var(--bs-gray-300);
    border-radius: var(--bs-border-radius);
    padding: 0.625rem 0.75rem;
    transition: var(--bi-transition-base);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.15);
}

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

.form-text {
    color: var(--bs-gray-600);
    font-size: 0.875rem;
}

/* Radio e Checkbox */
.form-check-input {
    border: 2px solid var(--bs-gray-400);
}

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

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.15);
}

.form-check-label {
    font-weight: 500;
    color: var(--bs-gray-800);
}

/* ============================================
   BREADCRUMBS (Bootstrap Italia Style)
   ============================================ */
.breadcrumb {
    background-color: var(--bs-gray-100);
    border-radius: var(--bs-border-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.breadcrumb-item {
    font-weight: 500;
}

.breadcrumb-item a {
    color: var(--bs-primary);
    text-decoration: none;
    transition: var(--bi-transition-base);
}

.breadcrumb-item a:hover {
    color: var(--bi-analogue-1);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--bs-gray-700);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--bs-gray-500);
}

/* ============================================
   ALERTS (Bootstrap Italia Style)
   ============================================ */
.alert {
    border: none;
    border-left: 4px solid;
    border-radius: var(--bs-border-radius);
    padding: 1rem 1.25rem;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(0, 135, 88, 0.1);
    border-left-color: var(--bs-success);
    color: var(--bs-success);
}

.alert-info {
    background-color: rgba(0, 115, 230, 0.1);
    border-left-color: var(--bs-info);
    color: var(--bs-info);
}

.alert-warning {
    background-color: rgba(166, 99, 0, 0.1);
    border-left-color: var(--bs-warning);
    color: var(--bs-warning);
}

.alert-danger {
    background-color: rgba(217, 54, 79, 0.1);
    border-left-color: var(--bs-danger);
    color: var(--bs-danger);
}

/* ============================================
   TABLES (Bootstrap Italia Style)
   ============================================ */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background-color: var(--bs-primary);
    color: #fff;
    font-weight: 600;
    border: none;
    padding: 1rem;
}

.table tbody tr {
    transition: var(--bi-transition-base);
}

.table tbody tr:hover {
    background-color: var(--bs-gray-100);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--bs-gray-300);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 102, 204, 0.03);
}

/* ============================================
   FOOTER (Bootstrap Italia Style)
   ============================================ */
.footer {
    background-color: var(--bs-gray-900);
    color: var(--bs-gray-300);
    border-top: 3px solid var(--bs-primary);
}

.footer .text-muted {
    color: var(--bs-gray-400) !important;
}

/* ============================================
   BADGES (Bootstrap Italia Style)
   ============================================ */
.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
    border-radius: var(--bs-border-radius-sm);
}

.badge.bg-primary {
    background-color: var(--bs-primary) !important;
}

.badge.bg-success {
    background-color: var(--bs-success) !important;
}

.badge.bg-danger {
    background-color: var(--bs-danger) !important;
}

.badge.bg-warning {
    background-color: var(--bs-warning) !important;
    color: #fff;
}

/* ============================================
   HERO SECTION (Bootstrap Italia Inspired)
   ============================================ */
.hero-section {
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bi-analogue-1) 100%);
    color: #fff;
    padding: 4rem 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

.hero-section .display-4 {
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-section .lead {
    font-size: 1.25rem;
    font-weight: 400;
    opacity: 0.95;
}

/* ============================================
   UTILITY CLASSES (Bootstrap Italia)
   ============================================ */
.text-primary {
    color: var(--bs-primary) !important;
}

.bg-primary {
    background-color: var(--bs-primary) !important;
}

.border-primary {
    border-color: var(--bs-primary) !important;
}

.shadow-sm {
    box-shadow: var(--bi-shadow-sm) !important;
}

.shadow {
    box-shadow: var(--bi-shadow) !important;
}

.shadow-lg {
    box-shadow: var(--bi-shadow-lg) !important;
}

/* ============================================
   ACCESSIBILITY & FOCUS STATES
   ============================================ */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bs-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media (max-width: 767.98px) {
    h1, .h1 { font-size: 2rem; }
    h2, .h2 { font-size: 1.75rem; }
    h3, .h3 { font-size: 1.5rem; }

    .hero-section {
        padding: 3rem 0;
    }

    .card {
        margin-bottom: 1rem;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 1rem;
    }

    .hero-section .display-4 {
        font-size: 2rem;
    }
}

/* ============================================
   LOADING & TRANSITIONS
   ============================================ */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* ============================================
   CUSTOM HOMEPAGE ELEMENTS
   ============================================ */
.stats-card {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.05) 0%, rgba(0, 102, 204, 0.1) 100%);
    border-radius: var(--bs-border-radius-lg);
    transition: var(--bi-transition-base);
}

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

.stats-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--bs-primary);
    line-height: 1;
}

.stats-label {
    font-size: 1rem;
    color: var(--bs-gray-800);
    font-weight: 600;
    margin-top: 0.5rem;
}

.step-card {
    position: relative;
    padding-left: 3.5rem;
}

.step-number {
    position: absolute;
    left: 0;
    top: 0;
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--bs-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.feature-icon {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bi-analogue-2) 100%);
    border-radius: var(--bs-border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.feature-icon i {
    font-size: 2rem;
    color: #fff;
}

/* ============================================
   WCAG AA CONTRAST FIXES
   ============================================ */

/* Text muted - aumentato contrasto */
.text-muted {
    color: var(--bs-gray-700) !important;
}

/* Card text e descrizioni */
.card-text {
    color: var(--bs-gray-800);
}

.card-text.text-muted {
    color: var(--bs-gray-700) !important;
}

/* Footer migliori contrasti */
.footer {
    background-color: #0D1821;
    color: #E5E9EB;
}

.footer .text-muted {
    color: #C1C7CD !important;
}

/* Text muted con migliore contrasto */
.text-muted {
    color: var(--bs-gray-700) !important;
}

/* Hero section - testi con opacità corretta */
.hero-section .lead {
    font-size: 1.25rem;
    font-weight: 400;
    opacity: 1;
    color: rgba(255, 255, 255, 0.95);
}

.hero-section p {
    color: rgba(255, 255, 255, 0.95);
}

/* Feature list - migliorare contrasto */
.feature-list li {
    color: var(--bs-gray-800);
    font-weight: 500;
}

/* Info list - migliorare contrasto */
.info-list li span {
    color: var(--bs-gray-800);
    font-weight: 500;
}

/* Contact items */
.contact-item a,
.contact-item span {
    color: var(--bs-gray-800);
    font-weight: 500;
}

/* Text muted override per WCAG AA */
.text-muted {
    color: var(--bs-gray-700) !important;
}

.card-text.text-muted {
    color: var(--bs-gray-700) !important;
}

/* ============================================
   HOMEPAGE ICONS FIX
   ============================================ */

/* Hero icon wrapper - dimensioni contenute */
.hero-icon-wrapper {
    max-width: 280px;
    margin: 0 auto;
}

.hero-icon-wrapper i {
    font-size: 8rem !important;
    opacity: 0.15 !important;
}

/* Stat icons - dimensioni ottimizzate */
.stat-icon {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.25rem !important;
}

.stat-icon i {
    font-size: inherit;
}

/* Step number - dimensioni ottimizzate */
.step-number {
    width: 45px !important;
    height: 45px !important;
    font-size: 1.15rem !important;
}

/* Istanza card icons */
.istanza-icon {
    width: 45px !important;
    height: 45px !important;
    font-size: 1.1rem !important;
    flex-shrink: 0;
}

.istanza-icon i {
    font-size: inherit;
}

/* Info icons */
.info-icon {
    width: 45px !important;
    height: 45px !important;
    font-size: 1.1rem !important;
    flex-shrink: 0;
}

.info-icon i {
    font-size: inherit;
}

/* Contact icons */
.contact-item i {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.95rem !important;
    flex-shrink: 0;
}

/* Feature list icons */
.feature-list li i {
    font-size: 0.9rem;
}

.info-list li i {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Responsive icons */
@media (max-width: 767.98px) {
    .hero-icon-wrapper i {
        font-size: 6rem !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.1rem !important;
    }

    .step-number {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }
}
