/**
 * Modern Theme - Additional Styles
 * Toast notifications, lightbox, loading states
 */

/* ==========================================================================
   1. Toast Notifications
   ========================================================================== */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem 1.5rem;
    z-index: 9999;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
}

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

.toast-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
}

.toast-success .toast-icon {
    background: #28a745;
    color: white;
}

.toast-error .toast-icon {
    background: #dc3545;
    color: white;
}

.toast-warning .toast-icon {
    background: #ffc107;
    color: #856404;
}

.toast-info .toast-icon {
    background: #17a2b8;
    color: white;
}

.toast-message {
    flex: 1;
    color: #2d3748;
}

/* ==========================================================================
   2. Lightbox
   ========================================================================== */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: lightboxZoom 0.3s ease;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

@keyframes lightboxZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   3. Location Suggestions
   ========================================================================== */

.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

/* ==========================================================================
   4. Form Error States
   ========================================================================== */

input.error,
textarea.error,
select.error {
    border-color: #dc3545 !important;
    background: #fff5f5;
}

.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

input.error:focus,
textarea.error:focus,
select.error:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* ==========================================================================
   5. Loading States
   ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ==========================================================================
   6. Header States
   ========================================================================== */

.modern-header.scroll-up {
    transform: translateY(0);
}

.modern-header.scroll-down {
    transform: translateY(-100%);
}

.modern-header {
    transition: transform 0.3s ease;
}

/* ==========================================================================
   6.1 Header Layout
   ========================================================================== */

.modern-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
    border-bottom: 1px solid #edf0f7;
}

.skip-to-content {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-to-content:focus {
    position: fixed;
    left: 1rem;
    top: 1rem;
    width: auto;
    height: auto;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #2e3192;
    border-radius: 8px;
    z-index: 2000;
}

.header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0;
    flex-wrap: nowrap;
}

.header-logo .logo-img {
    height: 40px;
    width: auto;
}

.header-nav {
    flex: 1 1 auto;
}

.header-nav .nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.nav-item {
    position: relative;
}

.nav-item.dropdown::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 12px;
}

.nav-link {
    color: #1f2a44;
    font-weight: 600;
    text-decoration: none;
}

.nav-item.active .nav-link {
    color: #2e3192;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #fff;
    border: 1px solid #edf0f7;
    box-shadow: 0 8px 16px rgba(0,0,0,.08);
    border-radius: 10px;
    padding: 0.5rem 0;
    display: none;
    min-width: 180px;
    z-index: 10;
}

.nav-item.dropdown:hover .dropdown-menu,
.nav-item.dropdown:focus-within .dropdown-menu {
    display: block;
}

.dropdown-menu li {
    list-style: none;
}

.dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: #1f2a44;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

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

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #edf0f7;
    background: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: #1f2a44;
    font-weight: 600;
    cursor: pointer;
}

.action-btn svg {
    color: #2e3192;
}

.action-btn .current-lang {
    color: #1f2a44;
    font-weight: 700;
    letter-spacing: .02em;
}

.user-menu .user-btn {
    border-color: #e4e8f2;
}

.user-menu .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(46,49,146,.15);
}

.language-selector .action-btn,
.user-menu .action-btn {
    background: #f8f9ff;
}

.language-selector {
    position: relative;
}

.language-dropdown {
    position: absolute;
    right: 0;
    top: 120%;
    background: #fff;
    border: 1px solid #edf0f7;
    border-radius: 10px;
    padding: 0.5rem 0;
    min-width: 160px;
    display: none;
    z-index: 1000;
}

.language-selector:hover .language-dropdown {
    display: block;
}

.language-dropdown a {
    display: block;
    padding: 0.4rem 0.9rem;
    color: #1f2a44;
}

.user-menu { position: relative; }
.user-dropdown {
    position: absolute;
    right: 0;
    top: 120%;
    background: #fff;
    border: 1px solid #edf0f7;
    border-radius: 10px;
    padding: 0.5rem 0;
    min-width: 180px;
    display: none;
    z-index: 1000;
}
.user-menu:hover .user-dropdown { display: block; }
.nav-link,
.dropdown-menu a,
.language-dropdown a,
.user-dropdown a,
.radio-label,
.filters-toggle,
.search-button,
.checkbox-label,
.mobile-menu-toggle {
    cursor: pointer;
}

.mobile-menu-toggle { display: none; }
.mobile-menu { display: none !important; }
.mobile-menu * { list-style: none; margin: 0; padding: 0; }

