/* UI Enhancements per iRendity - Miglioramenti User Experience */

/* Smooth Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0A1512;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Micro-interazioni migliorate */
.btn, .button, button {
    transform: translateY(0);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn:hover, .button:hover, button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 32, 25, 0.25);
}

.btn:active, .button:active, button:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* Effetto ripple per i bottoni */
.btn::before, .button::before, button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:focus::before, .button:focus::before, button:focus::before {
    width: 300px;
    height: 300px;
}

/* Cards con hover effects migliorati */
.card, .property-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.card:hover, .property-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 24px rgba(16, 32, 25, 0.15);
}

/* Focus states per accessibilità */
*:focus {
    outline: 2px solid #C9A24B;
    outline-offset: 2px;
    border-radius: 3px;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #0A1512;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    transition: top 0.2s ease;
}

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

/* Notification toast migliorata */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    max-width: 350px;
}

.toast {
    background: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 32, 25, 0.15);
    margin-bottom: 10px;
    overflow: hidden;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid #38A169;
}

.toast-error {
    border-left: 4px solid #E53E3E;
}

.toast-warning {
    border-left: 4px solid #DD6B20;
}

.toast-info {
    border-left: 4px solid #1E7A57;
}

/* Responsive typography migliorata */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.3rem; }
}

/* ===== DARK MODE ===== */
html[data-theme="dark"] .loading-overlay {
    background: rgba(10, 21, 18, 0.9);
}
html[data-theme="dark"] .loading-spinner {
    border-color: var(--color-border);
    border-top-color: var(--color-accent);
}
html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] .button:hover,
html[data-theme="dark"] button:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .card:hover,
html[data-theme="dark"] .property-card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .skip-link {
    background: var(--color-surface-raised);
    color: var(--color-text-strong);
}
html[data-theme="dark"] .toast {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-lg);
}

/* Scroll migliorato */
html {
    scroll-padding-top: 80px; /* Compensate for sticky header */
}

/* Performance hints */
.property-image img,
.card img {
    content-visibility: auto;
    contain-intrinsic-size: 250px;
}

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