/* ============================================================
   DE Search — Frontend Styles
   Dragon Evo Digital
   ============================================================ */

/* ---------- Reset & Box Model ---------- */
.de-search-wrap *,
.de-search-results-wrap * {
    box-sizing: border-box;
}

/* ---------- Wrapper ---------- */
.de-search-wrap {
    position: relative;
    display: block;
    width: 100%;
    max-width: 600px;
    font-size: 16px;
    color: #333;
    line-height: 1;
}

/* ---------- Form Inner ---------- */
.de-search-form {
    margin: 0;
    padding: 0;
}

.de-search-inner {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}

.de-search-wrap:not(.de-search-results-open) .de-search-inner:focus-within,
.de-search-wrap:not(.de-search-results-open) .de-search-inner:hover {
    border-color: #6b7280;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.de-search-wrap.de-search-results-open .de-search-inner {
    border-color: #4f46e5;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ---------- Input ---------- */
.de-search-input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 10px 0 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95em;
    color: #1f2937;
    -webkit-appearance: none;
    appearance: none;
}

.de-search-input::placeholder {
    color: #9ca3af;
}

.de-search-input::-webkit-search-cancel-button,
.de-search-input::-webkit-search-decoration {
    display: none;
}

/* ---------- Icons: Magnifier, Clear, Submit ---------- */
.de-search-icon-mag,
.de-search-submit,
.de-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.de-search-icon-mag {
    padding: 0 10px 0 14px;
    pointer-events: none;
}

.de-search-icon-mag svg,
.de-search-submit svg,
.de-search-clear svg {
    width: 18px;
    height: 18px;
}

.de-search-clear {
    padding: 0 8px;
}

.de-search-clear:hover {
    color: #ef4444;
}

.de-search-submit {
    height: 46px;
    padding: 0 16px;
    background: #4f46e5;
    color: #fff;
    border-radius: 0 6px 6px 0;
    transition: background 0.15s ease;
}

.de-search-submit:hover {
    background: #4338ca;
    color: #fff;
}

/* ---------- Loader (3 dots) ---------- */
.de-search-loader {
    display: none;
    align-items: center;
    gap: 3px;
    padding: 0 8px;
    height: 46px;
}

.de-search-loader span {
    display: block;
    width: 5px;
    height: 5px;
    background: #4f46e5;
    border-radius: 50%;
    animation: de-bounce 1.2s ease-in-out infinite;
}

.de-search-loader span:nth-child(1) { animation-delay: 0s; }
.de-search-loader span:nth-child(2) { animation-delay: 0.2s; }
.de-search-loader span:nth-child(3) { animation-delay: 0.4s; }

.de-search-loading .de-search-loader {
    display: flex;
}

