/**
 * CrownateStudio - Property Discovery Portal Styling
 * Minimalist, Premium, Responsive, and Adaptive Design
 */

/* Theme Variables */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;
    --accent: #ff4a17; /* Construction Intelligence Accent */
    --accent-glow: rgba(255, 74, 23, 0.15);
    --gold: #d4af37; /* Luxury Property Badge */
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.06);
    --transition-premium: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --bg-primary: #0b0f19;
    --bg-secondary: #070a10;
    --bg-card: #111827;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #ff5722;
    --accent-glow: rgba(255, 87, 34, 0.2);
    --gold: #fbbf24;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    --glass-bg: rgba(17, 24, 39, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
}

/* Global Reset overrides */
body.portal-active {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Header Z-index safety isolation */
#crownate-header {
    z-index: 1080 !important;
}

/* Typography & Visual Hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Raleway', sans-serif;
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.text-gradient {
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Theme Toggle Button */
.theme-toggle-floating {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1040;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-premium);
}

.theme-toggle-floating:hover {
    transform: scale(1.08) rotate(15deg);
    border-color: var(--accent);
    color: var(--accent);
}

/* Voice Search Button */
.voice-search-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: var(--transition-premium);
    padding: 0 8px;
}
.voice-search-btn.listening {
    color: var(--accent);
    animation: voicePulse 1.2s infinite ease-in-out;
}

@keyframes voicePulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Autocomplete Suggestion Box */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}
.autocomplete-suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition-premium);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}
.autocomplete-suggestion-item:last-child {
    border-bottom: none;
}
.autocomplete-suggestion-item:hover {
    background: var(--bg-secondary);
    color: var(--accent);
    padding-left: 24px;
}

/* Premium Filter Badges & Buttons */
.btn-category-pill {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 8px 18px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: var(--transition-premium);
    cursor: pointer;
}
.btn-category-pill:hover, .btn-category-pill.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 8px 16px var(--accent-glow);
}

/* Premium Property Card */
.property-premium-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition-premium);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.property-premium-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
    border-color: var(--accent-glow);
}

.card-media-wrapper {
    position: relative;
    height: 220px;
    overflow: hidden;
}

.card-img-scale {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.property-premium-card:hover .card-img-scale {
    transform: scale(1.06);
}

.card-badge-overlay {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.badge-luxury {
    background: rgba(0, 0, 0, 0.75);
    color: var(--gold);
    font-weight: 800;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(4px);
}

.badge-verified {
    background: rgba(0, 0, 0, 0.75);
    color: #10b981;
    font-weight: 800;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    backdrop-filter: blur(4px);
}

/* Card Body */
.card-content-body {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-property-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    transition: color 0.2s ease;
}

.property-specs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-secondary);
    text-align: center;
}

.spec-divider {
    border-right: 1px solid var(--border-color);
}

/* Custom interactive map styles with Z-index isolation */
.map-sticky-container {
    position: sticky;
    top: 100px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    z-index: 5; /* Keep map below navigation header */
}

#map-element {
    height: 550px;
    width: 100%;
    background: var(--bg-secondary);
    z-index: 4;
}

/* sliding details panel styles */
#property-details-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 580px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -15px 0 35px rgba(0, 0, 0, 0.1);
    z-index: 1100; /* Over maps and header */
    transition: right 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
}

#property-details-drawer.active {
    right: 0;
}

.drawer-header-premium {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-content-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
}

.drawer-overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1090; /* Right under drawer, over header */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Detail Spec block list */
.detail-spec-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.detail-spec-item {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.detail-spec-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.detail-spec-value {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* Custom premium popup modals */
.modal-premium {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-primary);
}

.modal-header-premium {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.modal-body-premium {
    padding: 24px;
}

/* Custom inputs inside forms */
.form-control-premium {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    font-size: 0.85rem !important;
    transition: var(--transition-premium) !important;
}

.form-control-premium:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px var(--accent-glow) !important;
}

.form-label-premium {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Premium matching block form styling */
.matching-card {
    background: var(--bg-card);
    border: 2px dashed var(--accent);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

/* Leaflet marker customization overrides */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: 12px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--card-shadow) !important;
}
.leaflet-popup-tip {
    background: var(--bg-card) !important;
}
.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-primary) !important;
}

/* ==============================================================
   ACCESSIBILITY & HIGH CONTRAST THEMING OVERRIDES (Task 1)
   ============================================================== */

/* Dark Mode Overrides */
[data-theme="dark"] .text-dark,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .card-property-title,
[data-theme="dark"] .card-content-body,
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6,
[data-theme="dark"] .detail-spec-value,
[data-theme="dark"] .detail-spec-label,
[data-theme="dark"] .btn-link,
[data-theme="dark"] .btn-outline-dark,
[data-theme="dark"] .spec-divider span,
[data-theme="dark"] .font-monospace.text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Light Mode Overrides */
[data-theme="light"] .text-dark {
    color: #000000 !important;
}

[data-theme="light"] .text-muted {
    color: #475569 !important; /* WCAG 4.5:1 ratio */
}

[data-theme="light"] .text-secondary {
    color: #273d4e !important;
}

[data-theme="light"] .bg-light {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

[data-theme="light"] .bg-white {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

[data-theme="light"] .btn-outline-dark {
    color: #0f172a !important;
    border-color: #0f172a !important;
}

[data-theme="light"] .btn-link.text-dark {
    color: #0f172a !important;
}
