/* ==========================================
   UX ENHANCEMENTS - ViviendaPro
   ========================================== */

/* 1. HAMBURGER MENU */
.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    padding: .5rem; z-index: 200; flex-direction: column; gap: 5px;
}
.hamburger span {
    display: block; width: 24px; height: 2px; background: var(--primary-color, #004f70);
    transition: transform .3s, opacity .3s;
}
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

@media (max-width: 768px) {
    .hamburger { display: flex; }
    .nav { display: none !important; flex-direction: column; width: 100%; position: absolute; top: 100%; left: 0; right: 0; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.1); padding: 1rem; z-index: 200; border-top: 1px solid #e2e8f0; }
    .nav.nav-open { display: flex !important; }
    .nav-links { flex-direction: column; align-items: center; gap: .75rem; padding: .5rem 0; width: 100%; }
    .nav-links a { width: 100%; text-align: center; padding: .5rem; border-radius: .375rem; }
    .nav-links a:hover, .nav-links a.active { background: #f1f5f9; }
    .auth-buttons { flex-direction: column; align-items: center; gap: .5rem; width: 100%; padding-top: .75rem; border-top: 1px solid #e2e8f0; }
    .auth-buttons .btn { width: 100%; text-align: center; }
    .user-welcome { width: 100%; text-align: center; padding: .25rem 0; }
    .header-content { position: relative; flex-direction: row !important; justify-content: space-between; align-items: center; gap: 0 !important; }
    .logo img { height: 50px !important; }
}

/* 2. SCROLL INDICATOR */
.header { transition: box-shadow .3s; }
.header.scrolled { box-shadow: 0 2px 12px rgba(0,0,0,.12); }

/* 3. SIDEBAR MOBILE */
.sidebar-toggle {
    display: none; background: none; border: none; font-size: 1.4rem;
    cursor: pointer; padding: .25rem .5rem; margin-right: .75rem;
    color: var(--u-text, #1e293b);
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 90; opacity: 0; transition: opacity .3s;
}

@media (max-width: 900px) {
    .sidebar-toggle { display: block; }
    .sidebar {
        transform: translateX(-100%); transition: transform .3s;
        width: 260px; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
    .sidebar.sidebar-open ~ .sidebar-overlay { display: block; opacity: 1; }
    .main-content, .user-wrapper > .main-content, .admin-wrapper > .main-content,
    .asesor-wrapper > .main-content, .inmob-wrapper > .main-content {
        margin-left: 0 !important; width: 100%;
    }
    .content-body { padding: 1rem !important; }
    .topbar { padding: .75rem 1rem !important; }
    .topbar > div[style*="display:flex"] { flex-direction: column; gap: .5rem; align-items: flex-end; }
    #globalSearch { width: 180px !important; font-size: .8rem !important; }
    .page-title { font-size: 1.1rem !important; }

    /* Portal tables & stats */
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: .75rem !important; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .card-header { flex-direction: column; gap: .5rem; align-items: flex-start !important; }
    .card-header .btn { width: 100%; }

    /* Portal forms */
    .form-grid { grid-template-columns: 1fr !important; }
    .form-actions { flex-direction: column; gap: .5rem; }
    .form-actions .btn { width: 100%; }

    /* Eval header buttons */
    .eval-header { flex-direction: column; gap: .75rem; }
    .eval-header > div { flex-wrap: wrap; gap: .35rem !important; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .topbar { flex-direction: column; gap: .5rem; align-items: flex-start !important; }
    #globalSearchWrap { width: 100%; }
    #globalSearch { width: 100% !important; }
}

/* 4. SKELETON LOADERS */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: .375rem;
}
.skeleton-text { height: 1rem; margin-bottom: .5rem; width: 80%; }
.skeleton-title { height: 1.5rem; margin-bottom: .75rem; width: 60%; }
.skeleton-image { height: 200px; width: 100%; }
.skeleton-card { padding: 1rem; }
@keyframes skeleton-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 5. LOADING BUTTONS */
.btn-loading {
    position: relative; pointer-events: none; opacity: .7;
}
.btn-loading::after {
    content: ''; position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff; border-radius: 50%;
    animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* 6. TOAST NOTIFICATIONS */
#toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 10000;
    display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.toast {
    background: #1e293b; color: #fff; padding: .75rem 1rem; border-radius: .5rem;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    transform: translateX(120%); transition: transform .3s ease;
    font-size: .9rem;
}
.toast.show { transform: translateX(0); }
.toast-success { border-left: 4px solid #10b981; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid #3b82f6; }
.toast-warning { border-left: 4px solid #f59e0b; }
.toast-close { background: none; border: none; color: #94a3b8; font-size: 1.2rem; cursor: pointer; padding: 0 .25rem; }

/* 7. SCROLL TO TOP */
.scroll-top-btn {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 1000;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary-color, #004f70); color: #fff; border: none;
    font-size: 1.3rem; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    opacity: 0; transform: translateY(20px);
    transition: opacity .3s, transform .3s;
    pointer-events: none;
}
.scroll-top-btn.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.scroll-top-btn:hover { background: var(--primary-hover, #003a52); }

/* 8. INLINE VALIDATION */
.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,.1) !important;
}
.input-valid {
    border-color: #10b981 !important;
}
.form-error { color: #ef4444; font-size: .8rem; margin-top: .25rem; display: block; }

/* PASSWORD STRENGTH */
.password-strength { margin-top: .35rem; display: flex; align-items: center; gap: .5rem; }
.strength-bar {
    height: 4px; background: #e5e7eb; border-radius: 2px; flex: 1;
    transition: width .3s, background .3s; width: 0;
}
.strength-text { font-size: .75rem; font-weight: 600; min-width: 60px; }

/* 10. FORM PROGRESS */
.form-progress {
    display: flex; gap: 0; margin-bottom: 1.5rem; overflow: hidden; border-radius: .5rem;
}
.form-progress-step {
    flex: 1; padding: .5rem; text-align: center; font-size: .8rem; font-weight: 600;
    background: #e5e7eb; color: #64748b; position: relative;
    transition: background .3s, color .3s;
}
.form-progress-step.active { background: var(--primary-color, #004f70); color: #fff; }
.form-progress-step.completed { background: #10b981; color: #fff; }

/* 13. SHARE BUTTONS */
.share-buttons {
    display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0;
}
.share-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .4rem .75rem; border-radius: .375rem; font-size: .8rem;
    text-decoration: none; cursor: pointer; border: 1px solid #e2e8f0;
    color: #334155; background: #fff; transition: all .2s;
}
.share-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.share-btn-whatsapp { color: #25d366; border-color: #25d366; }
.share-btn-whatsapp:hover { background: #25d366; color: #fff; }
.share-btn-facebook { color: #1877f2; border-color: #1877f2; }
.share-btn-facebook:hover { background: #1877f2; color: #fff; }

/* 18. DRAG & DROP */
.dropzone {
    border: 2px dashed #cbd5e1; border-radius: .5rem; padding: 1.5rem;
    text-align: center; cursor: pointer; transition: all .2s;
    background: #fafbfc;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary-color, #004f70);
    background: #f0f9ff;
}
.dropzone-content { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.dropzone-icon { font-size: 2rem; }
.dropzone-content span { font-size: .85rem; color: #64748b; }
.dropzone-hint { font-size: .75rem !important; color: #94a3b8 !important; }

/* 14. RECENTLY VIEWED BAR */
.recent-bar {
    background: #fff; border: 1px solid #e2e8f0; border-radius: .5rem;
    padding: .75rem 1rem; margin-bottom: 1.5rem;
}
.recent-bar-title { font-size: .8rem; color: #64748b; margin-bottom: .5rem; font-weight: 600; }
.recent-items { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .25rem; }
.recent-item {
    flex-shrink: 0; display: flex; align-items: center; gap: .5rem;
    padding: .35rem .6rem; background: #f8fafc; border-radius: .375rem;
    text-decoration: none; color: #1e293b; font-size: .8rem;
    border: 1px solid #e2e8f0; transition: border-color .2s;
}
.recent-item:hover { border-color: var(--primary-color, #004f70); }

/* SMOOTH TRANSITIONS */
.property-card, .card, .stat-card { transition: transform .2s, box-shadow .2s; }
.property-card:hover, .card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }

/* FOCUS STYLES (accessibility) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary-color, #004f70);
    outline-offset: 2px;
}

/* SMOOTH PAGE LOAD */
.content-body, .property-detail-section, .landing-featured {
    animation: fadeInUp .4s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 19. PAGE PROGRESS BAR */
#pageProgressBar {
    position: fixed; top: 0; left: 0; height: 3px; z-index: 99999;
    background: linear-gradient(90deg, var(--primary-color, #004f70), var(--secondary-color, #a9d52f));
    pointer-events: none;
}

/* 20. TABLE FILTER */
.table-filter:focus {
    border-color: var(--primary-color, #004f70) !important;
    box-shadow: 0 0 0 3px rgba(0,79,112,.08);
    outline: none;
}

/* 22. FORM SECTION INDICATOR */
.form-section-indicator div {
    transition: background .3s, color .3s;
}
@media (max-width: 768px) {
    .form-section-indicator {
        flex-wrap: wrap !important;
    }
    .form-section-indicator div {
        font-size: .65rem !important;
        padding: .3rem !important;
    }
}