@keyframes de-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ---------- Results Dropdown ---------- */
.de-search-results-wrap {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1.5px solid #4f46e5;
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    overflow: hidden;
    max-height: 70vh;
    overflow-y: auto;

    /* Animation */
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.de-search-wrap.de-search-results-open .de-search-results-wrap {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Scrollbar */
.de-search-results-wrap::-webkit-scrollbar { width: 4px; }
.de-search-results-wrap::-webkit-scrollbar-track { background: #f9fafb; }
.de-search-results-wrap::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ---------- Group Heading ---------- */
.de-search-group-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 6px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    border-top: 1px solid #f3f4f6;
}

.de-search-group:first-child .de-search-group-heading {
    border-top: none;
}

.de-search-group-heading-count {
    margin-left: auto;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 9999px;
    padding: 1px 7px;
    font-size: 0.9em;
    font-weight: 600;
}

/* ---------- Result Item ---------- */
.de-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: #1f2937;
    transition: background 0.1s ease;
    cursor: pointer;
    border-top: 1px solid #f3f4f6;
    position: relative;
}

.de-search-result:first-of-type {
    border-top: none;
}

.de-search-result:hover,
.de-search-result.de-search-result--active {
    background: #f5f3ff;
    text-decoration: none;
    color: #1f2937;
}

/* ---------- Thumbnail ---------- */
.de-search-thumb {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.de-search-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Placeholder icon when no thumbnail */
.de-search-thumb-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #d1d5db;
}

.de-search-thumb-placeholder svg {
    width: 22px;
    height: 22px;
}

/* ---------- Result Text ---------- */
.de-search-result-text {
    flex: 1;
    min-width: 0;
}

.de-search-result-title {
    display: block;
    font-size: 0.92em;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.de-search-result-title mark {
    background: transparent;
    color: #4f46e5;
    font-weight: 700;
}

.de-search-result-excerpt {
    display: block;
    font-size: 0.78em;
    color: #6b7280;
    margin-top: 3px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.de-search-result-excerpt mark {
    background: transparent;
    color: #4f46e5;
    font-weight: 600;
}

/* ---------- Type Badge ---------- */
.de-search-type-badge {
    flex-shrink: 0;
    font-size: 0.65em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 4px;
    background: #e0e7ff;
    color: #4338ca;
    white-space: nowrap;
}

/* ---------- "See All Results" footer ---------- */
.de-search-all-results {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.82em;
    font-weight: 600;
    color: #4f46e5;
    text-decoration: none;
    transition: background 0.1s ease;
    cursor: pointer;
    background: #fafafa;
}

.de-search-all-results:hover {
    background: #f5f3ff;
    color: #3730a3;
    text-decoration: none;
}

.de-search-all-results svg {
    width: 14px;
    height: 14px;
}

/* ---------- Fuzzy / Approximate Results Notice ---------- */
.de-search-fuzzy-notice {
    padding: 5px 16px;
    font-size: 0.72em;
    color: #9ca3af;
    font-style: italic;
    border-bottom: 1px solid #f3f4f6;
    background: #fafafa;
}

/* ---------- No Results ---------- */
.de-search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 0.9em;
}

.de-search-no-results strong {
    display: block;
    color: #1f2937;
    font-size: 1.1em;
    margin-bottom: 4px;
}

/* ---------- Mobile Overlay ---------- */
.de-search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
    animation: de-fade-in 0.2s ease;
}

.de-search-overlay.active {
    display: block;
}

@keyframes de-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (max-width: 768px) {
    .de-search-wrap.de-search-mobile-active {
        position: fixed;
        top: 16px;
        left: 16px;
        right: 16px;
        z-index: 9999;
        max-width: none;
    }

    .de-search-wrap.de-search-mobile-active .de-search-results-wrap {
        max-height: calc(100vh - 100px);
    }
}

/* ---------- Screen reader only ---------- */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Icon Layout
   A circular icon button that expands into a full bar.
   The expanded bar overlays content via position:absolute.
   ============================================================ */

/* The trigger button */
.de-search-icon-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.3);
    background: transparent;
    color: currentColor;
    cursor: pointer;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.de-search-icon-trigger:hover {
    border-color: currentColor;
    background: rgba(255,255,255,0.1);
}

.de-search-icon-trigger svg {
    width: 18px;
    height: 18px;
}

/* Icon layout wrapper —
   CRITICAL: shrink to icon size only. Must override any parent flex/grid allocation. */
.de-search-layout-icon {
    display: inline-flex !important;
    width: 40px !important;
    max-width: 40px !important;
    min-width: 0 !important;
    position: relative;
    /* overflow visible so expanded form can escape */
    overflow: visible !important;
}

/* Constrain Elementor wrapper elements so the icon widget doesn't fill column space */
.elementor-widget-de-search:has(.de-search-layout-icon),
.elementor-widget-container:has(.de-search-layout-icon) {
    width: auto !important;
    min-width: 0 !important;
    flex-shrink: 1 !important;
}

/* Also constrain the column/container itself — prevents the nav leaving a large empty gap */
/* Legacy column layout */
.elementor-column:has(.de-search-layout-icon) {
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
}
/* New Elementor Flexbox Container layout (e-con) */
.e-con:has(> .elementor-widget-de-search),
.e-con:has(> .e-con-inner > .elementor-widget-de-search) {
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
}

/* Show the trigger in icon layout */
.de-search-layout-icon .de-search-icon-trigger {
    display: flex;
}

/* The expandable form — hidden by default */
.de-search-layout-icon .de-search-form-expandable {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
    z-index: 10000;
    /* Do NOT set both left and right — pick one based on direction */
}

/* Expand LEFT (default) — bar grows left from icon right edge */
.de-search-layout-icon .de-search-form-expandable,
.de-search-layout-icon.de-expand-left .de-search-form-expandable {
    right: 0;
    left: auto;
}

/* Expand RIGHT — bar grows right from icon left edge */
.de-search-layout-icon.de-expand-right .de-search-form-expandable {
    left: 0;
    right: auto;
}

/* Opened state */
.de-search-layout-icon.de-search-icon-open .de-search-form-expandable {
    width: var(--de-search-expanded-width, 360px);
    opacity: 1;
    pointer-events: all;
    overflow: visible;
}

/* Hide trigger once open */
.de-search-layout-icon.de-search-icon-open .de-search-icon-trigger {
    opacity: 0;
    pointer-events: none;
}

/* Results dropdown positioning in icon layout */
.de-search-layout-icon .de-search-results-wrap,
.de-search-layout-icon.de-expand-left .de-search-results-wrap {
    right: 0;
    left: auto;
    width: var(--de-search-expanded-width, 360px);
}

.de-search-layout-icon.de-expand-right .de-search-results-wrap {
    left: 0;
    right: auto;
    width: var(--de-search-expanded-width, 360px);
}
