/* ============================================
   Search Articles Modal - مودال جستجوی مقالات
   ============================================ */

/* Header search area: input text cursor for typing */
.main-header .search-header input[type="search"] {
    cursor: text;
}

/* Overlay Backdrop */
.search-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    overflow-y: auto;
}

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

/* Modal Container */
.search-modal {
    width: 100%;
    max-width: 680px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.08);
    transform: translateY(-20px) scale(0.97);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    max-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 16px;
}

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

/* Modal Header / Search Input Area */
.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1.5px solid #f1f5f9;
    flex-shrink: 0;
    position: relative;
}

.search-modal-header .search-modal-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.search-modal-header:focus-within .search-modal-icon {
    opacity: 1;
}

.search-modal-header .search-modal-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 17px;
    font-weight: 500;
    color: #1e293b;
    font-family: "YekanBakh", sans-serif;
    caret-color: #E12528;
    direction: rtl;
    line-height: 1.5;
}

.search-modal-header .search-modal-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    font-family: "YekanBakh", sans-serif;
}

.search-modal-header .search-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: none;
    background: #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.search-modal-header .search-modal-close:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.search-modal-header .search-modal-close img {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

/* Clear Input Button */
.search-modal-header .search-clear-btn {
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.search-modal-header .search-clear-btn.visible {
    display: flex;
}

.search-modal-header .search-clear-btn:hover {
    background: #fee2e2;
}

.search-modal-header .search-clear-btn svg {
    width: 12px;
    height: 12px;
    color: #64748b;
}

/* Keyboard hint */
.search-modal-kbd {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
}

.search-modal-kbd kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 5px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-family: "YekanBakh", sans-serif;
    font-size: 11px;
    color: #64748b;
    box-shadow: 0 1px 0 #e2e8f0;
}

/* Modal Body */
.search-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}

.search-modal-body::-webkit-scrollbar {
    width: 4px;
}

.search-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.search-modal-body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

/* Section Headers */
.search-modal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 10px;
}

.search-modal-section-header .section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.search-modal-section-header .section-label .section-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #E12528;
    flex-shrink: 0;
}

.search-modal-section-header .section-count {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* Loading State */
.search-modal-loading {
    display: none;
    padding: 24px;
    gap: 16px;
    flex-direction: column;
}

.search-modal-loading.visible {
    display: flex;
}

.search-skeleton-card {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.search-skeleton-card .skeleton-image {
    width: 88px;
    height: 62px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e8edf2 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    border-radius: 12px;
    flex-shrink: 0;
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
}

.search-skeleton-card .skeleton-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

.search-skeleton-card .skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e8edf2 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
}

.search-skeleton-card .skeleton-line:first-child {
    width: 75%;
    height: 14px;
}

.search-skeleton-card .skeleton-line:nth-child(2) {
    width: 100%;
}

.search-skeleton-card .skeleton-line:last-child {
    width: 40%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Articles List */
.search-modal-articles {
    list-style: none;
    margin: 0;
    padding: 0 16px 8px;
}

.search-modal-articles .article-search-item {
    border-radius: 14px;
    transition: background 0.2s ease;
    position: relative;
}

.search-modal-articles .article-search-item:hover {
    background: #f8fafc;
}

.search-modal-articles .article-search-item + .article-search-item {
    border-top: 1px solid #f1f5f9;
}

.search-modal-articles .article-search-link {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 10px;
    text-decoration: none;
    color: inherit;
    border-radius: 14px;
    transition: all 0.2s ease;
}

/* Article Image */
.article-search-link .article-search-image {
    width: 100px;
    height: 70px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f1f5f9;
    position: relative;
}

.article-search-link .article-search-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.article-search-item:hover .article-search-image img {
    transform: scale(1.05);
}

.article-search-link .article-search-image .article-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fee2e2, #fef2f2);
}

.article-search-link .article-search-image .article-no-image svg {
    width: 28px;
    height: 28px;
    color: #E12528;
    opacity: 0.5;
}

/* Article Text Info */
.article-search-link .article-search-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.article-search-info .article-search-category {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #E12528;
    background: #fef2f2;
    padding: 2px 8px;
    border-radius: 6px;
    width: fit-content;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-search-info .article-search-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    transition: color 0.2s ease;
}

.article-search-item:hover .article-search-title {
    color: #E12528;
}

.article-search-info .article-search-title mark {
    background: rgba(225, 37, 40, 0.12);
    color: #E12528;
    border-radius: 3px;
    padding: 0 2px;
}

.article-search-info .article-search-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: #94a3b8;
}

