/**
 * Global Styles - Compass Design System
 * 
 * Purpose: Core variables, reset, typography, and utilities
 * Loaded on ALL pages for consistent branding
 * 
 * Design Reference: Compass.com (Minimalist, High Contrast, Luxurious)
 * 
 * @package Sokna
 * @since 1.0.0
 */

/* ============================================
   SELF-HOSTED FONTS - IBM Plex Sans Arabic
   ============================================ */

/**
 * IBM Plex Sans Arabic - Regular (400)
 * Used for: Body text, descriptions, paragraphs
 */
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('../fonts/ibm-plex/IBMPlexSansArabic-Regular.woff2') format('woff2'),
         url('../fonts/ibm-plex/IBMPlexSansArabic-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/**
 * IBM Plex Sans Arabic - Medium (500)
 * Used for: Labels, buttons, emphasized text
 */
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('../fonts/ibm-plex/IBMPlexSansArabic-Medium.woff2') format('woff2'),
         url('../fonts/ibm-plex/IBMPlexSansArabic-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/**
 * IBM Plex Sans Arabic - Bold (700)
 * Used for: Headings, titles, strong emphasis
 */
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('../fonts/ibm-plex/IBMPlexSansArabic-Bold.woff2') format('woff2'),
         url('../fonts/ibm-plex/IBMPlexSansArabic-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   CSS VARIABLES - Design Tokens
   ============================================ */
:root {
    /* Colors - Compass Palette */
    --color-primary: #000000;      /* Black - Main UI */
    --color-secondary: #FFFFFF;    /* White - Backgrounds */
    --color-accent: #0061DF;       /* Royal Blue - CTAs & Links */
    --color-gray-100: #F5F5F5;     /* Light Gray - Subtle Backgrounds */
    --color-gray-200: #E0E0E0;     /* Border Gray */
    --color-gray-300: #BDBDBD;     /* Muted Text */
    --color-gray-400: #757575;     /* Secondary Text */
    --color-gray-900: #212121;     /* Near Black */
    
    /* Typography - IBM Plex Sans Arabic for Brand Consistency */
    --font-main: 'IBM Plex Sans Arabic', 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-arabic: 'IBM Plex Sans Arabic', 'Cairo', 'Tajawal', sans-serif;
    
    /* Font Sizes (Mobile First) */
    --text-xs: 0.75rem;      /* 12px */
    --text-sm: 0.875rem;     /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg: 1.125rem;     /* 18px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.875rem;    /* 30px */
    --text-4xl: 2.25rem;     /* 36px */
    --text-5xl: 3rem;        /* 48px */
    
    /* Spacing (8px Base Grid) */
    --space-1: 0.5rem;   /* 8px */
    --space-2: 1rem;     /* 16px */
    --space-3: 1.5rem;   /* 24px */
    --space-4: 2rem;     /* 32px */
    --space-5: 2.5rem;   /* 40px */
    --space-6: 3rem;     /* 48px */
    --space-8: 4rem;     /* 64px */
    --space-10: 5rem;    /* 80px */
    
    /* Border Radius (Sharp Look) */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
    
    /* Shadows (Subtle & Elegant) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transitions (Smooth & Fast) */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-Index Layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ============================================
   CSS RESET - Minimal & Modern
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   HARD RESET: Force Zero-Offset for Top White Space
   ============================================ */

html {
    margin: 0 !important;
    padding: 0 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0 !important;
    padding: 0 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    font-family: var(--font-main) !important;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-primary);
    background-color: var(--color-secondary);
    overflow-x: hidden;
}

/* ============================================
   REMOVE WHITE SPACE GAP - CRITICAL FIX
   ============================================ */

/* Force zero margin on html and body */
html {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

* html body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

@media screen and (max-width: 782px) {
    html {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    body {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
}

/* WordPress Admin Bar - Negate any displacement */
#wpadminbar {
    position: fixed !important;
}

/* CRITICAL: Remove body padding-top for logged-out users */
body:not(.admin-bar) {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

@media (max-width: 767px) {
    body:not(.admin-bar) {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
}

/* Content spacing - Header is sticky, so no padding needed */
.site-main,
#main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

body:not(.admin-bar) .site-main,
body:not(.admin-bar) #main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

@media (max-width: 767px) {
    .site-main,
    #main-content,
    body:not(.admin-bar) .site-main,
    body:not(.admin-bar) #main-content {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
}

/* Global Font Application - Override Parent Theme */
body,
h1, h2, h3, h4, h5, h6,
input, select, textarea, button,
.btn {
    font-family: var(--font-main) !important;
}

/* RTL Font Family Override - IBM Plex Sans Arabic */
html[dir="rtl"],
html[dir="rtl"] body,
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] h4, html[dir="rtl"] h5, html[dir="rtl"] h6,
html[dir="rtl"] p, html[dir="rtl"] a, html[dir="rtl"] span,
html[dir="rtl"] input, html[dir="rtl"] select, html[dir="rtl"] textarea,
html[dir="rtl"] button, html[dir="rtl"] option {
    font-family: var(--font-arabic) !important;
    direction: rtl;
    text-align: start;
}

/* RTL: Ensure proper text direction - FORCED */
html[dir="rtl"],
html[dir="rtl"] * {
    direction: rtl !important;
}

html[dir="ltr"],
html[dir="ltr"] * {
    direction: ltr;
}

/* ============================================
   TYPOGRAPHY - Compass Style Hierarchy
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-block-end: var(--space-2);
    color: var(--color-primary);
}

h1 {
    font-size: var(--text-4xl);
    font-weight: 700;
}

h2 {
    font-size: var(--text-3xl);
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-base);
}

/* Responsive Typography (Desktop) */
@media (min-width: 768px) {
    h1 {
        font-size: var(--text-5xl);
    }
    h2 {
        font-size: var(--text-4xl);
    }
    h3 {
        font-size: var(--text-3xl);
    }
}

p {
    margin-block-end: var(--space-2);
    line-height: 1.7;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover,
a:focus {
    color: var(--color-primary);
}

strong, b {
    font-weight: 600;
}

/* Arabic Typography Adjustments */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 {
    font-weight: 700;
}

[dir="rtl"] p {
    line-height: 1.9;
}

/* ============================================
   LAYOUT UTILITIES
   ============================================ */

/* Container - Max Width with Responsive Padding */
.container {
    width: 100%;
    max-inline-size: 1320px;
    margin-inline: auto;
    padding-inline: var(--space-2);
}

@media (min-width: 768px) {
    .container {
        padding-inline: var(--space-4);
    }
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-3);
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .grid-cols-md-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-cols-md-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .grid-cols-lg-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .grid-cols-lg-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Flexbox Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: var(--space-1);
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

/* ============================================
   BUTTON STYLES - Compass CTA
   ============================================ */
.btn {
    display: inline-block;
    padding-block: var(--space-2);
    padding-inline: var(--space-4);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-secondary);
}

.btn-primary:hover {
    background-color: var(--color-gray-900);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background-color: var(--color-accent);
    color: var(--color-secondary);
}

.btn-accent:hover {
    background-color: #0052bb;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background-color: var(--color-primary);
    color: var(--color-secondary);
}

/* ============================================
   FORM ELEMENTS - Clean & Accessible
   ============================================ */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--space-2);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--color-primary);
    background-color: var(--color-secondary);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 97, 223, 0.1);
}

/* ============================================
   IMAGE OPTIMIZATION
   ============================================ */
img {
    max-inline-size: 100%;
    block-size: auto;
    display: block;
}

/* Blur-up Lazy Loading Effect */
img[loading="lazy"] {
    filter: blur(5px);
    transition: filter var(--transition-slow);
}

img[loading="lazy"].loaded {
    filter: blur(0);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Spacing Utilities */
.mt-1 { margin-block-start: var(--space-1); }
.mt-2 { margin-block-start: var(--space-2); }
.mt-3 { margin-block-start: var(--space-3); }
.mt-4 { margin-block-start: var(--space-4); }
.mb-1 { margin-block-end: var(--space-1); }
.mb-2 { margin-block-end: var(--space-2); }
.mb-3 { margin-block-end: var(--space-3); }
.mb-4 { margin-block-end: var(--space-4); }

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: start; }
.text-right { text-align: end; }
.text-uppercase { text-transform: uppercase; }
.text-gray { color: var(--color-gray-400); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }

/* Display Utilities */
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }

/* Visibility Utilities */
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
    .hide-desktop { display: none !important; }
}