@media (min-width: 992px) {
    .mobile-menu,
    .mobile-menu.active {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* ==========================================================================
   6.2 Search Bar Layout
   ========================================================================== */

.search-bar-wrapper { width: 100%; }
.search-form .search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.pf-hero .search-form .search-bar {
    gap: 0.9rem;
}

.search-field {
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 46px;
    flex: 1 1 180px;
}

.transaction-selector { flex: 1 1 100%; justify-content: flex-start; }
.location-field { flex: 2 1 280px; }
.select-field { flex: 1 1 160px; }

.search-input,
.search-select {
    border: none;
    width: 100%;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
}

.radio-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.radio-input {
    display: none;
}

.radio-text {
    border: 1px solid #dfe3f0;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-weight: 600;
    color: #1f2a44;
    background: #fff;
}

.radio-input:checked + .radio-text {
    background: #2e3192;
    border-color: #2e3192;
    color: #fff;
}

.filters-toggle,
.search-button {
    height: 46px;
    border-radius: 12px;
    border: none;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.filters-toggle { flex: 0 0 auto; }
.search-button { flex: 0 0 auto; }

.filters-toggle { background: #f0f3ff; color: #2e3192; }
.search-button { background: #2e3192; color: #fff; }

.advanced-filters {
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 14px;
}

.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.filter-group.full-width { grid-column: 1 / -1; }

/* ==========================================================================
   6.3 Footer Layout
   ========================================================================== */

.modern-footer { background: #0f1736; color: #cbd5f0; padding: 3rem 0 1.5rem; }
.footer-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2rem; }
.footer-title { color: #fff; margin-bottom: 0.75rem; font-size: 1rem; }
.footer-links, .footer-contact { list-style: none; padding: 0; margin: 0; }
.footer-links li, .footer-contact li { margin-bottom: 0.5rem; }
.footer-links a, .footer-contact a { color: #cbd5f0; }
.footer-bottom { margin-top: 2rem; border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem; }
.footer-bottom-content { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.footer-legal { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; }

@media (max-width: 1024px) {
    .header-nav { display: none; }
    .mobile-menu-toggle { display: inline-flex; }
    .search-form .search-bar { flex-direction: column; align-items: stretch; }
    .search-button, .filters-toggle { width: 100%; justify-content: center; }
    .mobile-menu { display: none; }
    .mobile-menu.active { display: block; }
}

@media (max-width: 768px) {
    .header-actions { gap: 0.5rem; }
    .mobile-menu { background: #fff; border-top: 1px solid #edf0f7; }
    .mobile-nav-menu { list-style: none; padding: 1rem; margin: 0; }
    .mobile-nav-menu li { margin-bottom: 0.75rem; }
}

/* ==========================================================================
   7. Back to Top Button
   ========================================================================== */

#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background: #5568d3;
    transform: translateY(-5px);
}

/* ==========================================================================
   8. Advanced Filters Panel
   ========================================================================== */

.advanced-filters {
    margin-top: 1rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 1.5rem;
    }
    to {
        opacity: 1;
        max-height: 1000px;
        padding: 1.5rem;
    }
}

.filters-toggle.active {
    background: #667eea;
    color: white;
}

.filter-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0 0.25rem;
}

/* ==========================================================================
   9. View Mode Toggle
   ========================================================================== */

.properties-grid.list-view {
    grid-template-columns: 1fr !important;
}

.properties-grid.list-view .property-card {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
}

.properties-grid.list-view .property-card .card-image {
    height: 100%;
    min-height: 200px;
}

.properties-grid.list-view .property-card .card-content {
    padding: 1rem 1rem 1rem 0;
}

@media (max-width: 768px) {
    .properties-grid.list-view .property-card {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   10. Image Lazy Loading
   ========================================================================== */

img[data-src],
img[data-srcset] {
    filter: blur(5px);
    transition: filter 0.3s;
}

img.loaded {
    filter: blur(0);
}

/* ==========================================================================
   11. Gallery Fullscreen
   ========================================================================== */

.gallery-wrapper:fullscreen,
.gallery-wrapper:-webkit-full-screen,
.gallery-wrapper:-moz-full-screen {
    background: black;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.gallery-wrapper:fullscreen .gallery-main,
.gallery-wrapper:-webkit-full-screen .gallery-main,
.gallery-wrapper:-moz-full-screen .gallery-main {
    height: calc(100vh - 120px) !important;
}

/* ==========================================================================
   12. Mobile Filters
   ========================================================================== */

@media (max-width: 1024px) {
    .filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 1001;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .filters-sidebar.active {
        transform: translateX(0);
    }
    
    .filters-sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: 1;
    }
    
    .sidebar-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 2;
        padding: 1rem 1.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
}

/* ==========================================================================
   13. Responsive Utilities
   ========================================================================== */

@media (max-width: 768px) {
    .toast {
        left: 1rem;
        right: 1rem;
        min-width: auto;
    }
    
    #back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
    
    .lightbox-content {
        max-width: 95vw;
    }
}

/* ==========================================================================
   14. Print Optimization
   ========================================================================== */

@media print {
    .toast,
    #back-to-top,
    .lightbox-overlay,
    .mobile-filters-toggle,
    .filters-toggle,
    .favorite-btn {
        display: none !important;
    }
}