.article-search-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.article-search-meta .meta-item svg {
    width: 13px;
    height: 13px;
    opacity: 0.7;
}

.article-search-meta .meta-divider {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
}

/* Arrow Icon */
.article-search-link .article-search-arrow {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 4px;
}

.article-search-item:hover .article-search-arrow {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.article-search-arrow svg {
    width: 16px;
    height: 16px;
    color: #cbd5e1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.article-search-item:hover .article-search-arrow svg {
    color: #E12528;
    transform: translateX(-2px);
}

/* No Results State */
.search-modal-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 12px;
    text-align: center;
}

.search-modal-empty.visible {
    display: flex;
}

.search-modal-empty .empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.search-modal-empty .empty-icon svg {
    width: 32px;
    height: 32px;
    color: #cbd5e1;
}

.search-modal-empty .empty-title {
    font-size: 15px;
    font-weight: 600;
    color: #475569;
    margin: 0;
}

.search-modal-empty .empty-text {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.7;
    margin: 0;
    max-width: 300px;
}

/* Modal Footer */
.search-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1.5px solid #f1f5f9;
    flex-shrink: 0;
    background: #fafbfc;
    border-radius: 0 0 24px 24px;
}

.search-modal-footer .footer-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #94a3b8;
}

.search-modal-footer .footer-hint .hint-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-modal-footer .footer-hint .hint-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    box-shadow: 0 1px 0 #e2e8f0;
    font-family: "YekanBakh", sans-serif;
}

.search-modal-footer .footer-all-articles {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #E12528;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.search-modal-footer .footer-all-articles:hover {
    background: #fef2f2;
}

.search-modal-footer .footer-all-articles svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.search-modal-footer .footer-all-articles:hover svg {
    transform: translateX(-3px);
}

/* Body scroll lock */
body.search-modal-open {
    overflow: hidden;
}

/* ============================================
   Responsive Styles
   ============================================ */

@media screen and (max-width: 768px) {
    .search-modal-overlay {
        padding-top: 0;
        align-items: flex-end;
    }

    .search-modal {
        max-width: 100%;
        margin: 0;
        border-radius: 24px 24px 0 0;
        max-height: 92dvh;
        transform: translateY(100%);
        opacity: 1;
    }

    .search-modal-overlay.is-open .search-modal {
        transform: translateY(0);
    }

    .search-modal-header {
        padding: 16px 16px 12px;
    }

    .search-modal-kbd {
        display: none;
    }

    .search-modal-articles {
        padding: 0 10px 8px;
    }

    .search-modal-articles .article-search-link {
        padding: 12px 8px;
        gap: 10px;
    }

    .article-search-link .article-search-image {
        width: 80px;
        height: 56px;
        border-radius: 10px;
    }

    .article-search-info .article-search-title {
        font-size: 13px;
    }

    .article-search-link .article-search-arrow {
        display: none;
    }

    .search-modal-footer {
        padding: 10px 16px;
    }

    .search-modal-footer .footer-hint {
        display: none;
    }

    .search-modal-section-header {
        padding: 14px 16px 8px;
    }

    .search-modal-loading {
        padding: 16px;
    }
}

@media screen and (max-width: 420px) {
    .article-search-link .article-search-image {
        width: 70px;
        height: 50px;
    }

    .article-search-info .article-search-meta {
        flex-wrap: wrap;
        gap: 6px;
    }

    .search-modal-empty {
        padding: 32px 16px;
    }
}
