/* ACCESSIBILITY FIX SICURO - Migliora accessibilità e usabilità */

/* Focus management migliorato */
:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Nasconde outline per mouse/touch, mantiene per tastiera */
:focus:not(:focus-visible) {
    outline: none;
}

/* Skip link per screen reader */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--color-secondary);
    color: var(--color-dark);
    padding: 8px;
    text-decoration: none;
    z-index: 100;
    border-radius: 4px;
    font-weight: 600;
}

.skip-link:focus {
    top: 6px;
}

/* Miglioramenti contrasto */
.high-contrast {
    color: var(--color-white);
    background: var(--color-dark);
}

/* Text scaling responsive */
@media (max-width: 768px) {
    html {
        font-size: 16px; /* Base font size per mobile */
    }
    
    .main-title {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    .subtitle {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .btn {
        font-size: 1rem;
        line-height: 1.4;
    }
}

/* Miglioramenti per utenti con difficoltà motorie */
.large-touch-target {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
}

/* Hover states più evidenti */
@media (hover: hover) {
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        box-shadow: 0 8px 25px rgba(0, 200, 83, 0.3);
        transform: translateY(-3px);
    }
}

/* Indicatori di stato per screen reader */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading states accessibili */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Error states più evidenti */
.error-message {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ff6b6b;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message::before {
    content: '⚠️';
    font-size: 1.2rem;
}

/* Success states */
.success-message {
    background: rgba(0, 200, 83, 0.1);
    border: 1px solid rgba(0, 200, 83, 0.3);
    color: var(--color-secondary);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.success-message::before {
    content: '✅';
    font-size: 1.2rem;
}

/* Miglioramenti per testi lunghi */
.readable-text {
    line-height: 1.6;
    letter-spacing: 0.02em;
    word-spacing: 0.1em;
}

/* Breadcrumb accessibili */
.breadcrumb {
    padding: 0;
    margin: 1rem 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: rgba(255, 255, 255, 0.6);
}

/* Tables responsive e accessibili */
.table-responsive {
    overflow-x: auto;
    max-width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-white);
}

.table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

/* Modal accessibili */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--color-dark);
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 1px solid var(--color-white);
    }
    
    .form-control {
        border: 2px solid var(--color-white);
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .btn {
        border: 1px solid black;
        background: white;
        color: black;
    }
}