.cursor-pointer {
    cursor: pointer;
}

.cursor-pointer:hover {
    background-color: #f8f9fa;
}

.dropdown-menu .dropdown-item.active {
    background-color: #007bff;
    color: white;
}

/* Sistema di Selezione Geografica */
#regionContainer {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* CAP Input con indicatori di stato */
#capInput {
    transition: all 0.3s ease;
    padding-right: 45px !important;
}

#capInput:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#capInput.is-valid {
    border-color: #198754;
    background-color: rgba(25, 135, 84, 0.05);
}

#capInput.is-invalid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

/* Messaggi di feedback CAP */
#capSuccessMessage {
    border-left: 3px solid #198754;
    padding-left: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

#capErrorMessage {
    border-left: 3px solid #dc3545;
    padding-left: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Indicatori di stato CAP */
.cap-icon-success {
    color: #198754;
    font-size: 1.2rem;
}

.cap-icon-error {
    color: #dc3545;
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 768px) {
    #capInput {
        padding-right: 40px !important;
    }

    #regionContainer {
        margin-top: 1rem;
    }
}

/* Autocomplete migliorato */
#citySuggestions {
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}

#citySuggestions .dropdown-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

#citySuggestions .dropdown-item:last-child {
    border-bottom: none;
}

#citySuggestions .dropdown-item:hover {
    background-color: #f8f9fa;
}

#citySuggestions .dropdown-item.active {
    background-color: #007bff;
}

/* Stili per le bandiere nel select */
.form-select option img.flag-icon {
    width: 16px !important;
    height: 12px !important;
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}

/* Migliora la visualizzazione delle bandiere */
.form-select {
    background-image: none !important;
    /* Rimuove la freccia predefinita Bootstrap */
}

/* Stile per le bandiere quando il select è aperto */
.form-select option {
    padding: 8px 12px;
    background: white;
    color: #333;
}

.form-select option:hover {
    background: #007bff;
    color: white;
}

/* Custom Select per bandiere */
.custom-select-container {
    position: relative;
}

.custom-select-display {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    background-color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.custom-select-display:hover {
    border-color: #adb5bd;
}

.custom-select-display.open {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.selected-flag {
    margin-right: 8px;
}

.selected-flag-img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.selected-text {
    flex: 1;
}

.dropdown-arrow {
    font-size: 0.8em;
    color: #6c757d;
    transition: transform 0.2s;
}

.custom-select-display.open .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.custom-option {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.15s;
}

.custom-option:hover {
    background-color: #f8f9fa;
}

.option-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    margin-right: 8px;
}

.option-text {
    flex: 1;
}

/* Stili per bandiere SVG */
.flag-select {
    position: relative;
}

.flag-container {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.flag-icon-svg {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    vertical-align: middle;
    margin-right: 6px;
}

.flag-fallback {
    font-size: 0.8em;
    color: #6c757d;
    font-weight: bold;
    margin-right: 6px;
}

/* Cache bandiere per prestazioni */
.flag-cache {
    display: none;
}

/* Miglioramenti per dispositivi mobili */
@media (max-width: 576px) {
    .flag-icon-svg {
        width: 18px;
        height: 13px;
    }

    .flag-container {
        margin-right: 6px;
    }
}

/* Telefono editabile */
.phone-input-container {
    position: relative;
}

.phone-editable {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    background-color: #fff;
    min-height: 38px;
    display: block;
    cursor: text;
    outline: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    text-align: left;
    direction: ltr;

}

.phone-editable:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.phone-editable.is-valid {
    border-color: #198754;
    background-color: rgba(25, 135, 84, 0.05);
}

.phone-editable.is-invalid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}



/* Loading state per bandiere */
.flag-loading {
    opacity: 0.5;
    animation: flagPulse 1.5s ease-in-out infinite;
}

@keyframes flagPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}



/* Stili per validazione campi fiscali */
.cf-validation-status,
.piva-validation-status {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.cf-status-icon,
.piva-status-icon {
    margin-right: 0.25rem;
}

.text-success {
    color: #198754 !important;
}

.text-danger {
    color: #dc3545 !important;
}

/* Miglioramenti per campi uppercase */
.uppercase-field {
    text-transform: uppercase;
    font-weight: 500;
}

/* Stili per campo sigla provincia readonly */
#provinciaInput[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

/* Stili per campo codice sponsor readonly (referral) */
#codiceSponsor[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Miglioramenti responsive */
@media (max-width: 576px) {

    .cf-validation-status,
    .piva-validation-status {
        font-size: 0.75rem;
    }

    .form-select option {
        padding: 6px 10px;
    }
}

/* Animazioni per feedback validazione */
.is-valid {
    animation: validPulse 0.3s ease-out;
}

.is-invalid {
    animation: invalidShake 0.3s ease-out;
}

@keyframes validPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(25, 135, 84, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0);
    }
}

