/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* Inter/Tajawal already loaded from Google Fonts in views */
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Prevent mobile zoomed-out look: ensure page fits viewport */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

/* RTL and Language Support */
body.rtl {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
}

body.ltr {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: ltr;
    text-align: left;
}

/* Arabic typography improvements */
.rtl h1, .rtl h2, .rtl h3, .rtl h4, .rtl h5, .rtl h6 {
    font-weight: 600;
    letter-spacing: 0;
}

.rtl p, .rtl span, .rtl div {
    font-weight: 400;
    line-height: 1.8;
}

/* Language Switcher */
.language-switcher {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 25px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 100px;
}

.language-switcher:hover {
    border-color: #e74c3c;
    box-shadow: 0 2px 5px rgba(231, 76, 60, 0.2);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.nav-links a:hover {
    background-color: #f8f9fa;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: #e74c3c;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    text-align: center;
}

.btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Brand Background Support */
.brand-background {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
}

.brand-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.brand-background .container {
    position: relative;
    z-index: 2;
}

.brand-background .header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.brand-background .card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
}

.card-header {
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    margin: 0;
    color: #333;
}

.card-body {
    padding: 1.5rem;
}

/* Desktop item layout: square media column like mobile */
.menu-item-media {
    width: 180px;
    flex: 0 0 180px;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f3f5;
    overflow: hidden;
    border-radius: 8px;
}
.menu-item-media img { width:100%; height:100%; object-fit:cover; display:block; }

/* Remove side padding for full-width feel on desktop cards containing menu items */
.card-body > .menu-item:first-child { margin-top: .25rem; }
/* Removed inner padding to let image and content hug card edges for maximum width */
/* .card-body > .menu-item { padding: .75rem 1rem; } */

/* Menu Items */
.menu-item {
    position: relative;
    display: flex; 
    align-items: flex-start; 
    gap: .5rem; 
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
}

.menu-item:hover {
    background-color: #f8f9fa;
}

.menu-item:last-child {
    border-bottom: none;
}
/* Image element (desktop base) */
.menu-item-image {
    flex-shrink: 0;
    border-radius: 10px;
    object-fit: cover;
    background-color: #f0f0f0;
}

.menu-item-content {
    flex: 1;
}

.menu-item-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    position: relative;
    padding-inline-end: 0; /* will be increased if price chip present */
}
.menu-item.has-price .menu-item-header { padding-inline-end: 92px; }

.menu-item-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--brand-item-name, #E74D84);
    margin: 0;
    overflow-wrap: anywhere;
}

.menu-item-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e74c3c;
}

