/* ========================================
   FANCY FRONTEND - Glassmorphism Header & Infinite Scroll
   Version: 0.4.1 - Mobile Fixed + Dark Mode
   ======================================== */

/* ========================================
   0. RESET & ROOT VARIABLES
   ======================================== */

* {
    box-sizing: border-box;
}

:root {
    --header-height: 70px;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-primary: rgba(255, 255, 255, 0.85);
    --bg-secondary: rgba(255, 255, 255, 0.6);
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --border-color: rgba(102, 126, 234, 0.2);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(102, 126, 234, 0.15);
}

[data-theme="dark"] {
    --bg-primary: rgba(26, 26, 26, 0.85);
    --bg-secondary: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --border-color: rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

/* Mobile viewport fix */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

.fancy-layout {
    min-height: calc(var(--vh, 1vh) * 100 - var(--header-height));
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ========================================
   1. GLASSMORPHISM HEADER
   ======================================== */

.fancy-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    background: var(--bg-primary);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.fancy-header-inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-sizing: border-box;
}

/* Logo/Brand */
.header-logo {
    flex-shrink: 0;
}

.header-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.header-logo a:hover {
    opacity: 0.8;
}

/* Search Bar */
.header-search {
    flex: 1;
    max-width: 500px;
    min-width: 0; /* Important for flex shrinking */
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 3.5rem 0 1rem;
    border: 2px solid var(--border-color);
    border-radius: 22px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
    outline: none;
}

.search-input:focus {
    border-color: #667eea;
    background: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-button {
    position: absolute;
    right: 4px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 18px;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-action-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.header-action-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.header-action-btn.active {
    background: var(--primary-gradient);
    color: white;
}

.header-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Favorites Badge */
.header-action-btn .favorites-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc3545;
    color: white;
    border-radius: 9px;
    font-size: 0.625rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Language Switcher */
.header-lang-switcher {
    position: relative;
}

.lang-current-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 48px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.lang-current-flag img,
.lang-current-flag .flag-emoji {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    font-size: 20px;
    line-height: 24px;
}

.lang-current-flag .dropdown-arrow {
    width: 10px;
    height: 10px;
    transition: transform 0.3s ease;
}

.lang-current-flag.active .dropdown-arrow {
    transform: rotate(180deg);
}

.lang-current-flag:hover {
    background: rgba(102, 126, 234, 0.1);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 150px;
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.lang-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.lang-dropdown-item img,
.lang-dropdown-item .flag-emoji {
    width: 20px;
    height: 20px;
    object-fit: cover;
    border-radius: 4px;
    font-size: 16px;
    line-height: 20px;
}

.lang-dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

/* User Dropdown */
.header-user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.user-dropdown a:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

/* ========================================
   2. FILTERS PANEL
   ======================================== */

.filters-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.filters-panel.active {
    box-shadow: var(--shadow-sm);
}

.filters-panel-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
    height: 44px;
    padding: 0 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
    outline: none;
}

.filter-select:focus,
.filter-input:focus {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.filters-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ========================================
   3. FANCY LAYOUT & CARDS
   ======================================== */

.fancy-layout {
    padding: 2rem 0;
    background: linear-gradient(180deg, #f8f9ff 0%, #ffffff 100%);
    min-height: 100vh;
}

[data-theme="dark"] .fancy-layout {
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
}

#services-grid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Enhanced Service Cards */
.service-card {
    background: var(--bg-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.service-card-image-wrapper {
    position: relative;
    padding-top: 66.67%; /* 3:2 aspect ratio */
    overflow: hidden;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
}

.service-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.service-card:hover .service-card-image {
    transform: scale(1.05);
}

.service-card-content {
    padding: 1.25rem;
}

.service-card-title a {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.service-card-title a:hover {
    color: #667eea;
}

.service-card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.service-category,
.service-area {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    font-weight: 500;
}

.service-card-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #28a745;
    margin-top: 0.75rem;
}

.service-card-footer {
    display: flex;
    gap: 0.625rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   4. LOADING INDICATOR
   ======================================== */

#loading-indicator {
    display: none;
    text-align: center;
    padding: 2.5rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   5. RESPONSIVE DESIGN
   ======================================== */

/* Tablet and below */
@media (max-width: 1024px) {
    .header-search {
        max-width: 300px;
    }
}

/* Mobile - 2 row header layout */
@media (max-width: 768px) {
    :root {
        --header-height: 112px;
    }

    .fancy-header-inner {
        padding: 0.5rem 0.75rem;
        height: 112px;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-content: space-between;
    }

    .header-logo {
        order: 1;
        flex: 0 0 auto;
    }

    .header-logo a {
        font-size: 1rem;
        white-space: nowrap;
    }

    /* Header actions in first row */
    .header-actions {
        order: 2;
        gap: 0.25rem;
        flex: 1;
        justify-content: flex-end;
    }

    /* Search bar takes full width in second row */
    .header-search {
        order: 3;
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        margin: 0;
    }

    .search-input {
        height: 42px;
        font-size: 0.875rem;
        padding: 0 3rem 0 1rem;
    }

    .search-button {
        width: 34px;
        height: 34px;
    }

    .search-button svg {
        width: 18px;
        height: 18px;
    }

    .header-action-btn {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .header-action-btn svg {
        width: 18px;
        height: 18px;
    }

    .favorites-badge {
        font-size: 0.625rem;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
    }

    /* Language switcher compact */
    .lang-current-flag {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
    }

    .lang-current-flag img,
    .lang-current-flag .flag-emoji {
        width: 20px !important;
        height: 20px !important;
    }

    .lang-current-flag .dropdown-arrow {
        display: none;
    }

    .lang-dropdown {
        min-width: 140px;
        font-size: 0.875rem;
    }

    .lang-dropdown-item {
        padding: 0.625rem !important;
        font-size: 0.875rem;
    }

    /* Filters panel */
    .filters-panel-inner {
        padding: 1rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .filters-actions {
        flex-direction: column;
    }

    .filters-actions button {
        width: 100%;
    }

    /* Services grid */
    #services-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
        gap: 1.25rem;
    }

    .fancy-layout {
        padding: 1.5rem 0;
    }

    .service-card-content {
        padding: 1rem;
    }

    /* Dropdowns align left on mobile */
    .lang-dropdown,
    .user-dropdown {
        right: 0;
        left: auto;
    }
}

/* Very small mobile */
@media (max-width: 480px) {
    :root {
        --header-height: 106px;
    }

    .fancy-header-inner {
        padding: 0.5rem 0.5rem;
        height: 106px;
        gap: 0.375rem;
    }

    .header-logo a {
        font-size: 0.9375rem;
    }

    .search-input {
        height: 40px;
        font-size: 0.8125rem;
    }

    .search-button {
        width: 32px;
        height: 32px;
    }

    .search-button svg {
        width: 16px;
        height: 16px;
    }

    .header-action-btn {
        width: 34px;
        height: 34px;
    }

    .header-action-btn svg {
        width: 16px;
        height: 16px;
    }

    .lang-current-flag {
        width: 34px !important;
        height: 34px !important;
    }

    .lang-current-flag img,
    .lang-current-flag .flag-emoji {
        width: 18px !important;
        height: 18px !important;
    }

    #services-grid {
        padding: 0 0.75rem;
    }

    .fancy-layout {
        padding: 1rem 0;
    }
}

/* Landscape mobile - keep 2 row layout */
@media (max-width: 768px) and (orientation: landscape) {
    :root {
        --header-height: 100px;
    }

    .fancy-header-inner {
        height: 100px;
        padding: 0.375rem 0.75rem;
    }

    .search-input {
        height: 38px;
    }

    .header-action-btn {
        width: 34px;
        height: 34px;
    }
}

/* ========================================
   6. UTILITY CLASSES
   ======================================== */

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.no-results h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.no-results p {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

/* ========================================
   7. DARK MODE SPECIFIC ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .service-card {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select,
[data-theme="dark"] .filter-input {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .service-category,
[data-theme="dark"] .service-area {
    background: rgba(102, 126, 234, 0.2);
    color: #a8b5ff;
}
