/* Main Stylesheet - Compatible with older browsers */

/* Reset e base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Header e navigation */
.navbar {
    background-color: #1F3566 !important;
}

.navbar-brand {
    color: white !important;
}

.navbar-brand:hover {
    color: #e0e0e0 !important;
}

.navbar-nav .nav-link {
    color: white !important;
    font-weight: 500;
    transition: color 0.15s ease-in-out;
    -webkit-transition: color 0.15s ease-in-out;
    -moz-transition: color 0.15s ease-in-out;
}

.navbar-nav .nav-link:hover {
    color: #e0e0e0 !important;
}

.navbar-nav .nav-link.active {
    color: #e0e0e0 !important;
    font-weight: 600;
}

.navbar-toggler {
    border-color: white !important;
}

.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='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

.navbar-brand img {
    max-height: 40px;
    width: auto;
}

/*
 * Navbar collassata (viewport < lg): evita che logo e toggler vadano su due righe
 * (il logo PNG è molto largo rispetto all'altezza).
 */
@media (max-width: 991.98px) {
    .navbar > .container {
        -webkit-flex-wrap: nowrap;
        -ms-flex-wrap: nowrap;
        flex-wrap: nowrap;
    }

    .navbar-brand {
        -webkit-box-flex: 1;
        -webkit-flex: 1 1 auto;
        -ms-flex: 1 1 auto;
        flex: 1 1 auto;
        min-width: 0;
        margin-right: 0.5rem;
    }

    .navbar-brand img {
        max-height: 28px;
        max-width: 100%;
        height: auto;
    }

    .navbar-toggler {
        -webkit-flex-shrink: 0;
        -ms-flex-negative: 0;
        flex-shrink: 0;
    }
}

/* Cards e contenitori */
.card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    -webkit-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    -moz-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: #1F3566;
    color: white;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* Form styles */
.form-control:focus {
    border-color: #1F3566;
    box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
    -webkit-box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
    -moz-box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
}

.form-select:focus {
    border-color: #1F3566;
    box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
    -webkit-box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
    -moz-box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
}

/* Button styles */
.btn {
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    -webkit-transition: all 0.15s ease-in-out;
    -moz-transition: all 0.15s ease-in-out;
}

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

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

/* Table styles */
.table {
    background-color: #fff;
    border-radius: 0.375rem;
    overflow: hidden;
    font-size: 0.875rem;
}

.table-sm {
    font-size: 0.8rem;
}

.table thead th {
    background-color: #1F3566;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    vertical-align: middle;
}

.table tbody td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(31, 53, 102, 0.05);
}

/* Responsive table improvements */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1200px) {
    .table-responsive {
        font-size: 0.8rem;
    }
}

