/**
 * GSM Root / Download Center - Live AJAX Instant Search Stylesheet
 * 60fps GPU-Accelerated Animations, Glassmorphism, Compact & Responsive
 */

/* Dropdown Container */
.gsm-live-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-width: 680px;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 10px;
    box-shadow: 0 14px 34px -4px rgba(15, 23, 42, 0.18), 0 0 1px 1px rgba(0, 0, 0, 0.05);
    z-index: 999999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    text-align: left;
}

.gsm-live-search-dropdown.is-open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Compact Scrollable Results Area */
.gsm-search-results-body {
    flex: 1 1 auto;
    max-height: 220px; /* Compact height: fits ~2.5 items comfortably with visible scrollbar */
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Custom Smooth Scrollbar */
.gsm-search-results-body::-webkit-scrollbar,
.gsm-live-search-dropdown::-webkit-scrollbar {
    width: 5px;
}
.gsm-search-results-body::-webkit-scrollbar-track,
.gsm-live-search-dropdown::-webkit-scrollbar-track {
    background: #f8fafc;
}
.gsm-search-results-body::-webkit-scrollbar-thumb,
.gsm-live-search-dropdown::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}
.gsm-search-results-body::-webkit-scrollbar-thumb:hover,
.gsm-live-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Dropdown Top Bar with Direct Close Action */
.gsm-dropdown-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #edf2f7;
    position: sticky;
    top: 0;
    z-index: 10;
}

.gsm-dropdown-topbar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gsm-dropdown-topbar-title i {
    color: #3b82f6;
    font-size: 11.5px;
}

.gsm-dropdown-close-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
    transition: all 0.15s ease;
}

.gsm-dropdown-close-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Group Headers */
.gsm-search-group {
    border-bottom: 1px solid #f1f5f9;
}
.gsm-search-group:last-child {
    border-bottom: none;
}

.gsm-search-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: #fcfdfe;
    border-bottom: 1px solid #edf2f7;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #64748b;
}

.gsm-search-group-header .group-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gsm-search-group-header .group-title i {
    font-size: 11.5px;
    color: #3b82f6;
}

.gsm-search-group-header .group-count {
    background: #e2e8f0;
    color: #334155;
    padding: 1px 5px;
    border-radius: 10px;
    font-size: 9.5px;
    font-weight: 600;
}

/* Search Items List */
.gsm-search-items-list {
    list-style: none;
    padding: 2px 0;
    margin: 0;
}

.gsm-search-item {
    display: flex;
    align-items: center;
    padding: 7px 14px;
    gap: 10px;
    text-decoration: none !important;
    color: #1e293b !important;
    transition: background-color 0.12s ease, transform 0.12s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.gsm-search-item:hover,
.gsm-search-item.is-selected {
    background-color: #f1f5f9;
    border-left-color: #3b82f6;
    text-decoration: none !important;
}

/* Item Thumbnail */
.gsm-search-thumb {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.gsm-search-thumb-icon {
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.gsm-search-thumb-icon.icon-file {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #2563eb;
}
.gsm-search-thumb-icon.icon-folder {
    background: linear-gradient(135deg, #fefce8, #fef08a);
    color: #ca8a04;
}
.gsm-search-thumb-icon.icon-product {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    color: #7c3aed;
}
.gsm-search-thumb-icon.icon-article {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #16a34a;
}

/* Item Information */
.gsm-search-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gsm-search-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.gsm-search-highlight {
    background: #fef08a;
    color: #854d0e;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 700;
}

.gsm-search-cat {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.gsm-search-cat i {
    font-size: 9.5px;
    color: #94a3b8;
}

/* Meta Badges */
.gsm-search-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 1px;
}

.gsm-search-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    line-height: 1.3;
}

.gsm-badge-free {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.gsm-badge-paid {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.gsm-badge-size {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.gsm-badge-downloads {
    background: #faf5ff;
    color: #7e22ce;
    border: 1px solid #e9d5ff;
}

.gsm-badge-folder {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* Item Action Arrow */
.gsm-search-action {
    color: #cbd5e1;
    font-size: 11.5px;
    transition: transform 0.12s ease, color 0.12s ease;
    padding-left: 3px;
}

.gsm-search-item:hover .gsm-search-action,
.gsm-search-item.is-selected .gsm-search-action {
    color: #3b82f6;
    transform: translateX(2px);
}

/* Footer Section */
.gsm-search-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.gsm-search-view-all-btn {
    font-size: 11.5px;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.12s ease;
}

.gsm-search-view-all-btn:hover {
    color: #1d4ed8;
    text-decoration: underline !important;
}

.gsm-search-hints {
    font-size: 10px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gsm-search-hints kbd {
    background: #e2e8f0;
    color: #475569;
    padding: 1px 3px;
    border-radius: 3px;
    font-size: 9px;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    box-shadow: none;
}

/* Skeleton Loading State */
.gsm-search-skeleton-group {
    padding: 6px 14px;
}

.gsm-search-skeleton-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.gsm-skeleton-box {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: gsm-skeleton-loading 1.4s infinite ease-in-out;
    border-radius: 5px;
}

.gsm-skeleton-thumb {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 6px;
}

.gsm-skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.gsm-skeleton-title {
    height: 13px;
    width: 75%;
}

.gsm-skeleton-subtitle {
    height: 10px;
    width: 45%;
}

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

/* Empty & Alert States */
.gsm-search-empty-state {
    padding: 22px 16px;
    text-align: center;
}

.gsm-search-empty-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.gsm-search-empty-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 3px;
}

.gsm-search-empty-text {
    font-size: 11.5px;
    color: #64748b;
    max-width: 300px;
    margin: 0 auto 8px;
    line-height: 1.35;
}

.gsm-search-empty-tip {
    font-size: 10.5px;
    color: #94a3b8;
    background: #f8fafc;
    padding: 4px 10px;
    border-radius: 5px;
    display: inline-block;
}

.search-area {
    position: relative;
}

/* RTL Support (Arabic) */
[dir="rtl"] .gsm-live-search-dropdown,
body.rtl .gsm-live-search-dropdown,
html[lang="ar"] .gsm-live-search-dropdown {
    text-align: right;
    direction: rtl;
    left: auto;
    right: 0;
}

[dir="rtl"] .gsm-search-item,
body.rtl .gsm-search-item,
html[lang="ar"] .gsm-search-item {
    border-left: none;
    border-right: 3px solid transparent;
}

[dir="rtl"] .gsm-search-item:hover,
[dir="rtl"] .gsm-search-item.is-selected,
body.rtl .gsm-search-item:hover,
body.rtl .gsm-search-item.is-selected,
html[lang="ar"] .gsm-search-item:hover,
html[lang="ar"] .gsm-search-item.is-selected {
    border-right-color: #3b82f6;
}

[dir="rtl"] .gsm-search-item:hover .gsm-search-action,
[dir="rtl"] .gsm-search-item.is-selected .gsm-search-action,
body.rtl .gsm-search-item:hover .gsm-search-action,
body.rtl .gsm-search-item.is-selected .gsm-search-action,
html[lang="ar"] .gsm-search-item:hover .gsm-search-action,
html[lang="ar"] .gsm-search-item.is-selected .gsm-search-action {
    transform: translateX(-2px);
}

@media (max-width: 768px) {
    .gsm-live-search-dropdown {
        max-width: 100%;
        left: 0;
        right: 0;
    }
}
