
/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 */

/* --- ROOT & THEME VARIABLES --- */
:root {
    /* Default Dark Theme */
    --bg-color: #121212;
    --bg-color-light: #1e1e1e;
    --surface-color: #2c2c2c;
    --primary-color: #bb86fc;
    --primary-variant-color: #3700b3;
    --secondary-color: #03dac6;
    --text-color: #ffffff;
    --text-muted-color: #a0a0a0;
    --border-color: #444444;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --chat-bg: #252525;
    --chat-bubble-bg: #3a3a3a;
    --chat-bubble-me-bg: var(--primary-gradient);
    --input-bg: #333;
    
    /* Layout Radius Variable (Default) */
    --main-radius: 12px;
    
    /* Custom Cursors */
    --cursor-crosshair-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M16 3v10m0 6v10M3 16h10m6 0h10" stroke-width="3" stroke="black" fill="none"/><path d="M16 3v10m0 6v10M3 16h10m6 0h10" stroke-width="1.5" stroke="white" fill="none"/></svg>');
    --cursor-magic-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><g transform="rotate(45 16 16)"><path stroke="black" stroke-width="1.5" fill="white" d="M14 4h4v18h-4z"/><path stroke="black" stroke-width="1.5" fill="yellow" d="M16 4l-4-4 4-4 4 4z"/></g></svg>');
    --cursor-bow-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path stroke="white" stroke-width="2.5" fill="none" d="M29 3 C 10 16, 10 16, 29 29 M16 16 H3"/></svg>');
}

body.theme-light {
    --bg-color: #f5f5f5;
    --bg-color-light: #ffffff;
    --surface-color: #ffffff;
    --primary-color: #6200ee;
    --primary-variant-color: #3700b3;
    --secondary-color: #03dac6;
    --text-color: #212121;
    --text-muted-color: #757575;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --chat-bg: #f9f9f9;
    --chat-bubble-bg: #eeeeee;
    --input-bg: #fff;
}

