:root {
    --primary-orange: #ff6600;
    --bg-color: #f9f9f9;
    --glass-bg: rgba(255, 255, 255, 0);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
    --backdrop-blur: blur(12px);
    --primary-color: #333;
    --accent-color: #fff;
    --btn-bg: var(--primary-orange);
    --btn-text: #ffffff;
    --font-family: 'Rubik', 'Tajawal', sans-serif;
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-color: #121212;
    --primary-color: #f0f0f0;
    --glass-bg: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.5);
}

/* High Contrast Overrides */
body.high-contrast {
    filter: contrast(1.25);
}
body.high-contrast .glass-card {
    border: 2px solid var(--primary-color) !important;
}

/* Accessibility Features */
body.highlight-links a {
    text-decoration: underline !important;
    font-weight: bold !important;
    outline: 2px solid var(--primary-orange) !important;
    outline-offset: 2px;
}

html.large-cursor, html.large-cursor *, 
body.large-cursor, body.large-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M0 0 L0 24 L7 17 L13 30 L17 28 L11 15 L19 15 Z" fill="white" stroke="black" stroke-width="1"/></svg>'), auto !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
* { outline: none !important; } /* Added to remove black outline on click */

/* Native Feel - Hide Scrollbars */
html, body {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}


body {
    font-family: var(--font-family);
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--primary-color);
    padding-bottom: env(safe-area-inset-bottom);
    overflow-x: hidden;
}

/* Prevent background scrolling when modal is open */
body.no-scroll {
    overflow: hidden;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
    flex-direction: column;
    background: var(--bg-color); /* Matches theme */
}

.spinner-container {
    width: 120px;
    height: 120px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 6px solid rgba(128, 128, 128, 0.2);
    border-top: 6px solid var(--btn-bg);
    border-radius: 50%;
    animation: spin-scale 2s ease-in-out infinite;
}

/* Removed loading-logo styles */

.loading-text {
    margin-top: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary-color);
    opacity: 0.8;
}

@keyframes spin-scale {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.6); }
    100% { transform: rotate(360deg) scale(1.2); }
}
@keyframes pulse { 0%, 100% { transform: scale(0.95); opacity: 0.8; } 50% { transform: scale(1.05); opacity: 1; } }

/* Utilities */
.hidden { display: none !important; }

/* Glassmorphism Base */
.glass-header, .glass-footer, .glass-card, .glass-modal {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Header */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: calc(15px + env(safe-area-inset-top)) 15px 15px 15px;
    border-radius: 0 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-icons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.user-greeting {
    font-weight: bold;
    font-size: 1.1rem;
}

#search-input {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.4);
    outline: none;
}

/* Main Content */
#main-content {
    padding: 20px;
    padding-bottom: 120px; /* Space for footer and banner */
    min-height: 80vh;
}

.page-title {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); /* Adjusted for better mobile fit */
    gap: 12px; /* Adjusted gap */
    width: 100%; /* Ensure full width */
}

/* Cards */
.glass-card {
    border-radius: 16px;
    padding: 20px;
    transition: transform 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    height: 100%;
    border: 1px solid var(--glass-border); /* Added border for definition */
    background: rgba(255, 255, 255, 0.1); /* Subtle background for cards */
}

/* Enlarge (i) Button - UI Fix #1 */
.info-btn-circular {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--primary-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
}

/* Force buttons to bottom of card */
.glass-card .glass-btn {
    margin-top: auto;
}

.view-btn {
    width: 100%;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Privacy Page Enhancements */
.privacy-page {
    background: var(--bg-color);
    animation: fadeInPage 0.4s ease-out;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: scale(1.02); }
    to { opacity: 1; transform: scale(1); }
}

.privacy-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 50px;
}

.privacy-container h2 {
    color: var(--primary-orange);
    margin-bottom: 8px;
}

.privacy-container p {
    font-size: 1.15rem; /* Increased font size */
    line-height: 1.6; /* UI Fix #3 */
    opacity: 0.9;
}

/* Adjustments for privacy header to look native */
.privacy-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

body.dark-mode .privacy-container p {
    color: #ccc;
}
.glass-card:active, .glass-btn:active { /* Apply active state to all glass buttons */
    transform: scale(0.98);
}

.store-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.store-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.store-deal {
    font-size: 0.9rem;
    color: var(--primary-color);
    opacity: 0.8;
    margin-bottom: 15px;
}

.glass-card .glass-btn {
    margin-top: auto;
}

/* Detail View */
.detail-card {
    margin-top: 20px;
    padding: 40px 20px;
    min-height: 300px;
    justify-content: center;
}

.detail-card .store-icon {
    font-size: 5rem;
}

.detail-card .store-name {
    font-size: 2rem;
    margin-bottom: 20px;
}

.detail-card .store-deal {
    font-size: 1.2rem;
    line-height: 1.6;
}

