:root {
    --primary-color: #4CAF50; /* A common Android green */
    --accent-color: #FFC107; /* Amber for highlights */
    --background-color: #F5F5F5;
    --surface-color: #FFFFFF;
    --text-color: #212121;
    --text-color-light: #757575;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --toolbar-height: 56px;
    --bottom-nav-height: 56px;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* Prevent body scroll */
    direction: rtl; /* Right-to-left direction for Arabic */
    text-align: right; /* Default text alignment for RTL */
}

#app {
    width: 100%;
    max-width: 420px; /* Typical phone width */
    height: 100vh; /* Full height of the viewport for the app frame */
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
    box-shadow: 0 0 10px var(--shadow-color); /* App container shadow */
    border-radius: var(--border-radius); /* Rounded corners for the app frame */
    overflow: hidden; /* Hide scrollbars outside content area */
    opacity: 0; /* Initially hidden for splash screen */
    visibility: hidden; /* Initially hidden for splash screen */
    transition: opacity 0.5s ease-in, visibility 0.5s; /* Transition for app appearance */
    pointer-events: none; /* Prevent interaction before it's fully visible */
}

/* Class to make the app visible after splash screen */
#app.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Splash Screen Styling */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-color); /* Primary color background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200; /* Ensure it's on top of everything else */
    color: var(--surface-color); /* White text color */
    font-size: 48px;
    font-weight: 700;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

#splash-screen h1 { /* Targeting the h1 inside splash-screen */
    font-size: 32px; /* Smaller font size */
    color: var(--accent-color); /* Vibrant accent color */
    /* Animation properties */
    animation: fadeInScale 1.5s ease-out forwards;
    transform: scale(0.8); /* Start smaller */
    opacity: 0; /* Start invisible */
}

/* Keyframes for the animation */
@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.05); /* Slightly larger than final size for a bounce effect */
    }
    100% {
        opacity: 1;
        transform: scale(1); /* Final size */
    }
}

.toolbar {
    background-color: var(--primary-color);
    color: var(--surface-color);
    padding: 0 16px;
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow-color);
    z-index: 10;
    flex-shrink: 0;
    position: relative; /* Needed for absolute positioning of children */
}

/* New logo styling for the main page */
.main-page-logo {
    position: absolute;
    right: 16px; /* Changed from 'left' to 'right' for RTL */
    top: 50%;
    transform: translateY(-50%) rotate(0deg); /* Adjust for vertical centering and initial rotation */
    font-size: 30px;
    color: var(--accent-color); /* Make it vibrant */
    animation: rotate 3s linear infinite; /* Apply rotation animation */
    z-index: 1;
}

/* Keyframes for rotation animation */
@keyframes rotate {
    from {
        transform: translateY(-50%) rotate(0deg); /* Maintain vertical centering */
    }
    to {
        transform: translateY(-50%) rotate(360deg); /* Maintain vertical centering */
    }
}

.toolbar-title {
    font-size: 20px;
    font-weight: 500;
    flex-grow: 1; /* Allow it to take available space */
    text-align: center; /* Center the text */
}

.content {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto; /* Scrollable content area */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    display: flex;
    flex-direction: column;
    gap: 16px; /* Space between food cards */
}

.food-card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    padding: 12px;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    position: relative; /* Needed for absolute positioning of children */
}

.food-card:hover {
    transform: translateY(-2px);
}

.food-card img {
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius);
    object-fit: cover;
    margin-left: 16px; /* Changed from 'margin-right' to 'margin-left' for RTL */
    flex-shrink: 0;
}

.food-card-info {
    flex-grow: 1;
}

.food-card h3 {
    font-size: 18px;
    margin-bottom: 4px;
    font-weight: 500;
}

.food-card p {
    font-size: 14px;
    color: var(--text-color-light);
    line-height: 1.4;
}

.favorite-button {
    position: absolute;
    top: 10px;
    left: 10px; /* Changed from 'right' to 'left' for RTL */
    background: none;
    border: none;
    font-size: 24px; /* Larger heart */
    cursor: pointer;
    color: var(--text-color-light); /* Default heart color is light grey for visibility */
    transition: color 0.2s ease-in-out, transform 0.2s ease-in-out;
    padding: 5px; /* Make clickable area larger */
    border-radius: 50%; /* Nice touch for clickable area */
    display: flex; /* To center the emoji if it's an icon font later */
    justify-content: center;
    align-items: center;
    z-index: 5; /* Ensure it's above other elements if overlaps */
}

