﻿/**
 * استایل‌های مودال جستجو - فیلمینجو
 * تم هماهنگ با صفحه اصلی - ریسپانسیو کامل
 */

/* =====================
   پس‌زمینه مودال
   ===================== */
.search-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: #222222;
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
}

.search-modal.active {
    display: block;
    animation: modalFadeIn 0.25s ease-out;
}

.search-modal.closing {
    animation: modalFadeOut 0.25s ease-in forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modalFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* =====================
   محتوای مودال
   ===================== */
.search-modal-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 20px 40px;
    animation: contentSlideUp 0.3s ease-out 0.05s both;
}

@keyframes contentSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================
   نوار بالای مودال — دکمه بستن + عنوان
   ===================== */
.search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.search-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #94a3b8;
    font-family: 'Vazirmatn', sans-serif;
}

/* دکمه بستن — همیشه داخل جریان */
.close-modal-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    background: rgba(42,42,42,0.8);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 8px 16px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 500;
    position: static;
    transform: none;
}

.close-modal-btn:hover {
    color: #f1f5f9;
    background: #444444;
    border-color: rgba(0,140,255,0.4);
}

/* =====================
   کانتینر ورودی جستجو
   ===================== */
.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    background: #2a2a2a;
    border: 1.5px solid rgba(0,140,255,0.25);
    border-radius: 12px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.search-input-container:focus-within {
    border-color: rgba(0,140,255,0.6);
    box-shadow: 0 0 0 3px rgba(0,140,255,0.1);
}

/* ورودی — flex-grow می‌گیره، padding راست برای ذره‌بین */
.search-input {
    flex: 1 1 0%;
    min-width: 0;
    background: transparent;
    color: #f8fafc;
    font-size: 1.1rem;
    padding: 16px 48px 16px 12px;
    border: none;
    outline: none;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 400;
}

.search-input::placeholder {
    color: #64748b;
    font-weight: 300;
}

/* آیکون ذره‌بین — absolute سمت راست */
.search-input-container::before {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    opacity: 0.7;
    pointer-events: none;
}

/* وقتی clear نمایش داره، ذره‌بین پنهان بشه */
.search-input-container:has(.clear-text.show)::before {
    display: none;
}

/* ─── گروه سمت چپ: [ ✕ ] | [ 🎤 ] ─── */
.search-left-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 100%;
    padding-left: 4px;
}

/* دکمه ضربدر */
.clear-text {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 50%;
    background: #3a3a3a;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    line-height: 0;
}

.clear-text:hover {
    color: #f1f5f9;
    background: #dc2626;
}

.clear-text.show {
    display: flex;
    animation: clearButtonShow 0.15s ease-out;
}

@keyframes clearButtonShow {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

/* خط جداکننده عمودی */
.search-divider {
    display: block;
    width: 1px;
    height: 20px;
    background: rgba(148, 163, 184, 0.55);
    margin: 0 6px;
    flex-shrink: 0;
}

/* وقتی ضربدر پنهانه، خط هم پنهان باشه */
.search-input-container:not(:has(.clear-text.show)) .search-divider {
    display: none;
}

/* ─── دکمه میکروفون ─── */
.voice-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    padding: 0;
    margin-left: 4px;
}

.voice-search-btn:hover {
    color: #008CFF;
    background: rgba(0,140,255,0.1);
}

/* مرورگر بدون پشتیبانی */
.voice-search-btn.unsupported {
    display: none;
}
.search-input-container:has(.voice-search-btn.unsupported) .search-divider {
    display: none;
}

/* حالت در حال ضبط */
.voice-search-btn.listening {
    color: #ef4444;
    background: rgba(239,68,68,0.12);
    animation: voicePulse 1.2s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.35); }
    50%       { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* دسترسی میکروفون رد شده — دکمه نمایش داده می‌شه، فقط رنگ تغییر می‌کنه */
.voice-search-btn.denied {
    color: #f59e0b;
    background: rgba(245,158,11,0.1);
    opacity: 0.75;
}

/* =====================
   نتایج جستجو
   ===================== */
.search-results {
    min-height: 100px;
}

.search-results:empty { display: none; }

/* گرید کارت‌ها — دسکتاپ ۵ ستون */
.sr-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-top: 8px;
}

/* دکمه بارگذاری بیشتر */
.sr-load-more {
    text-align: center;
    margin-top: 1.5rem;
}

.sr-load-more-btn {
    background: rgba(0,140,255,0.12);
    color: #008CFF;
    border: 1px solid rgba(0,140,255,0.35);
    border-radius: 10px;
    padding: 0.65rem 2rem;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sr-load-more-btn:hover {
    background: rgba(0,140,255,0.25);
    border-color: rgba(0,140,255,0.6);
}

.sr-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =====================
   کارت نتیجه جستجو
   ===================== */
.sr-card {
    display: flex;
    flex-direction: column;
}

.sr-card-img-wrap {
    position: relative;
    width: 100%;
    height: 14rem;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.sr-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sr-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    z-index: 10;
    font-size: 0.6rem;
    line-height: 1.3;
}

.sr-card-overlay .space-y-1 > * + * { margin-top: 2px; }

.sr-card-btns {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.sr-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sr-card:hover .sr-action-btn {
    opacity: 1;
    transform: scale(1);
}

/* عنوان — ارتفاع ثابت، ۲ خط با ... */
.sr-card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f8fafc;
    text-align: center;
    margin-top: 0.5rem;
    padding: 0 0.25rem;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* =====================
   پیشنهادات
   ===================== */
.search-suggestions {
    animation: suggestionsShow 0.4s ease-out 0.15s both;
}

@keyframes suggestionsShow {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.suggestion-category h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #66BBFF;
    margin-bottom: 12px;
    font-family: 'Vazirmatn', sans-serif;
}

.suggestion-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0;
}

.suggestion-item {
    background: #2a2a2a;
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.08);
    font-family: 'Vazirmatn', sans-serif;
}