.section-title {
    margin: 30px 0 15px 0;
    text-align: center;
    color: var(--primary-color);
}

/* Footer */
.glass-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 90;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom)) 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.footer-copyright {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: center;
    width: 100%;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    flex-wrap: nowrap;
}

.footer-btn {
    white-space: nowrap;
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    padding: 8px 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

#install-banner-container {
    position: fixed; /* Floating banner */
    bottom: calc(20px + env(safe-area-inset-bottom)); /* Dynamic margin from bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 90%; /* Constrain width */
    max-width: 400px; /* Max width for larger screens */
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space between button and close X */
    background: rgba(255, 255, 255, 0.9); /* White translucent background */
    backdrop-filter: var(--backdrop-blur); /* Glass effect */
    -webkit-backdrop-filter: var(--backdrop-blur); /* For Safari */
    border-radius: 20px; /* Rounded corners */
    padding: 10px 15px; /* Padding inside banner */
    box-shadow: var(--glass-shadow); /* Consistent shadow */
    border: 1px solid var(--glass-border); /* Consistent border */
    z-index: 101; /* Higher z-index than footer */
}

.close-banner {
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff; /* White X */
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.close-banner:active {
    transform: scale(0.9); /* Subtle active effect for X */
}

/* Claim/Redeem Button Styling - UI Fix #2 */
.redeem-btn {
    width: 80% !important;
    max-width: 300px !important;
    height: 50px !important;
    background: var(--primary-orange) !important;
    color: white !important;
    font-weight: 800 !important;
    border-radius: 15px !important;
    border: none !important;
    font-size: 1.1rem !important;
    box-shadow: 0 4px 15px rgba(255, 102, 0, 0.4) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px auto;
    transition: transform 0.1s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.redeem-btn:active {
    transform: scale(0.95) !important;
}

.glass-btn {
    background: var(--btn-bg);
    color: var(--btn-text);
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); /* Improved contrast for white text on orange */
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3); /* Orange shadow */
}

.footer-round-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    display: flex;
    justify-content: center;
    align-items: center;
}

#install-banner-container .glass-btn {
    flex-grow: 1; /* Allow install button to grow within the banner */
    margin-inline-end: 10px; /* Space between button and X */
}

.glass-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Onboarding Modal */
#onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.3);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-modal {
    width: 85%;
    max-width: 350px;
    padding: 40px 25px 25px 25px; /* Extra top padding for X button */
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    color: var(--primary-color);
}

.modal-close-x {
    position: absolute;
    top: 15px;
    inset-inline-end: 15px;
    font-size: 24px;
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    opacity: 0.7;
}

/* RTL Fixes for Bottom Buttons */
html[dir="rtl"] .top-controls {
    flex-direction: row-reverse;
}
html[dir="rtl"] .action-icons {
    flex-direction: row-reverse;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.3);
    margin: 10px 0;
}

.lang-option {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 15px;
}

/* RTL/LTR Adjustments */
html[dir="rtl"] .glass-btn {
    direction: rtl;
}

html[dir="ltr"] .glass-btn {
    direction: ltr;
}

/* Handle iOS Home Indicator (bottom bar) */
#main-content {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* Overlay & Modal System Fixes */
.modal-overlay, #map-overlay, #install-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-container {
    width: 90%;
    max-width: 500px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

#google-map-frame {
    width: 100%;
    flex-grow: 1;
    border-radius: 12px;
    margin-bottom: 15px;
    background: #eee;
}

/* Toast Animation Fix (Prevents the "Black Block" jumping) */
@keyframes toastFadeIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    padding: 12px 24px;
    background: rgba(40, 40, 40, 0.95);
    color: white;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: toastFadeIn 0.4s ease-out forwards;
    border: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

/* Language Display Logic */
html[lang="he"] .lang-en, html[lang="he"] .lang-ar { display: none !important; }
html[lang="en"] .lang-he, html[lang="en"] .lang-ar { display: none !important; }
html[lang="ar"] .lang-he, html[lang="ar"] .lang-en { display: none !important; }


/* Settings Widget Styling */
#access-widget { position: relative; display: inline-block; }
#access-menu { 
    display: none; 
    position: absolute; 
    top: 50px; 
    inset-inline-start: 0; 
    flex-direction: column; 
    gap: 8px; 
    background: rgba(255,255,255,0.98); 
    padding: 15px; 
    border-radius: 16px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); 
    min-width: 220px; 
    z-index: 1000;
    border: 1px solid var(--glass-border);
}
body.dark-mode #access-menu { background: rgba(30,30,30,0.98); color: #fff; }
.access-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.95rem; margin-bottom: 5px; }
.access-item span { color: inherit; }

/* Adjust main content padding for floating footer/banner */
#main-content {
    padding-bottom: 100px; /* Adjusted padding since footer is removed */
}

/* Ensure full width for main app container */
#app-container { width: 100%; }

/* Ad Container Styling */
.ad-container {
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    min-height: 50px;
}