/* ==========================================
   INDEX PAGE - ABSOLUTE FIX FOR Z-INDEX
   Perfect Stacking Context & Backdrop Filter
   ========================================== */

/* === Stats Section === */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    padding: 0 5px;
}

.stat-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    font-size: 1.6rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(180deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Loader === */
#loader { 
    text-align: center; 
    padding: 60px 20px; 
    color: var(--text-muted); 
    font-size: 1.1rem; 
}

.loader-spinner {
    width: 45px;
    height: 45px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Filter Section === */
.filter-wrapper { 
    max-width: 900px; 
    margin: 0 auto 40px; 
    background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.search-row { 
    display: flex; 
    gap: 12px; 
    margin-bottom: 20px; 
    flex-wrap: wrap;
    position: relative;
}

.search-input { 
    flex: 2; 
    min-width: 250px; 
    background: rgba(0,0,0,0.2); 
    border: 1px solid var(--border); 
    padding: 14px 20px; 
    border-radius: 12px; 
    color: #fff; 
    font-family: inherit; 
    font-size: 1rem; 
    transition: all 0.3s ease; 
}

.search-input:focus { 
    outline: none; 
    border-color: var(--accent); 
    background: rgba(0,0,0,0.4);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.05);
}

.search-input::placeholder {
    color: #666;
}

.search-loading {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.search-loading.active {
    opacity: 1;
}

.categories { 
    display: flex; 
    justify-content: center; 
    gap: 10px; 
    margin-bottom: 10px;
    flex-wrap: wrap; 
}

/* === Grid & Cards === */
.teams-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 24px; 
    margin-bottom: 60px; 
}

.card { 
    background: var(--card-bg); 
    border: 1px solid var(--border); 
    border-radius: 16px;
    overflow: hidden; 
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer; 
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    animation: card-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes card-appear {
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(7) { animation-delay: 0.35s; }
.card:nth-child(8) { animation-delay: 0.4s; }
.card:nth-child(9) { animation-delay: 0.45s; }

.card:hover { 
    border-color: rgba(255, 255, 255, 0.3); 
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.card-img-container { 
    width: 100%; 
    height: 280px; 
    background: #050505; 
    overflow: hidden;
    position: relative;
}

.card-img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    opacity: 0.9;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease; 
}

.card:hover .card-img { 
    opacity: 1; 
    transform: scale(1.08); 
}

.card-img-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.9) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card:hover .card-img-container::after {
    opacity: 1;
}

.card-content { 
    padding: 22px; 
    position: relative;
    z-index: 2;
}

.card-name { 
    font-size: 1.25rem; 
    font-weight: 800; 
    margin-bottom: 6px; 
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.card-title { 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    margin-bottom: 16px; 
    font-weight: 500;
}

.tag-container { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
}

.tag { 
    font-size: 0.75rem; 
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1); 
    padding: 5px 12px; 
    border-radius: 20px;
    color: #ddd;
    transition: all 0.2s ease;
}

.card:hover .tag {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* === Confirmation Badges === */
.confirmation-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-right: auto;
}

.badge-green { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.4); color: #10b981; }
.badge-blue { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.4); color: #3b82f6; }
.badge-gold { 
    background: rgba(245, 158, 11, 0.15); 
    border: 1px solid rgba(245, 158, 11, 0.4); 
    color: #fbbf24;
    animation: gold-glow 2s ease-in-out infinite; 
}

@keyframes gold-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.4); }
}

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    border-radius: 8px;
}

.skeleton-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.skeleton-img { width: 100%; height: 280px; border-radius: 0; }
.skeleton-content { padding: 22px; }
.skeleton-title { height: 26px; width: 70%; margin-bottom: 12px; }
.skeleton-subtitle { height: 18px; width: 50%; margin-bottom: 20px; }
.skeleton-tags { display: flex; gap: 8px; }
.skeleton-tag { height: 26px; width: 65px; border-radius: 20px; }

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

