/* ==========================================================================
   S3C Modern Spotlight Search & Command Palette Styles
   Clean White UI matching S3C Corporate Design System
   ========================================================================== */

:root {
    --search-orange: #ea580c;
    --search-amber: #f59e0b;
    --search-bg-card: #ffffff;
    --search-border: #e2e8f0;
    --search-border-subtle: #f1f5f9;
    --search-text-primary: #0f172a;
    --search-text-secondary: #64748b;
    --search-text-muted: #94a3b8;
    --search-item-hover: #fff7ed;
    --search-item-active: #ffedd5;
    --search-item-border: #fed7aa;
}

/* ── Header Action Bar ────────────────────────────────────────────── */
.header-action-bar {
    display: flex;
    align-items: center;
    gap: 14px;
}

@media (max-width: 991.98px) {
    .header-action-bar {
        justify-content: center;
        margin-top: 16px;
        margin-bottom: 16px;
        padding-top: 14px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
    }
}

html[dir="rtl"] .header-action-bar {
    padding-left: 0 !important;
    padding-inline-start: 1.5rem !important;
}

/* ── Header Trigger Button ────────────────────────────────────────── */
.header-search-trigger {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 9999px;
    padding: 7px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    gap: 8px;
    line-height: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.header-search-trigger:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(234, 88, 12, 0.6);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(234, 88, 12, 0.25);
    transform: translateY(-1px);
}

.header-search-trigger:active {
    transform: translateY(0);
}

.header-search-trigger .search-trigger-icon {
    font-size: 0.95rem;
    color: inherit;
    transition: transform 0.25s ease;
}

.header-search-trigger:hover .search-trigger-icon {
    transform: scale(1.1);
    color: var(--search-orange);
}

