:root {
    /* متغيرات الألوان للثيم الداكن (الافتراضي) */
    --bg-primary: #121b27;
    --bg-secondary: #1a2436;
    --bg-tertiary: #26334e;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --border-color: rgba(255, 255, 255, 0.1);
    --card-bg: #1a2436;
    --hover-bg: #26334e;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --header-bg: #0c1220;
    --input-bg: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    /* Primary color palette */
    --primary-color: #8b5cf6; /* Vibrant purple as main color */
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    
    /* Secondary colors */
    --secondary-color: #2563eb; /* Blue for accents */
    --secondary-light: #3b82f6;
    --secondary-dark: #1d4ed8;
    
    /* Neutral colors */
    --dark-bg: #121212; /* Nearly black background */
    --card-hover: #2a2a2a; /* Hover state for cards */
    
    /* Text colors */
    --text-muted: #a0a0a0; /* Muted text */
    --text-bright: #ffffff; /* Bright white for emphasis */
    
    /* Status colors */
    --success-color: #10b981; /* Green */
    --warning-color: #f59e0b; /* Amber */
    --error-color: #ef4444; /* Red */
    --info-color: #3b82f6; /* Blue */
    
    /* Specific usage colors */
    --airing-color: #16a34a; /* Green for currently airing */
    --completed-color: #eab308; /* Yellow for completed */
    --movie-color: #333cff; /* Blue for movies */
    --series-color: #8b5cf6; /* Purple for series */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-hover: 0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.05);
    
    /* Animation durations */
    --transition-fast: 150ms;
    --transition-normal: 300ms;
    --transition-slow: 500ms;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;
    
    /* Z-index layers */
    --z-below: -1;
    --z-normal: 1;
    --z-above: 10;
    --z-modal: 100;
    --z-overlay: 1000;
    --z-highest: 9999;
}

/* حذف وضع الثيم الداكن لأنه الوضع الافتراضي الآن */
/* [data-theme="dark"] {
    --bg-primary: #0a0e17;
    --bg-secondary: #121b27;
    --bg-tertiary: #1a2436;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --border-color: rgba(255, 255, 255, 0.07);
    --card-bg: #121b27;
    --hover-bg: #1a2436;
    --header-bg: #070b13;
    --input-bg: rgba(255, 255, 255, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.5);
} */

/* حذف وضع الثيم الفاتح لأننا نستخدم الداكن فقط */
/* [data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --hover-bg: #f3f4f6;
    --header-bg: #ffffff;
    --input-bg: rgba(0, 0, 0, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.1);
} */

/* === Reset and Base Styles === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
    text-align: right;
    min-height: 100vh;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    color: var(--text-bright);
}

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-normal) ease;
}

a:hover {
    color: var(--primary-light);
}

/* ===== Adsterra Native Banner Card ===== */
.adsterra-card .anime-poster{
    background-color:#1a1a2e;
    padding-top:140%;
    position:relative;
    overflow:hidden;
}
.adsterra-card .anime-details{
    display:flex;
    align-items:center;
    justify-content:center;
    padding:1rem;
}
.adsterra-card .anime-details h2{
    margin:0;
    font-size:1rem;
    color:#f0f0f0;
}

/* === Containers and Layout === */
.container {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    background-color: var(--bg-primary);
}

.section {
    padding: var(--spacing-2xl) 0;
}

/* Two column layout */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -var(--spacing-md);
}

.col {
    flex: 1;
    padding: 0 var(--spacing-md);
    min-width: 250px;
}