.suggestion-item:hover {
    background: rgba(0,140,255,0.15);
    color: #66BBFF;
    border-color: rgba(0,140,255,0.35);
}

/* پیام عدم نتیجه */
.no-results {
    text-align: center;
    padding: 48px 24px;
    color: #64748b;
    font-size: 1rem;
    background: #2a2a2a;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.06);
    font-family: 'Vazirmatn', sans-serif;
    line-height: 1.8;
}

.no-results::before {
    content: '';
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

/* =====================
   ریسپانسیو — تبلت بزرگ (max 1280px)
   ===================== */
@media (max-width: 1280px) {
    .sr-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* =====================
   ریسپانسیو — تبلت (max 1024px)
   ===================== */
@media (max-width: 1024px) {
    .search-modal-content { padding: 16px 16px 40px; }
    .sr-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
    .sr-card-img-wrap { height: 12rem; }
}

/* =====================
   ریسپانسیو — تبلت کوچک (max 768px)
   ===================== */
@media (max-width: 768px) {
    .search-modal-content { padding: 14px 12px 80px; }
    .search-input { font-size: 1rem; padding: 14px 44px 14px 12px; }
    .sr-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .sr-card-img-wrap { height: 12rem; }
}

/* =====================
   ریسپانسیو — موبایل (max 600px)
   ===================== */
@media (max-width: 600px) {
    .search-modal-content { padding: 12px 10px 80px; }
    .search-input { font-size: 0.95rem; padding: 13px 42px 13px 12px; }
    .sr-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .sr-card-img-wrap { height: 17rem; }
    .suggestion-item {
        font-size: 0.8rem;
        padding: 7px 12px;
    }
    .suggestion-category h3 {
        font-size: 0.9rem;
    }
}

/* =====================
   ریسپانسیو — موبایل خیلی کوچک (max 380px)
   ===================== */
@media (max-width: 380px) {
    .sr-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .sr-card-img-wrap { height: 15rem; }
}

/* =====================
   بج قسمت در نتایج جستجو
   ===================== */
.episode-search-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    background: rgba(0, 140, 255, 0.9);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    direction: rtl;
    font-family: 'Vazirmatn', sans-serif;
}

/* ── تاریخچه جستجو ── */
.search-history-wrap { margin-bottom: 1rem; }

.sh-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.25rem 0.6rem;
}

.sh-title {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 500;
}

.sh-clear-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    padding: 0;
    transition: color 0.2s;
}
.sh-clear-btn:hover { color: #f87171; }

/* کانتینر اسکرولر با فلش‌های ناوبری */
.sh-scroller-container {
    position: relative;
    overflow: visible;
}

/* اسکرول افقی */
.sh-cards {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.sh-cards::-webkit-scrollbar { display: none; }

/* دکمه‌های فلش — از پیش مخفی، JS آن‌ها را نمایش می‌دهد */
.sh-nav-btn {
    position: absolute;
    top: 42%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(26,26,26,0.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,140,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 30;
    cursor: pointer;
    transition: opacity 0.25s ease, background 0.25s ease;
    opacity: 0;
    pointer-events: none;
}
.sh-nav-btn:hover {
    background: rgba(0,140,255,0.75);
    border-color: #008CFF;
}
.sh-nav-left  { left: -16px; }
.sh-nav-right { right: -16px; }

/* ── کارت‌های تاریخچه ── */

/* sh-card: wrapper با عرض ثابت محاسبه‌شده
   فرمول: (عرض کانتینر - 4×gap) / 5
   کانتینر دسکتاپ ≈ 860px  →  (860 - 64) / 5 = 159.2 ≈ 159px */
.sh-card {
    flex-shrink: 0;
    width: calc((100% - 4 * 16px) / 5);
    min-width: 120px;
}

/* sr-card داخل sh-card عرض کامل wrapper را می‌گیرد */
.sh-card .sr-card {
    width: 100%;
}

/* ارتفاع تصویر — همان مقادیر sr-card-img-wrap در هر breakpoint */
.sh-card .sr-card-img-wrap {
    width: 100%;
    height: 14rem;
}

/* تبلت ۱۰۲۴ — grid 3 ستون */
@media (max-width: 1024px) {
    .sh-card .sr-card-img-wrap { height: 12rem; }
}
/* تبلت کوچک ۷۶۸ */
@media (max-width: 768px) {
    .sh-card .sr-card-img-wrap { height: 12rem; }
}
/* موبایل — ۲ کارت در دید */
@media (max-width: 600px) {
    .sh-card          { width: calc((100% - 16px) / 2); min-width: 130px; }
    .sh-card .sr-card-img-wrap { height: 17rem; }
    .sh-nav-btn   { width: 28px; height: 28px; }
    .sh-nav-left  { left: -10px; }
    .sh-nav-right { right: -10px; }
}
@media (max-width: 380px) {
    .sh-card .sr-card-img-wrap { height: 15rem; }
}