/* ==========================================
   MODAL - FIXED Z-INDEX & BACKDROP
   ========================================== */
.modal { 
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Modal Z-index is 1000 */
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active { 
    opacity: 1;
    visibility: visible;
}

.modal-content { 
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    max-width: 950px;
    border-radius: 24px;
    position: relative;
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Custom scrollbar */
.modal-content::-webkit-scrollbar { width: 8px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
.modal-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.modal.active .modal-content {
    transform: translateY(0) scale(1);
}

/* دکمه بستن مدال - ثابت و بزرگ برای کلیک راحت */
.close-modal { 
    position: fixed; /* ثابت در صفحه، حتی موقع اسکرول */
    left: 25px;
    top: 25px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 50px;     /* بزرگتر شد برای کلیک راحت تر */
    height: 50px;    /* بزرگتر شد */
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem; /* آیکون بزرگتر شد */
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1010;   /* بالاتر از همه چیز در مدال */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.close-modal:hover { 
    background: var(--danger, #ef4444);
    border-color: var(--danger, #ef4444);
    transform: rotate(90deg) scale(1.1); /* انیمیشن جذاب موقع هاور */
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.4);
}

.modal-inner { 
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 40px;
}

.modal-sidebar { display: flex; flex-direction: column; gap: 20px; }

.modal-profile-img { 
    width: 100%;
    border-radius: 18px;
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

.modal-profile-img:hover { 
    transform: scale(1.03);
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}

.modal-action-area { display: flex; flex-direction: column; gap: 12px; }

#m-name { font-size: 2.2rem; font-weight: 900; margin-bottom: 8px; color: #fff; line-height: 1.3; }
#m-title { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 25px; font-weight: 500; }
#m-tags { margin-bottom: 30px; }
#m-tags .tag { font-size: 0.85rem; padding: 6px 16px; margin: 4px; }
#m-desc { font-size: 1.05rem; line-height: 1.9; color: #ddd; text-align: justify; }

.modal-description {
    background: rgba(255, 255, 255, 0.02);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 30px;
}

.info-row { 
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.info-row:hover { border-color: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.05); }
.info-row svg { width: 26px; height: 26px; fill: var(--text-muted); margin-top: 2px; flex-shrink: 0; }
.info-label { color: var(--text-muted); font-size: 0.85rem; display: block; margin-bottom: 6px; font-weight: 500; }
.info-value { color: #fff; font-size: 1.1rem; line-height: 1.7; font-weight: 700; }

.share-box { border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 18px; background: rgba(255,255,255,0.02); }
.share-title { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; display: block; }
.share-btns { display: flex; gap: 10px; }

.share-btn { 
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
    color: #eee; text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: all 0.2s ease;
}
.share-btn:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); color: #fff; }
.share-btn svg { width: 18px; height: 18px; fill: currentColor; }

.report-btn { 
    width: 100%; padding: 16px; background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); border-radius: 16px;
    cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center;
    justify-content: center; gap: 10px; font-weight: 700; text-decoration: none; font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
}
.report-btn:hover { background: var(--danger); color: white; box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3); }

.confirm-btn {
    width: 100%; padding: 16px; background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3); color: var(--success); border-radius: 16px;
    cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center;
    justify-content: center; gap: 10px; font-weight: 700; font-size: 1rem; margin-bottom: 12px;
    font-family: 'Vazirmatn', sans-serif;
}
.confirm-btn:hover:not(:disabled) { background: var(--success); color: #000; box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3); }
.confirm-btn:disabled { opacity: 0.8; cursor: not-allowed; }

/* ==========================================
   GALLERY
   ========================================== */
#g-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-top: 35px; }

.g-item { 
    position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1); cursor: zoom-in; transition: all 0.3s ease;
}
.g-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.3); }

.g-item img, .g-item video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.g-item:hover img, .g-item:hover video { transform: scale(1.05); }

.video-play-hint { 
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4); pointer-events: none; transition: background 0.3s ease;
}
.g-item:hover .video-play-hint { background: rgba(0,0,0,0.2); }
.video-badge { 
    position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.7); 
    color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; 
    font-weight: 800; pointer-events: none; backdrop-filter: blur(4px); 
}