/* === Header and Search === */
header {
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown var(--transition-slow) ease-out;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.search-filter-container {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    margin-top: var(--spacing-xl);
    position: relative;
    z-index: var(--z-above);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.search-form input[type="text"] {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
    transition: all var(--transition-normal) ease;
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(139,92,246,0.3);
}

.search-form button {
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.search-form button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.search-form button:active {
    transform: translateY(0);
}

.filter-groups {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-muted);
}

.filter-group select {
    width: 100%;
    padding: var(--spacing-md);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Status and Type Badges */
.status-badges,
.type-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.status-badge,
.type-badge {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-normal) ease;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.status-badge i,
.type-badge i {
    opacity: 0.7;
}

.status-badge:hover,
.type-badge:hover {
    border-color: var(--primary-color);
    background-color: rgba(139,92,246,0.1);
}

.status-badge.active,
.type-badge.active {
    border-color: var(--primary-color);
    background-color: rgba(139,92,246,0.2);
    font-weight: 600;
}

.status-badge-airing.active {
    border-color: var(--airing-color);
    background-color: rgba(22,163,74,0.2);
}

.status-badge-completed.active {
    border-color: var(--completed-color);
    background-color: rgba(234,179,8,0.2);
}

.type-badge-series.active {
    border-color: var(--series-color);
    background-color: rgba(139,92,246,0.2);
}

.type-badge-movie.active {
    border-color: var(--movie-color);
    background-color: rgba(51,60,255,0.2);
}

/* Active Filters */
.active-filters-container {
    margin: var(--spacing-md) 0;
}

.active-filters {
    background-color: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-md);
}

.active-filters-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.active-filters-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.active-filter-badge {
    background-color: var(--input-bg);
    border-radius: var(--radius-full);
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.filter-label {
    color: var(--text-muted);
    margin-left: var(--spacing-xs);
}

.filter-value {
    font-weight: 600;
}

.filter-remove {
    color: var(--text-muted);
    margin-right: var(--spacing-xs);
    transition: color var(--transition-normal) ease;
}

.filter-remove:hover {
    color: var(--error-color);
}

/* === Anime Grid === */
.anime-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 16px;
    contain: layout style; /* تحسين الأداء */
    
}

/* === Modern Anime Card Design === */
.anime-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    contain: content; /* تحسين الأداء */
    will-change: transform; /* تحسين أداء التحويل */
    opacity: 0; /* بطاقات الأنمي تبدأ مخفية */
    transform: translateY(20px); /* بداية من أسفل */
    transition: opacity 0.3s ease, transform 0.3s ease;
    
}

/* تعريف فئة show لإظهار بطاقات الأنمي */
.anime-card.show {
    opacity: 1;
    transform: translateY(0);
}

.anime-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.anime-poster {
    position: relative;
    overflow: hidden;
    aspect-ratio: 2/3;
    background-color: var(--card-bg-darker); /* لون مؤقت أثناء تحميل الصورة */
}

.anime-poster-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d; /* تحسين أداء التحويل */
}

.anime-card:hover .anime-poster-img {
    transform: scale(1.05); /* تقليل حجم التكبير */
}

.anime-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0.8;
    transition: opacity 0.2s ease;
    z-index: 1;
    pointer-events: none; /* السماح بالنقر على العناصر تحتها */
}

.anime-card:hover .anime-overlay {
    opacity: 0.95;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0.3) 100%);
}

.anime-details {
    padding: 12px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* يسمح للتذييل بالالتصاق بالأسفل */
    position: relative;
    z-index: 2; /* ليكون فوق الملصق */
    justify-content: flex-end; /* محاذاة العناصر للأسفل */
}

.anime-card .anime-details h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.3;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.25s ease;
    position: relative;
    text-align: right;
}

.anime-card:hover .anime-details h2 {
    transform: translateY(-8rem); /* تقليل مسافة الانتقال */
    white-space: normal; /* السماح بالنص بالانتقال إلى سطر جديد */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* الحد الأقصى للسطور */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anime-meta-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: opacity 0.2s ease;
    margin-bottom: 4px;
}

.anime-card:hover .anime-meta-info {
    opacity: 0;
    visibility: hidden; /* تحسين الأداء بدلاً من تغيير الارتفاع */
}

.anime-meta-info .anime-type,
.anime-meta-info .anime-rating-display {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background-color: rgba(255, 255, 255, 0.08);
}

.anime-meta-info .anime-rating-display i {
    color: #f5c518; /* لون ذهبي للنجمة */
    font-size: 0.7rem; /* تصغير حجم الأيقونة */
}

.anime-actions-hover {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 12px;
    z-index: 4; /* التأكد من أن الأزرار فوق التراكب */
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateY(10px); /* تقليل مسافة الانتقال */
    transition: opacity 0.25s ease, transform 0.25s ease;
    will-change: opacity, transform; /* تحسين أداء التحويل */
}

