:root {
    /* Light Mode Colors */
    --background-gradient: linear-gradient(to right, #fef9f9, rgb(180, 224, 241));
    --text-color: #333;
    --header-bg: linear-gradient(90deg, #00a8cc, #d8f4ff);
    --header-text: #ffffff;
    --hero-bg: linear-gradient(135deg, rgba(0, 169, 204, 0.5), rgba(0, 201, 167, 0.4)), var(--hero-bg-image) no-repeat center center/cover;
    --hero-text: #ffffff;
    --hero-text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.4);
    --card-bg: linear-gradient(145deg, #fdfcfe, #d8f4ff);
    --card-text: #00a8cc;
    --card-secondary-text: #444;
    --btn-bg: linear-gradient(90deg, #00c9a7, #12d3cf);
    --btn-bg-hover: linear-gradient(90deg, #00b49c, #0ec7c3);
    --btn-shadow: 0 6px 15px rgba(0, 201, 167, 0.5);
    --search-input-border: #d4af37;
    --search-btn-bg: linear-gradient(90deg, #00c9a7, #12d3cf);
    --search-btn-bg-hover: linear-gradient(90deg, #00b49c, #0ec7c3);
    --footer-bg: linear-gradient(145deg, #fdfcfe, #d8f4ff);
    --footer-text: #333;
}

/* Dark Mode Colors */
body.dark-mode {
    --background-gradient: linear-gradient(to right, #1a1a1a, #2c3e50);
    --text-color: #e0e0e0;
    --header-bg: linear-gradient(90deg, #2c3e50, #34495e);
    --header-text: #e0e0e0;
    --hero-bg: linear-gradient(135deg, rgba(44, 62, 80, 0.5), rgba(52, 73, 94, 0.4)), var(--hero-bg-image) no-repeat center center/cover;
    --hero-text: #e0e0e0;
    --hero-text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.6);
    --card-bg: linear-gradient(145deg, #2c2c2c, #3a3a3a);
    --card-text: #3498db;
    --card-secondary-text: #b0b0b0;
    --btn-bg: linear-gradient(90deg, #3498db, #2980b9);
    --btn-bg-hover: linear-gradient(90deg, #2980b9, #1f618d);
    --search-btn-bg: linear-gradient(90deg, #3498db, #2980b9);
    --search-btn-bg-hover: linear-gradient(90deg, #2980b9, #1f618d);
    --footer-bg: linear-gradient(145deg, #2c2c2c, #3a3a3a);
    --footer-text: #e0e0e0;
    --search-input-border: #555;
}

body {
    margin: 0;
    font-family: 'Cairo', sans-serif;
    background: var(--background-gradient);
    color: var(--text-color);
    transition: background 0.3s ease, color 0.3s ease;
}

html[dir="rtl"] body {
    text-align: right;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--header-bg);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.8s ease-out forwards;
}

@keyframes slideDown {
    0% { transform: translateY(-100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.header a {
    color: var(--header-text);
    text-decoration: none;
    margin: 0 15px;
    font-size: 18px;
    font-weight: 500;
    position: relative;
    transition: color 0.3s ease;
}

.header a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background-color: var(--header-text);
    left: 0;
    bottom: -5px;
    transition: width 0.3s ease;
}

html[dir="rtl"] .header a::after {
    left: unset;
    right: 0;
}

.header a:hover::after { width: 100%; }
.header a:hover { color: #f0f8ff; }

.logo {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
    transition: transform 0.3s ease;
}

.logo:hover { transform: scale(1.05); }

.menu {
    display: flex;
    align-items: center;
}

html[dir="rtl"] .menu {
    flex-direction: row-reverse;
}

.coins-display {
    margin-left: 10px;
    font-weight: bold;
    color: var(--header-text);
    background: var(--header-bg);
    padding: 5px 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

html[dir="rtl"] .coins-display {
    margin-left: 0;
    margin-right: 10px;
}

.coins-icon {
    font-size: 16px;
    color: #ffd700;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark Mode Toggle */
.dark-mode-toggle, .language-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0 10px;
}

.dark-mode-toggle i, .language-toggle i {
    font-size: 20px;
    color: var(--header-text);
    transition: color 0.3s ease;
}

.hamburger {
    display: none;
    font-size: 24px;
    background: none;
    border: none;
    color: var(--header-text);
    cursor: pointer;
    z-index: 101; /* Ensure hamburger is above menu */
}

@media (max-width: 768px) {
    .menu {
        display: none;
        flex-direction: column;
        position: fixed; /* Changed from absolute to fixed for better mobile behavior */
        top: 60px;
        left: 0;
        width: 100%;
        background: var(--header-bg);
        padding: 20px 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100; /* Ensure menu is below hamburger but above content */
    }

    .menu.active {
        display: flex; /* Ensure menu is displayed when active */
    }

    html[dir="rtl"] .menu {
        flex-direction: column;
        left: unset;
        right: 0;
    }

    .menu a, .menu .dark-mode-toggle, .menu .language-toggle, .menu .coins-display {
        margin: 10px 0;
        font-size: 20px;
        justify-content: center;
        width: 100%;
        text-align: center;
    }

    .hamburger {
        display: block;
    }
}

/* Hero Section */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
    background: var(--hero-bg);
    color: var(--hero-text);
    text-align: center;
    padding: 0 20px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    animation: pulse 6s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 0.3; }
    100% { transform: scale(1); opacity: 0.7; }
}

.hero h1 {
    font-size: 64px;
    font-weight: 700;
    margin: 0;
    text-shadow: var(--hero-text-shadow);
    animation: slideInFromTop 1s ease-out forwards;
    letter-spacing: 2px;
}

.hero p {
    font-size: 28px;
    font-weight: 400;
    margin: 20px 0 30px;
    max-width: 800px;
    line-height: 1.6;
    text-shadow: var(--hero-text-shadow);
    animation: fadeIn 1.2s ease-out 0.3s forwards;
    opacity: 0;
}

.btn {
    background: var(--btn-bg);
    color: white;
    padding: 14px 40px;
    text-decoration: none;
    font-size: 20px;
    font-weight: 600;
    border-radius: 50px;
    box-shadow: var(--btn-shadow);
    transition: all 0.4s ease;
    animation: bounceIn 1s ease-out 0.6s forwards;
    opacity: 0;
}

.btn:hover {
    background: var(--btn-bg-hover);
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 201, 167, 0.7);
}

/* Cards Container */
.cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Hero Card Styling */
.hero-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--card-bg);
    color: var(--card-text);
    text-align: center;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    flex: 1 1 calc(33.33% - 20px);
    box-sizing: border-box;
    min-width: 280px;
    max-width: 360px;
    height: 500px;
}

.hero-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.hero-card h1 {
    color: var(--card-text);
    font-size: 28px;
    margin: 10px 0;
}

.hero-card p {
    font-size: 16px;
    color: var(--card-secondary-text);
    line-height: 1.5;
    margin: 0 0 15px;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.hero-card img:hover {
    transform: scale(1.05);
}

.hero-card .btn {
    background: var(--btn-bg);
    padding: 10px 25px;
    border-radius: 50px;
    font-size: 16px;
    box-shadow: var(--btn-shadow);
}

.hero-card .btn:hover {
    background: var(--btn-bg-hover);
    transform: scale(1.1);
}

/* Animations */
@keyframes slideInFromTop {
    0% { transform: translateY(-50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 900px) {
    .hero-card { flex: 1 1 calc(50% - 20px); }
    .hero h1 { font-size: 48px; }
    .hero p { font-size: 22px; }
}

@media (max-width: 600px) {
    .hero-card { flex: 1 1 100%; }
    .hero { height: 60vh; }
    .hero h1 { font-size: 36px; }
    .hero p { font-size: 18px; }
    .btn { padding: 12px 30px; font-size: 18px; }
}

/* Footer */
.footer {
    background: var(--footer-bg);
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    color: var(--footer-text);
    position: relative;
    bottom: 0;
    width: 100%;
}

/* Search Form */
.search-form {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.search-form input {
    padding: 10px;
    width: 300px;
    border: 1px solid var(--search-input-border);
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.search-form input:focus {
    outline: none;
    border-color: #00a8cc;
}

.search-form button {
    background: var(--search-btn-bg);
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-form button:hover {
    background: var(--search-btn-bg-hover);
    transform: scale(1.05);
}