.header-search-trigger .search-trigger-kbd {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.header-search-trigger .search-trigger-kbd kbd {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: inherit;
    padding: 2px 5px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Mobile Icon-only Trigger */
.header-search-trigger--mobile {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

/* Scrolled Header Adaptation */
nav.header-nav.scrolled .header-search-trigger {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.12);
    color: #334155;
}

nav.header-nav.scrolled .header-search-trigger:hover {
    background: rgba(234, 88, 12, 0.1);
    border-color: var(--search-orange);
    color: var(--search-orange);
    box-shadow: 0 0 14px rgba(234, 88, 12, 0.2);
}

nav.header-nav.scrolled .header-search-trigger .search-trigger-kbd kbd {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
    border-color: rgba(0, 0, 0, 0.1);
}

/* ── Modal Backdrop Overlay ───────────────────────────────────────── */
.search-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.search-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Search Container Box (Clean White UI Card) ─────────────────────── */
.search-modal-box {
    width: 100%;
    max-width: 680px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: 3.5px solid var(--search-orange);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(0, 0, 0, 0.04);
    border-radius: 18px;
    overflow: hidden;
    transform: scale(0.97) translateY(-10px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 84vh;
    position: relative;
}

.search-modal-backdrop.is-open .search-modal-box {
    transform: scale(1) translateY(0);
}

/* ── Search Input Field Row ───────────────────────────────────────── */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.search-input-icon {
    font-size: 1.25rem;
    color: var(--search-orange);
    margin-inline-end: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.search-input-field {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-size: 1.125rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
}

.search-input-field::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-clear-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    margin-inline-end: 10px;
    transition: all 0.2s ease;
}

.search-clear-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.search-clear-btn.is-visible {
    display: inline-flex;
}

.search-esc-badge {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.2;
    transition: all 0.2s ease;
}

.search-esc-badge:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* ── Category Filter Tabs ─────────────────────────────────────────── */
.search-categories-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: #f8fafc;
}

.search-categories-bar::-webkit-scrollbar {
    display: none;
}

.search-category-pill {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.search-category-pill:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.search-category-pill.active {
    background: #fff7ed;
    border-color: var(--search-orange);
    color: var(--search-orange);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(234, 88, 12, 0.15);
}

/* ── Results Container (Scrollbar Fixed & Optimized) ──────────────── */
.search-results-container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(84vh - 145px);
    overflow-y: auto !important;
    padding: 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Custom Visible Scrollbar for Webkit (Chrome, Edge, Safari) */
.search-results-container::-webkit-scrollbar {
    width: 6px;
    display: block;
}

.search-results-container::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 4px;
}

.search-results-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.search-results-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Result Item Card (White UI) ──────────────────────────────────── */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid #f1f5f9;
    margin-bottom: 6px;
    position: relative;
    cursor: pointer;
    background: #ffffff;
}

.search-result-item:hover,
.search-result-item.is-selected {
    background: #fff7ed;
    border-color: #fed7aa;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.08);
}

html[dir="rtl"] .search-result-item:hover,
html[dir="rtl"] .search-result-item.is-selected {
    transform: translateX(-3px);
}

/* Result Icon or Thumbnail */
.search-item-media {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.search-item-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-item-media i {
    font-size: 1.15rem;
    color: var(--search-orange);
}

/* Result Text Content */
.search-item-content {
    flex-grow: 1;
    min-width: 0;
}

.search-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.search-item-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge category tag (Light mode styling) */
.search-item-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge--products {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge--services {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.badge--industries {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge--news {
    background: #faf5ff;
    color: #7e22ce;
    border: 1px solid #e9d5ff;
}

.badge--careers {
    background: #f0fdfa;
    color: #0f766e;
    border: 1px solid #99f6e4;
}

.badge--projects {
    background: #fdf2f8;
    color: #be185d;
    border: 1px solid #fbcfe8;
}

.badge--pages {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.search-item-desc {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Match highlight */
.search-item-title mark,
.search-item-desc mark {
    background: #fef08a;
    color: #854d0e;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* Result Item Right Arrow */
.search-item-arrow {
    font-size: 0.85rem;
    color: #94a3b8;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.search-result-item:hover .search-item-arrow,
.search-result-item.is-selected .search-item-arrow {
    color: var(--search-orange);
    transform: translateX(4px);
}

html[dir="rtl"] .search-result-item:hover .search-item-arrow,
html[dir="rtl"] .search-result-item.is-selected .search-item-arrow {
    transform: translateX(-4px);
}

/* ── Section Title in Results ─────────────────────────────────────── */
.search-section-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 12px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Quick Links / Trending Pill Section (White UI) ───────────────── */
.search-quick-links-wrap {
    padding: 8px 10px;
}

.search-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.search-quick-tag {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.search-quick-tag i {
    color: var(--search-orange);
    font-size: 0.75rem;
}

.search-quick-tag:hover {
    background: #fff7ed;
    border-color: #fdba74;
    color: var(--search-orange);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.1);
}

/* ── Empty State ──────────────────────────────────────────────────── */
.search-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.search-empty-icon {
    font-size: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.search-empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 6px;
}

.search-empty-desc {
    font-size: 0.88rem;
    color: #64748b;
    max-width: 360px;
    margin: 0 auto;
}

/* ── Loading Spinner State ────────────────────────────────────────── */
.search-loading-state {
    text-align: center;
    padding: 35px 20px;
    color: #64748b;
}

.search-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f1f5f9;
    border-top-color: var(--search-orange);
    border-radius: 50%;
    animation: searchSpin 0.7s linear infinite;
    margin: 0 auto 12px;
}

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

/* ── Modal Footer Helper ──────────────────────────────────────────── */
.search-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 18px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 0.75rem;
    color: #64748b;
}

.search-footer-shortcuts {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-footer-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.search-footer-shortcut kbd {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.68rem;
    padding: 2px 5px;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ── Arabic RTL Adjustments ───────────────────────────────────────── */
html[dir="rtl"] .search-modal-box {
    font-family: 'Cairo', sans-serif !important;
}

html[dir="rtl"] .search-input-field {
    text-align: right;
}

html[dir="rtl"] .search-item-content {
    text-align: right;
}

html[dir="rtl"] .search-item-arrow {
    transform: rotate(180deg);
}

/* ── Comprehensive Responsive Adjustments ───────────────────────────── */

/* Tablets (768px to 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .search-modal-box {
        max-width: 620px;
        max-height: 84vh;
        max-height: 84dvh;
    }

    .search-results-container {
        max-height: calc(84dvh - 145px);
    }
}

/* Mobile Devices (< 768px) */
@media (max-width: 767.98px) {
    .search-modal-backdrop {
        padding: 12px 10px env(safe-area-inset-bottom, 12px);
        align-items: flex-start;
    }

    .search-modal-box {
        max-height: calc(100dvh - 24px);
        max-height: calc(100vh - 24px);
        border-radius: 16px;
        margin: 0 auto;
    }

    .search-input-wrapper {
        padding: 12px 14px;
    }

    .search-input-field {
        font-size: 0.98rem;
    }

    .search-results-container {
        max-height: calc(100dvh - 165px);
        max-height: calc(100vh - 165px);
        padding: 10px 12px;
    }

    .search-result-item {
        padding: 10px 12px;
        gap: 12px;
    }

    .search-item-media {
        width: 40px;
        height: 40px;
    }

    .search-item-title {
        font-size: 0.92rem;
    }

    .search-item-desc {
        font-size: 0.78rem;
    }

    .search-modal-footer {
        padding: 8px 14px;
        font-size: 0.72rem;
    }
}

/* Small Phones (< 480px, e.g. iPhone SE, Galaxy A series) */
@media (max-width: 479.98px) {
    .search-modal-backdrop {
        padding: 8px 6px env(safe-area-inset-bottom, 8px);
    }

    .search-modal-box {
        max-height: calc(100dvh - 16px);
        max-height: calc(100vh - 16px);
        border-radius: 14px;
    }

    .search-input-wrapper {
        padding: 10px 12px;
    }

    .search-input-icon {
        font-size: 1.1rem;
        margin-inline-end: 8px;
    }

    .search-input-field {
        font-size: 0.9rem;
    }

    .search-esc-badge {
        width: 28px;
        height: 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 50%;
    }

    .search-categories-bar {
        padding: 6px 10px;
        gap: 4px;
    }

    .search-category-pill {
        font-size: 0.75rem;
        padding: 4px 10px;
        gap: 4px;
    }

    .search-results-container {
        padding: 8px 10px;
        max-height: calc(100dvh - 150px);
        max-height: calc(100vh - 150px);
    }

    .search-result-item {
        padding: 8px 10px;
        gap: 10px;
        border-radius: 10px;
    }

    .search-item-media {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .search-item-media i {
        font-size: 0.95rem;
    }

    .search-item-title {
        font-size: 0.88rem;
    }

    .search-item-desc {
        font-size: 0.75rem;
    }

    .search-item-badge {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    .search-quick-tags {
        gap: 6px;
    }

    .search-quick-tag {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .search-item-arrow {
        font-size: 0.75rem;
    }
}

/* Landscape Phones (height <= 520px) */
@media (max-height: 520px) and (orientation: landscape) {
    .search-modal-backdrop {
        padding: 6px 16px;
    }

    .search-modal-box {
        max-height: 96vh;
        max-height: 96dvh;
    }

    .search-input-wrapper {
        padding: 8px 14px;
    }

    .search-categories-bar {
        padding: 4px 12px;
    }

    .search-results-container {
        max-height: calc(96dvh - 110px);
        max-height: calc(96vh - 110px);
        padding: 8px 12px;
    }

    .search-modal-footer {
        padding: 6px 12px;
    }
}