.anime-card:hover .anime-actions-hover {
    opacity: 1;
    transform: translateY(0);
}

/* زر المفضلة دائماً مرئي */
.btn-favorite {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: transform 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-favorite:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.btn-favorite.is-favorite {
    color: #ff4757;
    background-color: rgba(255, 71, 87, 0.3);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}

.btn-favorite.is-favorite:hover {
    background-color: rgba(255, 71, 87, 0.4);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

/* Animation for favorite button toggle */
.btn-favorite.toggling {
    animation: favoriteToggle 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* تسريع التأثير مع منحنى بيزييه أكثر كفاءة */
}

@keyframes favoriteToggle {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); } /* تقليل حجم التكبير */
    100% { transform: scale(1); }
}

/* Heart icon styling */
.btn-favorite i {
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.btn-favorite:hover i {
    transform: scale(1.1);
}

.btn-favorite.is-favorite i {
    color: #ff4757;
    text-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

/* Loading state for favorite button */
.btn-favorite:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-favorite:disabled i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-watch-now {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.btn-watch-now:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.3);
}

.btn-watch-now i {
    font-size: 1rem;
}

.anime-secondary-actions {
    display: flex;
    gap: 8px;
}

.btn-secondary {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-secondary-action {
    flex-grow: 1;
    padding: 8px;
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    color: #f0f0f0;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-secondary-action:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.secondary-actions-container {
    display: flex;
    gap: 10px;
}

/* شارات على الملصق */
.poster-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.favorite-badge, .anime-episode-badge {
    position: absolute;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.65rem;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.favorite-badge {
    top: 8px;
    background-color: rgba(255, 82, 82, 0.85);
    animation: fadeIn 0.3s ease-out;
}

.anime-episode-badge {
    top: 36px;
}

.anime-episode-badge.completed {
    background-color: rgba(76, 175, 80, 0.85);
}

.anime-episode-badge.airing {
    background-color: rgba(33, 150, 243, 0.85);
}

/* Style only the episode number inside airing badge */
.anime-episode-badge .episode-number {
    color: var(--secondary-color);
    font-weight: 700;
}

/* النقطة الخضراء المتحركة للأنميات التي تعرض الآن */
.airing-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--airing-color);
    margin-right: 4px;
    margin-left: 4px;
    position: relative;
    top: -1px;
    animation: pulse 2.5s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
    will-change: transform, box-shadow; /* تحسين أداء التحويل */
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5);
    }
    70% {
        opacity: 0.7;
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(22, 163, 74, 0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
    }
}


/* Show elements that were previously hidden */
.anime-card .anime-category,
.anime-card .anime-episodes,
.anime-card .anime-type,
.anime-card .anime-status,
.anime-card .anime-rating,
.anime-card .anime-reting-badge,
.anime-card .anime-actions {
    display: block; /* Show these elements */
}

/* تعديلات الاستجابة للشاشات المختلفة */
@media (max-width: 768px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding: 10px 0;
    }
    
    .anime-details {
        padding: 8px;
    }
    
    .anime-details h2 {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .anime-meta-info {
        font-size: 0.7rem;
    }
    
    .btn-favorite {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
    
    .anime-actions-hover {
        padding: 10px 8px;
        gap: 6px;
    }
    
    .btn-watch-now {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* تحسينات إضافية للأجهزة الصغيرة جداً */
@media (max-width: 480px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
}

@media (max-width: 480px) {
    .anime-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    .anime-card .anime-details h2 {
        font-size: 1rem;
    }
}

/* === Notifications === */
.notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: var(--text-primary);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 10px var(--shadow-color);
    z-index: var(--z-overlay);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: top var(--transition-normal) ease;
}

.notification.show {
    top: 20px;
    animation: slideInDown var(--transition-normal) ease, fadeOut 0.5s ease 2.5s forwards;
}

/* === Animations === */
/* تحسين رسوم متحركة لعرض بطاقات الأنمي */
@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px); /* تقليل مسافة الانتقال */
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* رسوم متحركة لعرض بطاقات الأنمي */
.anime-card {
    opacity: 1;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform; /* تحسين أداء التحويل */
}

.anime-card.show {
    opacity: 1;
    transform: translateY(0);
}

@keyframes fadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    0% {
        top: -100px;
    }
    100% {
        top: 20px;
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* === Responsive Design === */
@media (max-width: 1200px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 992px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: var(--spacing-md);
    }
   
    
    .anime-details h2 {
        font-size: 0.9rem;
    }
    
    .anime-details p {
        font-size: 0.75rem;
    }
    
    .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .view-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 576px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--spacing-sm);
    }
    
    .anime-details {
        padding: var(--spacing-sm);
    }
    
    .anime-actions {
        flex-direction: column;
    }
    
    .anime-grid.list-view .anime-card {
        height: 120px;
    }
    
    .anime-grid.list-view .anime-poster {
        width: 80px;
        min-width: 80px;
        height: 120px;
    }
    
    .anime-grid.list-view .anime-details p {
        width: 100%;
    }
}