body.theme-midnight-blue {
    --bg-color: #0f172a;
    --bg-color-light: #1e293b;
    --surface-color: #1e293b;
    --primary-color: #38bdf8;
    --text-color: #e2e8f0;
    --text-muted-color: #94a3b8;
    --border-color: #334155;
    --primary-gradient: linear-gradient(135deg, #0ea5e9, #6366f1);
}

body.theme-royal-purple {
    --bg-color: #2c1f43;
    --bg-color-light: #3e2c5f;
    --surface-color: #3e2c5f;
    --primary-color: #c084fc;
    --text-color: #f3e8ff;
    --text-muted-color: #d8b4fe;
    --border-color: #581c87;
    --primary-gradient: linear-gradient(135deg, #a855f7, #e879f9);
}

body.theme-emerald-green {
    --bg-color: #064e3b;
    --bg-color-light: #047857;
    --surface-color: #047857;
    --primary-color: #6ee7b7;
    --text-color: #ecfdf5;
    --text-muted-color: #a7f3d0;
    --border-color: #022c22;
    --primary-gradient: linear-gradient(135deg, #10b981, #34d399);
}

body.theme-sunset-orange {
    --bg-color: #451a03;
    --bg-color-light: #7c2d12;
    --surface-color: #7c2d12;
    --primary-color: #fb923c;
    --text-color: #fff7ed;
    --text-muted-color: #fdba74;
    --border-color: #451a03;
    --primary-gradient: linear-gradient(135deg, #f97316, #ea580c);
}

body.theme-dreamy-pink {
    --bg-color: #5b21b6;
    --bg-color-light: #7e22ce;
    --surface-color: #7e22ce;
    --primary-color: #f9a8d4;
    --text-color: #f5d0fe;
    --text-muted-color: #e9d5ff;
    --border-color: #4c1d95;
    --primary-gradient: linear-gradient(135deg, #d946ef, #ec4899);
}

body.theme-sky-blue {
    --bg-color: #f0f9ff;
    --bg-color-light: #ffffff;
    --surface-color: #ffffff;
    --primary-color: #0ea5e9;
    --text-color: #0c4a6e;
    --text-muted-color: #38bdf8;
    --border-color: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #38bdf8, #0ea5e9);
}

body.theme-luxury-gold {
    --bg-color: #1c1917;
    --bg-color-light: #292524;
    --surface-color: #292524;
    --primary-color: #fde047;
    --text-color: #fafaf9;
    --text-muted-color: #d6d3d1;
    --border-color: #44403c;
    --primary-gradient: linear-gradient(135deg, #facc15, #eab308);
}

body.theme-neon-electric {
    --bg-color: #000000;
    --bg-color-light: #1a1a1a;
    --surface-color: #1a1a1a;
    --primary-color: #00ffc8;
    --text-color: #ffffff;
    --text-muted-color: #b3b3b3;
    --border-color: #333333;
    --primary-gradient: linear-gradient(135deg, #ff00ea, #00ffc8);
}

body.theme-dark-cherry {
    --bg-color: #2a0000;
    --bg-color-light: #4b0000;
    --surface-color: #4b0000;
    --primary-color: #ff8c8c;
    --text-color: #ffe5e5;
    --text-muted-color: #ffbaba;
    --border-color: #6a0000;
    --primary-gradient: linear-gradient(135deg, #d32f2f, #ff6b6b);
}


/* --- GENERAL STYLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.5s ease, color 0.5s ease;
    overflow-x: hidden;
}

/* Custom Cursor Application - Force Override */
body.cursor-crosshair, body.cursor-crosshair * { cursor: var(--cursor-crosshair-url) 16 16, crosshair !important; }
body.cursor-magic, body.cursor-magic * { cursor: var(--cursor-magic-url) 4 4, pointer !important; }
body.cursor-bow, body.cursor-bow * { cursor: var(--cursor-bow-url) 10 10, pointer !important; }


body.game-open {
    overflow: hidden;
}


/* --- UI STYLES (Layout & Appearance) --- */

/* 1. GLASSMORPHISM (Corrected) */
body.style-glass {
    --bg-color: #0f172a;
    /* Adding a gradient background to Body so blur has something to show */
    background-image: 
        radial-gradient(at 0% 0%, rgba(74, 32, 138, 0.35) 0px, transparent 50%), 
        radial-gradient(at 100% 0%, rgba(22, 163, 74, 0.35) 0px, transparent 50%), 
        radial-gradient(at 100% 100%, rgba(192, 38, 211, 0.35) 0px, transparent 50%), 
        radial-gradient(at 0% 100%, rgba(14, 165, 233, 0.35) 0px, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
    
    --surface-color: rgba(255, 255, 255, 0.05); /* Very transparent */
    --bg-color-light: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* Apply Glass Effect to individual components ONLY */
body.style-glass .game-card,
body.style-glass .header,
body.style-glass .site-footer,
body.style-glass .modal-content,
body.style-glass .session-indicator {
    background: rgba(30, 41, 59, 0.4); /* Semi-transparent dark blue */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Specific styling for Chat Sidebar in Glass Mode to prevent overlay issues */
body.style-glass .chat-sidebar {
    background: rgba(15, 23, 42, 0.85) !important; /* Higher opacity for readability */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* 2. RETRO / PIXEL */
body.style-retro {
    --main-radius: 0px;
    --shadow-color: rgba(0,0,0,1);
}
body.style-retro .game-card,
body.style-retro .btn,
body.style-retro .modal-content,
body.style-retro .header,
body.style-retro .player-logo,
body.style-retro .chat-badge,
body.style-retro .session-indicator,
body.style-retro input,
body.style-retro select {
    border-radius: 0 !important;
}
body.style-retro .btn,
body.style-retro .game-card {
    border: 2px solid var(--text-color);
    box-shadow: 4px 4px 0px var(--text-color);
    transition: transform 0.1s;
}
body.style-retro .btn:hover,
body.style-retro .game-card:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--text-color);
}
body.style-retro .header,
body.style-retro .site-footer {
    border-bottom: 2px solid var(--text-color);
    border-top: 2px solid var(--text-color);
}

/* 3. MINIMALIST */
body.style-minimal {
    --shadow-color: transparent;
    --border-color: rgba(255,255,255,0.2);
    --primary-gradient: var(--primary-color); /* Solid color instead of gradient */
}
body.style-minimal .game-card,
body.style-minimal .btn,
body.style-minimal .header {
    box-shadow: none !important;
    border: 1px solid var(--border-color);
}
body.style-minimal .btn {
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
}
body.style-minimal .btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
}


/* --- FONT FAMILIES --- */
body.font-tajawal { font-family: 'Tajawal', sans-serif !important; }
body.font-cairo { font-family: 'Cairo', sans-serif !important; }
body.font-almarai { font-family: 'Almarai', sans-serif !important; }
body.font-changa { font-family: 'Changa', sans-serif !important; }
body.font-system { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif !important; }


/* --- ANIMATION & FONT SIZES --- */
body.animation-slow * { transition-duration: 0.8s !important; }
body.animation-normal * { transition-duration: 0.4s !important; }
body.animation-fast * { transition-duration: 0.2s !important; }
body.animation-none * { transition: none !important; }

body.font-small { font-size: 13px; }
body.font-medium { font-size: 15px; }
body.font-large { font-size: 17px; }
body.font-xlarge { font-size: 19px; }


/* --- PAGE LOADER & NOTICES --- */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-loader-bar {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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


.session-notice {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-gradient);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-color);
    z-index: 9999;
    font-size: 14px;
    animation: slideInDown 0.5s ease;
}

@keyframes slideInDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Session Expired Modal (Full Screen Center) - Responsive Update */
.session-expired-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(240, 147, 251, 0.4);
    z-index: 10000;
    text-align: center;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 18px;
    line-height: 1.6;
    white-space: pre-line;
    animation: slideInUp 0.5s ease;
    
    /* Width Logic: 50% on Desktop */
    width: 50%;
}

/* New Network Offline Modal */
.network-offline-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800; /* Warning Orange */
    color: white;
    padding: 52px 25px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 10001;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 700;
    font-size: 14px;
    animation: slideDownFade 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
    min-width: 280px;
}

.network-offline-modal.show {
    display: flex;
}

.network-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes slideDownFade {
    from { transform: translate(-50%, -20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}


@media (max-width: 768px) {
    .session-expired-modal {
        /* Width Logic: 90% on Mobile */
        width: 90%;
        padding: 20px;
        font-size: 16px;
    }
    .network-offline-modal {
        width: 90%;
        font-size: 13px;
    }
}


/* Session Indicator */
.session-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-color);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted-color);
    box-shadow: 0 2px 10px var(--shadow-color);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.session-indicator.warning .pulse-dot {
    background: #ff9800;
}

.session-indicator.error .pulse-dot {
    background: #f44336;
    animation: none;
}


/* --- HEADER --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--bg-color-light);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.player-info h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

.player-info p {
    font-size: 0.8rem;
    color: var(--text-muted-color);
    margin: 0;
}

.header-right {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.btn .btn-text {
    margin-right: 4px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.btn-chat {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.chat-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background-color: var(--primary-color);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-color-light);
}

.btn-notifications {
    background-color: transparent;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
}

.notification-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background-color: #ff4d4d;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-color-light);
}

.btn-settings {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.btn-logout {
    background: var(--primary-gradient);
    color: white;
}


/* --- MAIN CONTAINER & GAME GRID --- */
.container {
    padding: 30px;
    padding-bottom: 100px; /* Space for the new footer */
}

.games-grid {
    display: grid;
    gap: 25px;
}

.games-grid.single { grid-template-columns: repeat(1, 1fr); }
.games-grid.grid-2 { grid-template-columns: repeat(2, 1fr); }
.games-grid.grid-3 { grid-template-columns: repeat(3, 1fr); }
.games-grid.grid-4 { grid-template-columns: repeat(4, 1fr); }
.games-grid.grid-5 { grid-template-columns: repeat(5, 1fr); }
.games-grid.grid-6 { grid-template-columns: repeat(6, 1fr); }

.game-card {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 6 / 3;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game-card:hover {
    transform: scale(1.05);
}

.game-card-image {
    width: 100%;
    height: 100%;
}

.game-card-image img {
    width: 100%;
    height: 100%;
/*    object-fit: cover;*/
    transition: transform 0.4s ease;
}

.game-card:hover .game-card-image img {
    transform: scale(1.1);
}

.game-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card:hover .game-card-overlay {
    opacity: 1;
}

.play-icon {
    font-size: 3rem;
    color: white;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.game-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    text-align: center;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    transition: opacity 0.3s ease;
}

.games-grid.hide-names .game-card-content {
    opacity: 0;
}
.game-card:hover .game-card-content {
    opacity: 1;
}

.game-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-shadow: 1px 1px 3px #000;
}

.game-card.modern { border-radius: var(--main-radius); }
.game-card.classic { border: 4px solid var(--border-color); border-radius: 0; }
.game-card.flat { border-radius: 0; }
.game-card.3d {
    border-radius: var(--main-radius);
    box-shadow: 0 10px 20px var(--shadow-color);
}
.game-card.neon {
    border-radius: var(--main-radius);
    box-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
}

/* --- BETA GAME STYLES --- */
.game-card.beta {
    box-shadow: 0 0 0 3px #ff9800;
}

/* Ribbon Style for Beta */
.game-card.beta::before {
    content: 'تجريبي';
    position: absolute;
    top: 20px;
    left: -32px;
    transform: rotate(-45deg);
    background: linear-gradient(135deg, #ff9800, #ff5722);
    color: white;
    padding: 5px 35px;
    font-size: 0.75rem;
    font-weight: 800;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 120px;
    text-align: center;
}

/* --- PRO VERSION STYLES --- */
.game-card.pro-version {
    box-shadow: 0 0 0 3px gold, 0 5px 20px rgba(255, 215, 0, 0.4);
    border: 2px solid gold;
}

/* Ribbon Style for Pro */
.game-card.pro-version::before {
    content: 'PRO';
    position: absolute;
    top: 20px;
    left: -32px;
    transform: rotate(-45deg);
    background: linear-gradient(135deg, #ffd700, #f0c000);
    color: #333;
    padding: 5px 35px;
    font-size: 0.75rem;
    font-weight: 900;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 120px;
    text-align: center;
}

/* --- NEW FOOTER DESIGN --- */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-color-light);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    z-index: 999;
    padding: 10px 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copyright-text {
    font-size: 0.8rem;
    color: var(--text-muted-color);
}

.btn-purchase {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-color), 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


/* Responsive */
@media (max-width: 1200px) {
    .games-grid.grid-5, 
    .games-grid.grid-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .games-grid.grid-4,
    .games-grid.grid-5, 
    .games-grid.grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: row;
        gap: 10px;
        padding: 10px 15px;
    }
    .header-left {
        width: auto;
        flex-grow: 1;
        flex-shrink: 1;
        min-width: 0;
    }
    .header-right {
        width: auto;
        flex-shrink: 0;
    }
    .player-logo {
        width: 40px;
        height: 40px;
    }
    .player-info h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
    .player-info p {
        display: none;
    }
    .header-right .btn {
        padding: 0;
        width: 40px;
        height: 40px;
        justify-content: center;
        font-size: 1.2rem;
    }
    .header-right .btn .btn-text {
        display: none;
    }
    .chat-badge, .notification-badge {
        top: -2px;
        left: auto;
        right: -2px;
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .container {
        padding: 15px;
        padding-bottom: 120px; /* More space for taller footer on mobile */
    }
    .games-grid {
        gap: 15px;
    }
    .games-grid.grid-3,
    .games-grid.grid-4,
    .games-grid.grid-5, 
    .games-grid.grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }
}