@media (max-width: 992px) {
    .table-responsive {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.7rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* Badge styles */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 0.25rem;
}

.badge.bg-primary {
    background-color: #1F3566 !important;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

.badge.bg-info {
    background-color: #0dcaf0 !important;
}

/* Alert styles */
.alert {
    border-radius: 0.375rem;
    border: none;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Pagination styles */
.pagination .page-link {
    color: #1F3566;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin: 0 0.125rem;
}

.pagination .page-link:hover {
    color: #1a2d5a;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination .page-item.active .page-link {
    background-color: #1F3566;
    border-color: #1F3566;
    color: #fff;
}

/* Sticky positioning */
.sticky-top {
    position: -webkit-sticky;
    position: -moz-sticky;
    position: sticky;
    top: 1rem;
    z-index: 1020;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .sticky-top {
        position: relative !important;
        top: 0 !important;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .table-responsive {
        font-size: 0.8rem;
    }
}

/* Utility classes */
.text-muted {
    color: #6c757d !important;
}

.bg-light {
    background-color: #1F3566 !important;
}

.border-light {
    border-color: #1F3566 !important;
}

/* Loading states */
.spinner-border {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 0.125em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
    -webkit-animation: spinner-border 0.75s linear infinite;
    -moz-animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -moz-transform: rotate(360deg);
    }
}

@-webkit-keyframes spinner-border {
    to {
        -webkit-transform: rotate(360deg);
    }
}

@-moz-keyframes spinner-border {
    to {
        -moz-transform: rotate(360deg);
    }
}

/* Focus styles per accessibilità */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Skip link per accessibilità */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 0.25rem;
    z-index: 1000;
}

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

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .card {
        border: 1px solid #000;
        box-shadow: none;
        -webkit-box-shadow: none;
        -moz-box-shadow: none;
    }

    .table {
        border: 1px solid #000;
    }

    .table th,
    .table td {
        border: 1px solid #000;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }

    .form-control,
    .form-select {
        border-width: 2px;
    }

    .table th,
    .table td {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        -webkit-animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        -webkit-transition-duration: 0.01ms !important;
        -moz-animation-duration: 0.01ms !important;
        -moz-animation-iteration-count: 1 !important;
        -moz-transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}

/* Fallback per browser obsoleti */
.btn-copy-url {
    cursor: pointer;
}

/* Nascondi elementi che dipendono da JavaScript moderno */
.js-only {
    display: none;
}

/* Mostra fallback per browser obsoleti */
.no-js-fallback {
    display: block;
}

/* Compatibilità con IE11 */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .sticky-top {
        position: relative !important;
        top: 0 !important;
    }

    .card {
        display: block;
    }

    .d-flex {
        display: block !important;
    }

    .d-grid {
        display: block !important;
    }

    .gap-2 > * {
        margin-bottom: 0.5rem;
    }

    .gap-2 > *:last-child {
        margin-bottom: 0;
    }
}

/* Compatibilità con Safari < 10 */
@supports not (display: grid) {
    .d-grid {
        display: block !important;
    }

    .d-grid > * {
        margin-bottom: 0.5rem;
    }

    .d-grid > *:last-child {
        margin-bottom: 0;
    }
}

/* Fallback per flexbox */
@supports not (display: flex) {
    .d-flex {
        display: block !important;
    }

    .justify-content-between {
        text-align: center;
    }

    .justify-content-between > * {
        display: block;
        margin-bottom: 0.5rem;
    }

    .justify-content-between > *:last-child {
        margin-bottom: 0;
    }

    .align-items-center {
        vertical-align: middle;
    }
}

/* Fallback per grid */
.row {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.col-lg-4 {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 auto;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    width: 33.333333%;
}

.col-lg-8 {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 auto;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    width: 66.666667%;
}

/* Fallback per sticky positioning */
.sticky-top {
    position: -webkit-sticky;
    position: sticky;
    top: 1rem;
    z-index: 1020;
}

/* Utility classes per browser obsoleti */
.d-grid {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
}

.gap-2 {
    gap: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.ms-2 {
    margin-left: 0.5rem !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.text-center {
    text-align: center !important;
}

/* Fallback per border-radius */
.rounded {
    -webkit-border-radius: 0.375rem;
    -moz-border-radius: 0.375rem;
    border-radius: 0.375rem;
}

/* Fallback per box-shadow */
.shadow {
    -webkit-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    -moz-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Footer styles */
footer {
    color: white !important;
}

footer a {
    color: white !important;
}

footer a:hover {
    color: #e0e0e0 !important;
    text-decoration: underline;
}

/* Badge +1 nelle aree della tabella risultati */
.badge-area-extra {
    background-color: #1F3566;
    color: #fff !important;
    font-weight: bold;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 0.85em;
    margin-left: 4px;
    vertical-align: middle;
}

/* Effetto hover per le card cliccabili */
.hover-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.hover-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

.hover-card a:hover {
    color: inherit;
}

/* Radio button styles for registration form */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}

.form-check:hover {
    border-color: #1F3566;
    background-color: rgba(31, 53, 102, 0.02);
}

.form-check input[type="radio"] {
    margin-top: 0.125rem;
    flex-shrink: 0;
}

.form-check-label {
    cursor: pointer;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0;
    margin-left: 0.5em;
}

.form-check input[type="radio"]:checked + .form-check-label {
    color: #1F3566;
    font-weight: 600;
}

.form-check input[type="radio"]:checked {
    background-color: #1F3566;
    border-color: #1F3566;
}

.form-check input[type="radio"]:focus {
    box-shadow: 0 0 0 0.2rem rgba(31, 53, 102, 0.25);
}

/* Stile compatto per i checkbox delle aree SOLO nella ricerca avanzata */
.professionista-advanced-search-aree .form-check {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 0;
    background: none;
    margin-bottom: 0.25rem;
    box-shadow: none;
}

.professionista-advanced-search-aree .form-check-input {
    margin-top: 0.2rem;
}

/* Preferenze dell'utente attraverso il browser */

@media (prefers-contrast: more) {
  :root {
    --bs-body-bg: #ffffff;
    --bs-body-color: #000000;
    --bs-link-color: #0000ee;
  }

  a:hover, a:focus {
    outline: 3px solid #000;
  }
}