/* === Utility Classes === */
.text-center {
    text-align: center;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.hidden {
    display: none !important;
}

/* === Loading Effects === */
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--card-hover) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* === Dark Mode Override (Default) === */
/* These styles are already set for dark mode as the default */

/* === Fancy Effects === */
.hover-scale {
    transition: transform var(--transition-normal) ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-brightness {
    transition: filter var(--transition-normal) ease;
}

.hover-brightness:hover {
    filter: brightness(1.2);
}

/* === Custom scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-color);
}

/* === Prevent text selection for UI elements === */
.no-select {
    user-select: none;
}

/* === Notifications === */
.notification {
    background-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 4px 10px var(--shadow-color);
}

/* === SweetAlert adjustments === */
.swal2-popup {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.swal2-title {
    color: var(--text-primary);
}

.swal2-content {
    color: var(--text-secondary);
}

.swal2-input, 
.swal2-textarea {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* === زر العودة للأعلى === */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: rgba(139, 92, 246, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    visibility: hidden;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px var(--shadow-color);
    background-color: rgba(139, 92, 246, 0.7);
}

.back-to-top i {
    font-size: 20px;
    transition: transform 0.3s ease;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

.back-to-top:hover i {
    transform: translateY(-3px);
}

/* للأجهزة اللوحية متوسطة الحجم */
@media (min-width: 768px) and (max-width: 991px) {
    .back-to-top {
        bottom: 25px;
        right: 25px;
        width: 60px;
        height: 60px;
        border-radius: 20px;
        background: rgba(139, 92, 246, 0.15);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 20px rgba(139, 92, 246, 0.15);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
    
    .back-to-top i {
        font-size: 24px;
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6));
    }
    
    .back-to-top:hover {
        transform: translateY(-10px) scale(1.02);
        background: rgba(139, 92, 246, 0.25);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2), 0 0 30px rgba(139, 92, 246, 0.25);
    }
    
    .back-to-top:hover i {
        transform: translateY(-5px) scale(1.1);
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
    }
}

/* تحسين لشاشات الحواسيب */
@media (min-width: 992px) {
    .back-to-top {
        bottom: 30px;
        right: 30px;
        width: 70px;
        height: 70px;
        border-radius: 24px;
        background: rgba(139, 92, 246, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 0 20px rgba(139, 92, 246, 0.1);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transform-style: preserve-3d;
        perspective: 800px;
    }
    
    .back-to-top::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 24px;
        padding: 2px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.2), rgba(255, 255, 255, 0.2));
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        opacity: 0.5;
        transition: opacity 0.4s ease;
    }
    
    .back-to-top:hover::before {
        opacity: 1;
    }
    
    .back-to-top:hover {
        transform: translateY(-10px) scale(1.05) rotateX(10deg);
        box-shadow: 
            0 20px 50px rgba(0, 0, 0, 0.2), 
            0 0 30px rgba(139, 92, 246, 0.2),
            0 -5px 15px rgba(255, 255, 255, 0.1);
        background: rgba(139, 92, 246, 0.15);
    }
    
    .back-to-top i {
        font-size: 28px;
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
        transform: translateZ(20px);
        transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .back-to-top:hover i {
        transform: translateZ(30px) translateY(-8px) scale(1.2);
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 1));
        animation: floatArrow 2s infinite alternate;
    }
    
    @keyframes floatArrow {
        0% {
            transform: translateZ(30px) translateY(-3px);
            filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
        }
        100% {
            transform: translateZ(40px) translateY(-12px);
            filter: drop-shadow(0 0 25px rgba(255, 255, 255, 1));
        }
    }
}