/* ============================================
   SKELETON LOADER - UX Enhancement
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-100) 25%,
        var(--color-gray-200) 50%,
        var(--color-gray-100) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.sr-only,
.screen-reader-text {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Visible for Keyboard Navigation */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ============================================
   PRICE CURRENCY SWITCHER (Property detail)
   Premium, minimalist [ DH | € | $ ] next to price
   ============================================ */

/* Container: price + switcher vertically centered (middle of price text) */
.sokna-price-container,
.sokna-price-row,
.sokna-price-group-with-switcher {
    display: flex;
    align-items: center !important;
    gap: 15px;
    flex-wrap: nowrap;
}

@media (max-width: 480px) {
    .sokna-price-container,
    .sokna-price-row,
    .sokna-price-group-with-switcher {
        flex-wrap: wrap;
        align-items: center !important;
    }
}

/* Switcher: no vertical offset, aligned to middle of price */
.sokna-price-switcher,
.sokna-currency-switcher {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: stretch;
    align-self: center;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.sokna-price-switcher .sokna-currency-option,
.sokna-currency-switcher .sokna-currency-option {
    padding: 4px 10px;
    min-width: 35px;
    height: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #333333;
    text-decoration: none;
    border-inline-end: 1px solid #e0e0e0;
    background-color: #fff;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.sokna-price-switcher .sokna-currency-option:last-child,
.sokna-currency-switcher .sokna-currency-option:last-child {
    border-inline-end: none;
}

.sokna-price-switcher .sokna-currency-option:hover,
.sokna-currency-switcher .sokna-currency-option:hover {
    background-color: #f5f5f5;
    color: #000000;
}

/* Active and inactive same height for balanced container */
.sokna-price-switcher .sokna-currency-option.active,
.sokna-currency-switcher .sokna-currency-option.active {
    background-color: #0073e1;
    color: #ffffff;
    border-color: #0073e1;
    height: 28px;
    min-height: 28px;
}

.sokna-price-switcher .sokna-currency-option.active:hover,
.sokna-currency-switcher .sokna-currency-option.active:hover {
    background-color: #0062c7;
    color: #ffffff;
}

/* RTL: same flex row; logical properties (border-inline-end) already flip */
[dir="rtl"] .sokna-price-row,
[dir="rtl"] .sokna-price-group-with-switcher {
    flex-direction: row;
}

/* ============================================
   HOUZEZ OVERRIDE: Kill Ghost Status Labels
   ============================================
   Direct taxonomy fetch is our source of truth.
   Hide any labels Houzez might inject via JS/meta.
 */
.label-status-rented,
.label-status-sold,
.label-status {
    display: none !important;
}