.menu-item-description {
    color: var(--brand-item-desc, #111);
    margin-bottom: 0.5rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.menu-item.has-price .menu-item-description { padding-inline-end: 90px; }
.menu-item.has-price .menu-item-header { min-height: 34px; }

.menu-item-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.9rem;
    color: #888;
}

.allergen-info {
    background-color: #fff3cd;
    color: #856404;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.allergen-info:hover {
    background-color: #ffeaa7;
}

/* Categories */
.category-section {
    margin-bottom: 3rem;
}

.category-title {
    position: relative;
    background-color: #e74c3c;
    color: white;
    padding: 1rem 1.5rem;
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

/* Category hero with dim overlay */
.category-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    background-size: cover !important;
    background-position: center !important;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

/* Increase height on desktop for better aspect ratio (~4:1 instead of ~6.8:1) */
@media (min-width: 768px) {
    .category-hero {
        min-height: 250px;
    }
}

/* Overlay removed - images now have embedded text and pre-dimming */
/*
.category-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1;
}
*/
/* Text hidden - images have embedded text */
.category-hero span,
.category-hero h2,
.category-hero h3,
.category-hero .title-text {
    position: relative;
    z-index: 2;
    color: white !important;
    font-size: 1.8rem;
    font-weight: 700;
    display: none; /* Hidden since images have embedded text */
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Chips (price, calories, etc.) */
:root {
    --chip-green: #2ecc71; /* friendly green */
    --chip-green-dark: #27ae60;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--chip-green);
    color: #fff;
    padding: 6px 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: .9rem;
    line-height: 1;
}
.chip .sar-icon, .chip img.sar-icon { 
    width: 18px; 
    height: 18px; 
    display: inline-block; 
}
.chip .unit { opacity: .95; font-weight: 600; }
.chip.secondary { background: var(--chip-green-dark); }

/* Price chip: position top-corner of each item for consistency */
.price-chip {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px; /* respects RTL */
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Ensure parent provides positioning context */
.menu-item { position: relative; }

/* Icon-only action chips (allergens, dietary, nutrition) */
.icon-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: #eef8f0;
    color: #1e7e34;
    border: 1px solid #cdebd5;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
}
.icon-chip .icon { font-size: 1rem; line-height: 1; }
.icon-chip .label { font-size: .85rem; color: #2f4f4f; }
.icon-chip:hover { background: #e3f3e7; }

/* Brand hero */
.brand-hero {
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    overflow: hidden;
    margin: 1rem 0 1.25rem;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.brand-hero::before { 
    content: ''; 
    position: absolute; 
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.35); 
    z-index: 1;
}
.brand-hero .brand-logo {
    position: relative;
    z-index: 2;
    max-width: min(92%, 420px);
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* New compact brand strip (replaces old grey block) */
.brand-strip {
    padding-left: 0;
    padding-right: 0;
    margin-top: .25rem;
    margin-bottom: .75rem;
}
.brand-logo-box {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    position: relative;
    display: grid;
    place-items: center;
    /* subtle background and hairlines that visually merge with header and category buttons */
    background: linear-gradient(180deg, rgba(0,0,0,0.04), rgba(0,0,0,0.02));
    border-left: 1px solid rgba(0,0,0,0.06);
    border-right: 1px solid rgba(0,0,0,0.06);
}
.brand-logo-box::before,
.brand-logo-box::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.12), transparent);
}
.brand-logo-box::before { top: 0; }
.brand-logo-box::after { bottom: 0; }
.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* fill the whole square with wide logos too */
    display: block;
}

/* Mobile tweaks for the brand strip */
@media (max-width: 768px) {
    .brand-strip { margin-top: 0; margin-bottom: .5rem; }
    .brand-logo-box { 
        max-width: none; 
        aspect-ratio: 4 / 3; /* Reduced height by 25% (was 1/1) */
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-title {
    margin: 0;
    color: #333;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.allergen-list {
    list-style: none;
    padding: 0;
}

.allergen-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.allergen-item:last-child {
    border-bottom: none;
}

.allergen-type {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-weight: 600;
}

.allergen-type.contains {
    background-color: #dc3545;
    color: white;
}

.allergen-type.may-contain {
    background-color: #ffc107;
    color: #333;
}

/* Admin styles */
.admin-header {
    background-color: #343a40;
    color: white;
}

.admin-nav {
    background-color: #495057;
    padding: 1rem 0;
}

.admin-nav .container {
    display: flex;
    gap: 2rem;
}

.admin-nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.admin-nav a:hover,
.admin-nav a.active {
    background-color: #6c757d;
}

.admin-content {
    padding: 2rem 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.table img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container { padding-left: 0; padding-right: 0; width: 100%; max-width: 100%; }
    .header { width: 100%; }
    .header .container { padding-left: 12px; padding-right: 12px; }
    body[style*="background-attachment: fixed"] { background-attachment: scroll !important; }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Keep image-left (LTR) / right (RTL) on mobile as in reference design */
    .menu-item { 
        flex-direction: row; 
        align-items: stretch; 
        text-align: start; 
        gap: 0; 
        padding: 0; 
        min-height: 120px;
    }
    /* Image takes ~33% width; limit height to 22% of viewport height */
    .menu-item-image, .menu-item-image-container, .menu-item-media { 
        flex: 0 0 33.333%;
        width: 33.333% !important; 
        aspect-ratio: auto; /* not forced square on mobile */
        max-height: 22vh; /* requested mobile max height */
        height: auto !important; 
        border-radius: 0;
        flex-shrink: 0;
        position: relative;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f1f3f5;
    }
    .menu-item-image-container img.menu-item-image, 
    .menu-item-image-container > img, 
    .menu-item-image img, 
    .menu-item-media img { 
        width: 100% !important; 
        height: 100% !important; 
        object-fit: cover !important; 
        display: block; 
    }
    .menu-item-content {
        padding: .85rem .9rem .9rem .9rem;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .menu-item-header { 
        display: flex; 
        align-items: flex-start; 
        gap: .5rem; 
    }
    .menu-item-header h3.menu-item-name { 
        flex: 1 1 auto; 
        margin: 0; 
        min-width: 0; 
        display: -webkit-box;
    -webkit-line-clamp: 2; /* allow wrap to two lines */
    line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
        line-height: 1.15;
    }
    .menu-item-header .chip { flex: 0 0 auto; white-space: nowrap; }
    .menu-item.has-price .menu-item-header { padding-inline-end: 86px; }
    /* ensure price chip stays visible even when name wraps */
    .menu-item .price-chip { top: 6px; inset-inline-end: 6px; }
    /* RTL: keep image on appropriate side */
    body.rtl .menu-item { direction: rtl; }
    body.rtl .menu-item-image, body.rtl .menu-item-image-container, body.rtl .menu-item-media { order: 2; }
    body.rtl .menu-item-content { order: 1; }
    .menu-item-header { flex-direction: row; gap: .5rem; align-items: baseline; justify-content: space-between; text-align: start; }
    .menu-item-name { font-size: 1.06rem; }
    .menu-item-description { font-size: .9rem; margin-top: .25rem; }
    .menu-item-meta { justify-content: flex-start; flex-wrap: wrap; gap: .4rem; }

    /* Make action chips finger-friendly and hide labels on mobile */
    .icon-chip { padding: 10px 12px; border-radius: 14px; }
    .icon-chip .icon { font-size: 1.15rem; }
    .icon-chip .label { display: none; }
    .chip { padding: 8px 10px; font-size: .9rem; border-radius: 14px; }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .admin-nav .container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