/* تعديلات للشاشات الصغيرة جدًا */
@media (max-width: 576px) {
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        background-color: rgba(139, 92, 246, 0.5);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }
    
    .back-to-top i {
        font-size: 18px;
    }
}

/* إخفاء زر عرض القائمة في الشاشات الأكبر من 500px */
@media (min-width: 501px) {
    .view-toggle-btn-modern {
        display: none !important;
    }
}

/* تصميم جديد ومبتكر لعناصر التحكم في العرض */
.view-controls-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1.5rem 0;
    background: rgba(26, 36, 54, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 0.8rem 1.2rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.3s ease;
}

.results-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.results-count strong {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 0.2rem;
    margin-left: 0.2rem;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

/* تصميم منسدل الترتيب */
.sort-dropdown-modern {
    position: relative;
}

.sort-select-modern {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.5rem 2.2rem 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23b0b0b0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 10px;
    text-align: right;
}

.sort-select-modern:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.sort-select-modern:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* تصميم مبتكر لأزرار تبديل العرض */
.view-toggle-modern {
    display: flex;
    border-radius: 12px;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    height: 35px;
}

.view-toggle-btn-modern {
    width: 40px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: color 0.3s ease;
}

/* مؤشر الحالة النشطة المتحرك */
.view-toggle-modern::after {
    content: '';
    position: absolute;
    width: 40px;
    height: calc(100% - 6px);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.7), rgba(124, 58, 237, 0.7));
    top: 3px;
    right: 3px;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.view-toggle-modern.list-active::after {
    transform: translateX(-40px);
}

.view-toggle-btn-modern.active {
    color: white;
}

.view-toggle-btn-modern i {
    font-size: 1.2rem;
}

/* تأثير نبض عند النقر */
.view-toggle-btn-modern.pulse-effect i {
    animation: pulse-scale 0.5s ease-out;
}

@keyframes pulse-scale {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* تأثير انتقال للشبكة */
#anime-grid.transitioning {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0.8;
    transform: scale(0.98);
}

#anime-grid {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: scale(1);
}

/* تأثير تحول حجم الشبكة بين الأوضاع */
#anime-grid.list-view {
    animation: switch-to-list 0.4s ease forwards;
}

#anime-grid:not(.list-view) {
    animation: switch-to-grid 0.4s ease forwards;
}