/* ==========================================
   LIGHTBOX - PERFECT Z-INDEX & BACKDROP
   ========================================== */
.lightbox { 
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9999; /* Lightbox Z-index is higher than Modal */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.lightbox.active { 
    opacity: 1;
    visibility: visible;
}

.lightbox-close {
    position: fixed;
    top: 25px;
    left: 25px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.2s ease;
    z-index: 10000;
}

.lightbox-close:hover { background: var(--danger); border-color: var(--danger); transform: rotate(90deg); }

#lb-content {
    max-width: 90%;
    max-height: 85vh;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.active #lb-content { transform: scale(1); }

/* === Lightbox Navigation Arrows === */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10001; /* بالاتر از پس زمینه لایت‌باکس */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lightbox-nav:hover {
    background: var(--accent, #fff);
    color: #000;
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.lightbox-next { right: 30px; }
.lightbox-prev { left: 30px; }

/* ترانزیشن برای تغییر نرم عکس‌ها */
#lb-content {
    transition: opacity 0.2s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 600px) {
    .lightbox-nav { width: 45px; height: 45px; font-size: 1.2rem; }
    .lightbox-next { right: 15px; }
    .lightbox-prev { left: 15px; }
}

/* === Toast Notifications === */
.toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 10001; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.toast { background: rgba(20, 20, 20, 0.95); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 14px; padding: 16px 25px; display: flex; align-items: center; gap: 14px; color: #fff; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; pointer-events: auto; backdrop-filter: blur(10px); }
.toast.toast-out { animation: toast-out 0.3s ease forwards; }
.toast-success { border-bottom: 3px solid #10b981; } .toast-error { border-bottom: 3px solid #ef4444; } .toast-info { border-bottom: 3px solid #3b82f6; }
.toast-icon { font-size: 1.2rem; font-weight: bold; }

@keyframes toast-in { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(30px); } }

/* === Empty State === */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon { font-size: 4rem; margin-bottom: 20px; opacity: 0.3; }
.empty-state-text { color: var(--text-muted); margin-bottom: 15px; }
.empty-state-link { color: var(--accent); text-decoration: underline; }

/* === Pagination === */
#pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 40px 0 60px;
    flex-wrap: wrap;
}

#pagination-container button {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    min-width: 45px;
}

#pagination-container button:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

#pagination-container button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

#pagination-container button.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 700;
}

/* ==========================================
   Shared Toast Fallback
   Added for new AppToast system
   Does not change existing theme
   ========================================== */

#toast-container:empty {
    display: none;
}

.toast-out {
    opacity: 0;
    transform: translateY(20px);
}

/* === Responsive === */
@media (max-width: 950px) {
    .modal-inner { grid-template-columns: 1fr; gap: 30px; }
    .modal-sidebar { flex-direction: row; align-items: flex-start; }
    .modal-profile-img { width: 180px; }
    .modal-action-area { flex: 1; }
    #g-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    .stats-section { grid-template-columns: repeat(2, 1fr); }
    .search-row { flex-direction: column; }
    .search-input { min-width: 100%; }
    .modal-content { padding: 30px 20px; }
    .modal-sidebar { flex-direction: column; }
    .modal-profile-img { width: 100%; max-width: 250px; margin: 0 auto; }
    #m-name { text-align: center; font-size: 1.8rem; } 
    #m-title { text-align: center; } 
    #m-tags { justify-content: center; }
    #g-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}

@media (max-width: 480px) {
    .stats-section { gap: 12px; }
    .stat-card { padding: 15px; }
    .stat-value { font-size: 1.5rem; }
    .teams-grid { gap: 16px; }
    .card-img-container { height: 220px; }
    #g-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .lightbox-close { top: 15px; left: 15px; width: 40px; height: 40px; }
    #m-name { font-size: 1.5rem; }
}