/* =========================================================
   TV Schedule EPG — Search widget
   shortcode: [tvsmepg_search]
   ========================================================= */

/* ── Wrapper ──────────────────────────────────────────── */
.tvsmepg-search-wrap {
    font-family: inherit;
    box-sizing: border-box;
    max-width: 100%;
}
.tvsmepg-search-wrap *,
.tvsmepg-search-wrap *::before,
.tvsmepg-search-wrap *::after {
    box-sizing: border-box;
}

/* ── Form row ─────────────────────────────────────────── */
.tvsmepg-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ── Search input wrapper ─────────────────────────────── */
.tvsmepg-search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.tvsmepg-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
    pointer-events: none;
    display: block;
}

.tvsmepg-search-input {
    width: 100% !important;
    padding: 9px 36px 9px 34px !important;
    border: 1.5px solid #d1d5db !important;
    border-radius: 8px !important;
    font-size: .9rem !important;
    line-height: 1.4 !important;
    background: #fff !important;
    color: #111827 !important;
    outline: none !important;
    transition: border-color .18s, box-shadow .18s;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none !important;
}
.tvsmepg-search-input:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12) !important;
}
/* hide native clear button in webkit */
.tvsmepg-search-input::-webkit-search-cancel-button { display: none; }

.tvsmepg-search-clear {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
}
.tvsmepg-search-clear:hover { color: #374151; }

/* ── Channel select & date input ──────────────────────── */
.tvsmepg-search-channel,
.tvsmepg-search-date {
    padding: 9px 10px !important;
    border: 1.5px solid #d1d5db !important;
    border-radius: 8px !important;
    font-size: .85rem !important;
    background: #fff !important;
    color: #374151 !important;
    outline: none !important;
    cursor: pointer;
    height: auto !important;
    transition: border-color .18s;
}
.tvsmepg-search-channel:focus,
.tvsmepg-search-date:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12) !important;
}
.tvsmepg-search-channel { flex: 0 0 auto; max-width: 160px; }
.tvsmepg-search-date    { flex: 0 0 auto; }

/* Dark theme */
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-input,
    .tvsmepg-search-channel,
    .tvsmepg-search-date {
        background: #1e2432 !important;
        border-color: rgba(255,255,255,.12) !important;
        color: #e8eaf0 !important;
    }
    .tvsmepg-search-input:focus,
    .tvsmepg-search-channel:focus,
    .tvsmepg-search-date:focus {
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59,130,246,.15) !important;
    }
}

/* ── Results area ─────────────────────────────────────── */
.tvsmepg-search-results {
    min-height: 40px;
}

/* Hint / empty / loading / message */
.tvsmepg-search-hint,
.tvsmepg-search-empty,
.tvsmepg-search-loading,
.tvsmepg-search-count {
    font-size: .82rem;
    color: #9ca3af;
    padding: 10px 4px;
}
.tvsmepg-search-count {
    font-weight: 600;
    color: #6b7280;
    padding-bottom: 6px;
}

/* Spinner */
.tvsmepg-search-loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #d1d5db;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: tvsmepg-spin .7s linear infinite;
    margin-right: 7px;
    vertical-align: middle;
}
@keyframes tvsmepg-spin { to { transform: rotate(360deg); } }

/* ── Result list ──────────────────────────────────────── */
.tvsmepg-search-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tvsmepg-search-list li::before,
.tvsmepg-search-list li::after { display: none !important; content: none !important; }

/* ── Single result item ───────────────────────────────── */
.tvsmepg-search-item {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: background .15s, border-color .15s, box-shadow .15s;
    cursor: default;
}
.tvsmepg-search-item:hover {
    background: #f8faff;
    border-color: #c7d2fe;
    box-shadow: 0 2px 8px rgba(37,99,235,.07);
}
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-item { background: #1e2432; border-color: rgba(255,255,255,.08); }
    .tvsmepg-search-item:hover { background: #252d3e; border-color: rgba(99,102,241,.35); }
}

/* Channel logo column */
.tvsmepg-search-item-logo {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain;
    background: #f1f3f8;
}
.tvsmepg-search-item-logo-fallback {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .03em;
}

/* Body */
.tvsmepg-search-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tvsmepg-search-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tvsmepg-search-item-channel {
    font-size: .72rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
}
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-item-channel { color: #9ca3af; }
}

.tvsmepg-search-item-time {
    font-size: .72rem;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

.tvsmepg-search-item-date {
    font-size: .7rem;
    color: #9ca3af;
}

.tvsmepg-search-item-title {
    font-size: .9rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-item-title { color: #f3f4f6; }
}

.tvsmepg-search-item-desc {
    font-size: .78rem;
    color: #6b7280;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-item-desc { color: #9ca3af; }
}

/* Badges */
.tvsmepg-search-item-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.tvsmepg-srch-badge {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.4;
}
.tvsmepg-srch-badge--live   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.tvsmepg-srch-badge--replay { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.tvsmepg-srch-badge--adult  { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.tvsmepg-srch-badge--cat    { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }

/* Highlight search term */
.tvsmepg-search-hl {
    background: #fef9c3;
    border-radius: 2px;
    padding: 0 1px;
}
@media (prefers-color-scheme: dark) {
    .tvsmepg-search-hl { background: rgba(253,224,71,.2); }
}

/* ── Thumbnail column (optional) ──────────────────────── */
.tvsmepg-search-item-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: #f1f3f8;
}

@media (max-width: 480px) {
    .tvsmepg-search-item-thumb { display: none; }
}