@keyframes switch-to-list {
    0% { 
        opacity: 0.8;
        transform: scale(0.98);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes switch-to-grid {
    0% { 
        opacity: 0.8;
        transform: scale(0.98);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}

/* تجاوب مع الشاشات المختلفة */
@media (max-width: 768px) {
    .view-controls-modern {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
    }
    
    .sort-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .sort-select-modern {
        max-width: 160px;
    }
}

/* شاشات صغيرة جداً */
@media (max-width: 500px) {
    .view-controls-modern {
        border-radius: 12px;
        padding: 0.8rem;
        margin: 1rem 0;
    }
    
    .results-count {
        font-size: 0.75rem;
    }
    
    .sort-select-modern {
        font-size: 0.75rem;
        padding: 0.4rem 2rem 0.4rem 0.8rem;
        max-width: 140px;
    }
}

/* ===== أنماط التقييم ===== */
.rating-updated {
    animation: pulse 0.7s ease-in-out;
}

.badge-updated {
    animation: flash 0.7s ease-in-out;
}

.user-rating {
    display: inline-block;
    margin-right: 10px;
    padding: 0 8px;
    background-color: rgba(124, 58, 237, 0.1);
    border-radius: 4px;
    font-size: 0.85em;
    border-right: 2px solid #7c3aed;
}

.user-rating strong {
    color: #7c3aed;
    font-weight: 700;
}

.user-rating-updated {
    animation: highlight 0.7s ease-in-out;
}

/* وصف التقييم */
.rating-text-description {
    display: inline-block;
    margin-right: 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    padding: 2px 8px;
    transition: all 0.3s ease;
}

/* ألوان مختلفة لمستويات التقييم */
.rating-excellent {
    background-color: rgba(0, 200, 83, 0.1);
    color: #00c853;
    border-right: 2px solid #00c853;
}

.rating-good {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    border-right: 2px solid #ffc107;
}

.rating-average {
    background-color: rgba(255, 152, 0, 0.1);
    color: #ff9800;
    border-right: 2px solid #ff9800;
}

.rating-poor {
    background-color: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border-right: 2px solid #f44336;
}

/* Rating Dialog Styles */
.rating-popup {
    direction: rtl;
    font-family: 'Cairo', sans-serif;
    background: rgba(31, 31, 31, 0.95);
    color: #f8fafc;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rating-popup .swal2-title {
    color: white;
    font-size: 1.5rem;
}

.rating-stars {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.stars-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.stars-container i {
    font-size: 1.8rem;
    color: #ffc107;
}

.rating-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #7c3aed;
    margin-top: 10px;
}

.rating-tips {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: 10px;
    text-align: center;
}

.rating-description {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 15px;
    text-align: center;
    color: #ffc107;
}

input[type="range"].swal2-range {
    height: 10px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: all 0.3s;
}

input[type="range"].swal2-range::-webkit-slider-thumb {
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #7c3aed;
    cursor: pointer;
    transition: all 0.3s;
}

input[type="range"].swal2-range::-webkit-slider-thumb:hover {
    background: #6d28d9;
    transform: scale(1.1);
}

.rating-confirm-btn {
    background-color: #7c3aed !important;
    border-radius: 0.5rem !important;
}

.rating-cancel-btn {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc !important;
    border-radius: 0.5rem !important;
}

/* Rating Success Animation */
.rating-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
}

.rating-value-large {
    font-size: 3rem;
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 10px;
}

.rating-stars-large {
    font-size: 1.5rem;
    color: #ffc107;
    margin-bottom: 15px;
}

.btn-rate.rated {
    background-color: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.btn-rate.rated:hover {
    background-color: #7c3aed;
    color: white;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #7c3aed; }
    100% { transform: scale(1); }
}

@keyframes flash {
    0% { background-color: rgba(124, 58, 237, 0.2); }
    50% { background-color: rgba(124, 58, 237, 0.5); }
    100% { background-color: rgba(124, 58, 237, 0.2); }
}

@keyframes highlight {
    0% { background-color: rgba(124, 58, 237, 0.1); }
    50% { background-color: rgba(124, 58, 237, 0.3); }
    100% { background-color: rgba(124, 58, 237, 0.1); }
}

/* === Media query for extra small screens (under 320px) === */
@media (max-width: 320px) {
    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--spacing-xs);
    }
    
    .container {
        padding: 0 5px;
    }
    
    .anime-details h2 {
        font-size: 0.95rem;
        line-height: 1.2;
        margin-bottom: 5px;
    }
    
    .anime-details p {
        font-size: 0.8rem;
        margin-bottom: 5px;
    }
    
    .anime-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .anime-episode-badge {
        font-size: 0.7rem;
        padding: 2px 5px;
        right: 15px;
    }
    
    .anime-reting-badge {
        font-size: 0.75rem;
        width: 40px;
        height: 40px;
    }
    
    .anime-category {
        font-size: 0.75rem;
    }
    
    .anime-grid.list-view .anime-card {
        height: auto;
        flex-direction: column;
    }
    
    .anime-grid.list-view .anime-poster {
        width: 100%;
        height: 140px;
    }
    
    .watch-button {
        transform: scale(0.8);
    }
    
    .favorite-badge {
        width: 25px;
        height: 25px;
        top: 5px;
        right: 5px;
    }
    
    .favorite-badge i {
        font-size: 0.8rem;
    }
}

main {
    padding: 20px 0;
}

/* Responsive design for favorite buttons */
@media (max-width: 768px) {
    .btn-favorite {
        width: 32px;
        height: 32px;
        top: 8px;
        right: 8px;
    }
    
    .btn-favorite i {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .btn-favorite {
        width: 30px;
        height: 30px;
        top: 6px;
        right: 6px;
    }
    
    .btn-favorite i {
        font-size: 0.8rem;
    }
}