.favorite-button:hover {
    transform: scale(1.1);
}

.favorite-button.is-favorited {
    color: #FF0000; /* Favorited heart color is red */
}

.bottom-nav {
    background-color: var(--surface-color);
    height: var(--bottom-nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 4px var(--shadow-color);
    z-index: 10;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    flex: 1;
    color: var(--text-color-light);
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-text {
    font-size: 12px;
    font-weight: 500;
}

/* Optional: Scrollbar styling for a cleaner look */
.content::-webkit-scrollbar {
    width: 8px;
}

.content::-webkit-scrollbar-track {
    background: var(--background-color);
}

.content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 2px solid var(--background-color);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 380px; /* Slightly smaller than app max-width */
    padding: 20px;
    position: relative;
    max-height: 80vh; /* Limit height to prevent overflow on small screens */
    overflow-y: auto; /* Enable scrolling for content if it overflows */
    transform: scale(0.9);
    transition: transform 0.3s ease-in-out;
}

.modal-overlay.visible .modal-content {
    transform: scale(1);
}

.modal-close-button {
    position: absolute;
    top: 10px;
    left: 10px; /* Changed from 'right' to 'left' for RTL */
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color-light);
    cursor: pointer;
    padding: 5px;
    line-height: 1; /* Ensure X is vertically centered */
}

.modal-image {
    width: 100%;
    height: 180px; /* Fixed height for modal image */
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 700;
}

.modal-content p {
    font-size: 16px;
    color: var(--text-color-light);
    margin-bottom: 15px;
    line-height: 1.5;
}

.modal-content h3 {
    font-size: 18px;
    margin-top: 20px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-content ul {
    list-style: none;
    padding-right: 0; /* Changed from 'padding-left' to 'padding-right' for RTL */
}

.modal-content ul li {
    font-size: 16px;
    margin-bottom: 8px;
    padding-right: 20px; /* Changed from 'padding-left' to 'padding-right' for RTL */
    position: relative;
}

.modal-content ul li::before {
    content: '•'; /* Bullet point */
    color: var(--primary-color);
    position: absolute;
    right: 0; /* Changed from 'left' to 'right' for RTL */
    top: 0;
}

/* Search input styling */
.search-input {
    width: calc(100% - 32px); /* Full width minus content padding */
    padding: 12px 16px;
    margin: 0 0 16px 0; /* Add margin-bottom for spacing from cards */
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    transition: border-color 0.2s ease-in-out;
    -webkit-appearance: none; /* Remove default iOS styling */
    -moz-appearance: none; /* Remove default Firefox styling */
    appearance: none;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05), 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.no-results-message {
    text-align: center;
    color: var(--text-color-light);
    font-style: italic;
    margin-top: 20px;
    padding: 0 16px; /* Add padding to align with other content */
}

/* Offline Page Styling */
.offline-page-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--background-color);
    text-align: center;
}

.offline-container {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px var(--shadow-color);
    padding: 30px;
    margin: 20px;
    max-width: 400px;
    opacity: 0; /* Initially hidden for animation */
    transform: translateY(20px); /* Start slightly below for animation */
    animation: fadeInSlideUp 0.8s forwards ease-out; /* Apply initial animation */
}

/* New keyframes for the offline-container */
@keyframes fadeInSlideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.offline-container h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.offline-container p {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 25px;
    line-height: 1.6;
}

/* New styling for the offline icon */
.offline-icon {
    font-size: 60px; /* Large emoji */
    margin-bottom: 20px;
    color: var(--accent-color); /* Use accent color for visibility */
    animation: bouncePulse 2s infinite ease-in-out; /* Apply pulsing animation */
}

/* New keyframes for the pulsing icon */
@keyframes bouncePulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-10px) scale(1.05); /* Move up and slightly enlarge */
        opacity: 0.8;
    }
}

.retry-button {
    background-color: var(--primary-color);
    color: var(--surface-color);
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.retry-button:hover {
    background-color: #388E3C; /* Darker shade of green */
}