@keyframes invalidShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Animazione lampeggio per pulsante verde */
.flash {
    animation: flash 1s infinite;
}

@keyframes flash {
    0%, 50%, 100% {
        opacity: 1;
    }
    25%, 75% {
        opacity: 0.5;
    }
}

/* Styles from register_step3.php */
#specialInstructionsContainer {
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        overflow: hidden;
    }
    to {
        opacity: 1;
        max-height: 200px;
        overflow: visible;
    }
}

/* ✅ CAP LOOKUP REAL-TIME - Stili e Animazioni */
#shippingCAPInput {
    transition: all 0.3s ease;
    padding-right: 45px !important;
}

#shippingCAPInput:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#shippingCAPInput.is-valid {
    border-color: #198754;
    background-color: rgba(25, 135, 84, 0.05);
}

#shippingCAPInput.is-invalid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

/* Animazioni per stati CAP */
.cap-status-enter {
    animation: capStatusSlideIn 0.3s ease-out;
}

.cap-status-exit {
    animation: capStatusSlideOut 0.3s ease-in;
}

@keyframes capStatusSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes capStatusSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Spinner personalizzato */
.cap-spinner {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
    animation: capSpin 0.8s linear infinite;
}

@keyframes capSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Indicatori di stato */
.cap-icon-success {
    color: #198754;
    font-size: 1.2rem;
}

.cap-icon-error {
    color: #dc3545;
    font-size: 1.2rem;
}

.cap-icon-warning {
    color: #ffc107;
    font-size: 1.2rem;
}

/* Responsive per mobile */
@media (max-width: 768px) {
    #shippingCAPInput {
        padding-right: 40px !important;
    }

    #capErrorMessage,
    #capSuccessMessage {
        font-size: 0.875rem;
    }
}

/* Focus management per accessibilità */
#shippingCAPInput:focus + .position-absolute #capStatusIcon .cap-icon-success,
#shippingCAPInput:focus + .position-absolute #capStatusIcon .cap-icon-error,
#shippingCAPInput:focus + .position-absolute #capStatusIcon .cap-icon-warning {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #shippingCAPInput.is-valid {
        border-width: 2px;
        background-color: white;
    }

    #shippingCAPInput.is-invalid {
        border-width: 2px;
        background-color: white;
    }

    .cap-icon-success,
    .cap-icon-error,
    .cap-icon-warning {
        font-size: 1.4rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #shippingCAPInput,
    .cap-status-enter,
    .cap-status-exit {
        animation: none;
        transition: none;
    }

    .cap-spinner {
        animation: none;
        border: 2px solid #6c757d;
        border-top: 2px solid #0d6efd;
        border-radius: 50%;
        width: 1rem;
        height: 1rem;
        animation: none;
    }
}

/* Loading state enhancement */
.cap-loading-state {
    background: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: capLoading 1.5s infinite;
}

@keyframes capLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error state styling */
#capErrorMessage {
    border-left: 3px solid #dc3545;
    padding-left: 0.75rem;
    animation: capStatusSlideIn 0.3s ease-out;
}

/* Success state styling */
#capSuccessMessage {
    border-left: 3px solid #198754;
    padding-left: 0.75rem;
    animation: capStatusSlideIn 0.3s ease-out;
}

/* Help text enhancement */
#capHelpText {
    transition: color 0.3s ease;
}

#capHelpText.searching {
    color: #6c757d;
    font-style: italic;
}

#capHelpText.found {
    color: #198754;
    font-weight: 500;
}

#capHelpText.not-found {
    color: #dc3545;
}

/* Flashing border animation for erroneous fields */
@keyframes flash-error {
    0% { border-color: red; box-shadow: 0 0 5px red; }
    50% { border-color: yellow; box-shadow: 0 0 5px yellow; }
    100% { border-color: red; box-shadow: 0 0 5px red; }
}

.error-flash {
    animation: flash-error 1s infinite;
    border: 2px solid red !important;
    box-shadow: 0 0 5px red !important;
}

/* Footer always at bottom */
body.register-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.register-page main {
    flex: 1;
}

body.register-page .footer {
    margin-top: auto;
}