/* =========================================================
   Chapter Live Search — Frontend Styles (modern, mobile-first)
   ========================================================= */

.cls-search-wrapper {
    margin: 0 0 1.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: inherit;
    background: transparent !important;
}

/* Input row */
.cls-search-wrapper .cls-input-wrap {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    width: 100% !important;
    max-width: 640px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

/* Search icon — fixed box, never overlaps text */
.cls-search-wrapper .cls-icon {
    position: absolute !important;
    left: 16px !important;
    top: 50% !important;
    width: 19px !important;
    height: 19px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translateY(-50%) !important;
    color: var(--cls-accent, #6c757d);
    opacity: 0.75;
    pointer-events: none !important;
    flex-shrink: 0;
    transition: color 0.2s, opacity 0.2s;
    z-index: 2;
}

/* Input field */
.cls-search-wrapper .cls-input {
    display: block !important;
    width: 100% !important;
    height: 48px !important;
    margin: 0 !important;
    padding: 0 2.75rem 0 3rem !important;
    font-size: 0.98rem !important;
    line-height: 48px !important;
    font-family: inherit;
    color: #1a1d21;
    background: #fff;
    border: 1.5px solid #e2e5e9 !important;
    border-radius: 12px !important;
    outline: none !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    box-sizing: border-box !important;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.cls-search-wrapper .cls-input::-webkit-search-cancel-button,
.cls-search-wrapper .cls-input::-webkit-search-decoration {
    -webkit-appearance: none !important;
    display: none !important;
}

.cls-search-wrapper .cls-input:hover {
    border-color: color-mix(in srgb, var(--cls-accent, #6c757d) 45%, #e2e5e9);
}

.cls-search-wrapper .cls-input:focus {
    border-color: var(--cls-accent, #6c757d);
    background: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cls-accent, #6c757d) 16%, transparent);
}

.cls-search-wrapper .cls-input:focus ~ .cls-icon,
.cls-search-wrapper .cls-input-wrap:focus-within .cls-icon {
    color: var(--cls-accent, #6c757d);
    opacity: 1;
}

.cls-search-wrapper .cls-input::placeholder {
    color: #9aa1a9;
    font-weight: 400;
}

/* Clear (×) button */
.cls-search-wrapper .cls-clear {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: #f1f2f4 !important;
    border: none !important;
    width: 26px;
    height: 26px;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    color: #6b7280;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    transition: color 0.15s, background 0.15s, transform 0.1s;
    line-height: 1;
    z-index: 2;
}

.cls-search-wrapper .cls-clear:hover {
    color: #1a1d21;
    background: #e6e8eb !important;
}

.cls-search-wrapper .cls-clear:active {
    transform: translateY(-50%) scale(0.92) !important;
}

.cls-search-wrapper .cls-clear[hidden] {
    display: none !important;
}

/* Status text */
.cls-search-wrapper .cls-status {
    margin: 0.5rem auto 0 !important;
    max-width: 640px !important;
    font-size: 0.82rem !important;
    color: #8a9099;
    min-height: 1.2em;
    text-align: right;
    padding-right: 4px;
}

/* Hidden items during search */
.cls-hidden {
    display: none !important;
}

/* No-results message */
.cls-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem 1rem;
    color: #8a9099;
    font-size: 0.95rem;
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
    .cls-search-wrapper .cls-input {
        background: #1c1e22;
        color: #e9ecef;
        border-color: #34383e !important;
    }
    .cls-search-wrapper .cls-input::placeholder {
        color: #6b7178;
    }
    .cls-search-wrapper .cls-clear {
        background: #2a2d32 !important;
        color: #b0b5bb;
    }
    .cls-search-wrapper .cls-clear:hover {
        background: #35393f !important;
        color: #fff;
    }
    .cls-search-wrapper .cls-status,
    .cls-no-results {
        color: #7d8288;
    }
}

/* ── Mobile ── */
@media (max-width: 600px) {
    .cls-search-wrapper {
        margin: 0 0 1.1rem !important;
        padding: 0 0.15rem;
    }
    .cls-search-wrapper .cls-input-wrap {
        max-width: 100% !important;
    }
    .cls-search-wrapper .cls-input {
        height: 46px !important;
        line-height: 46px !important;
        font-size: 16px !important; /* stops iOS auto-zoom on focus */
        padding: 0 2.5rem 0 2.75rem !important;
        border-radius: 11px !important;
    }
    .cls-search-wrapper .cls-icon {
        left: 13px !important;
        width: 17px !important;
        height: 17px !important;
    }
    .cls-search-wrapper .cls-clear {
        right: 6px !important;
        width: 28px;
        height: 28px;
    }
    .cls-search-wrapper .cls-status {
        max-width: 100% !important;
        font-size: 0.78rem !important;
        text-align: left;
        padding: 0 2px;
    }
    .cls-no-results {
        padding: 2rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .cls-search-wrapper .cls-input {
        padding: 0 2.3rem 0 2.55rem !important;
    }
}
