/**
 * Food Detail Modal - Étel részletek popup
 * Támogatja: desktop modal, mobil slide-up, dark/light mode
 */

/* Modal háttér */
.food-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: calc(var(--z-modal-high) - 1); /* 3999 - modal alatt */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.food-detail-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal konténer */
.food-detail-modal {
    position: fixed;
    z-index: var(--z-modal-high); /* 4000 */
    background: var(--card-background, #ffffff);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.food-detail-modal.active {
    transform: translateY(0);
}

/* Desktop stílus */
@media (min-width: 769px) {
    .food-detail-modal {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
        pointer-events: none;  /* KRITIKUS: Nem blokkolja a kattintásokat! */
        width: 90%;
        max-width: 500px;
        max-height: 90vh;
        border-radius: 16px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    
    .food-detail-modal.active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: auto;  /* KRITIKUS: Aktív állapotban elfogadja! */
    }
    
    /* Desktop árak - egymás mellett, wrap */
    .food-detail-price-options {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .food-detail-price-option {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: calc(50% - 4px) !important;
        border-radius: 10px !important;
        padding: 12px 14px !important;
    }
}

/* === FEATURE IKONOK === */
.food-detail-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    align-items: center;
}

.food-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: help;
    padding: 3px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, background 0.2s;
    position: relative;
}

.food-feature-icon:hover {
    transform: scale(1.15);
    background: rgba(0, 0, 0, 0.1);
}

/* Tooltip stílus (natív title attribútum helyett custom) */
.food-feature-icon[title] {
    position: relative;
}

/* Mobilon kisebb ikonok */
@media (max-width: 768px) {
    .food-detail-features {
        gap: 4px;
        margin-bottom: 6px;
    }
    
    .food-feature-icon {
        font-size: 12px;
        padding: 2px 4px;
    }
}

/* Dark mode feature ikonok */
[data-theme="dark"] .food-feature-icon {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .food-feature-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] .food-feature-icon {
        background: rgba(255, 255, 255, 0.1);
    }
    
    [data-theme="auto"] .food-feature-icon:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* Mobil stílus - slide up */
@media (max-width: 768px) {
    .food-detail-modal {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
    }
    
    .food-detail-modal.active {
        transform: translateY(0);
    }
    
    /* Header fix méret */
    .food-detail-header {
        flex-shrink: 0;
    }
    
    /* Négyzetes kép mobilon is — minden középen; a tartalom alatta görgethető */
    .food-detail-image-container {
        padding-bottom: 100%;
        max-height: 56vh; /* nagyon kis kijelzőn ne nyomja le a kosár-gombot */
    }
    
    /* Tartalom - görgethető, flex:1 */
    .food-detail-content {
        flex: 1;
        overflow-y: auto;
        padding: 10px 14px;
        min-height: 0;
    }
    
    /* Kisebb betűméretek */
    .food-detail-name {
        font-size: 1rem;
        margin-bottom: 4px;
    }
    
    .food-detail-name .item-number {
        font-size: 0.8em;
    }
    
    .food-detail-seasonal {
        font-size: 0.55rem;
        padding: 2px 6px;
        margin-bottom: 4px;
    }
    
    .food-detail-description {
        font-size: 0.8rem;
        line-height: 1.35;
        margin-bottom: 8px;
    }
    
    /* Allergének - INLINE, kompakt */
    .food-detail-allergens {
        padding: 0;
        margin-bottom: 8px;
        background: none;
        border: none;
        border-radius: 0;
        display: inline;
    }
    
    .food-detail-allergens-title {
        display: inline;
        font-size: 0.75rem;
        color: #e74c3c;
    }
    
    .food-detail-allergens-title i {
        margin-right: 4px;
    }
    
    .food-detail-allergens-list {
        display: inline;
        font-size: 0.75rem;
        color: #c0392b;
    }
    
    /* Címkék kisebb */
    .food-detail-tags {
        gap: 4px;
        margin-bottom: 8px;
    }
    
    .food-detail-tag {
        padding: 2px 5px;
        font-size: 0.6rem;
    }
    
    /* Árak - flexibilis chip stílus */
    .food-detail-prices {
        margin-bottom: 0;
    }
    
    .food-detail-prices-title {
        font-size: 0.7rem;
        margin-bottom: 4px;
        color: var(--text-muted);
    }
    
    .food-detail-price-options {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    
    .food-detail-price-option {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: calc(50% - 4px) !important;
        max-width: 100% !important;
        padding: 8px 10px !important;
        border-width: 1px !important;
        border-radius: 8px !important;
    }
    
    .food-detail-price-radio {
        width: 14px;
        height: 14px;
        margin-right: 6px;
    }
    
    .food-detail-price-option.selected .food-detail-price-radio::after {
        width: 6px;
        height: 6px;
    }
    
    .food-detail-price-label {
        font-size: 0.75rem;
    }
    
    .food-detail-price-value {
        font-size: 0.8rem;
        margin-left: auto;
    }
    
    .food-detail-single-price {
        font-size: 1rem;
        margin-bottom: 0;
    }
    
    .food-detail-single-price .unit {
        font-size: 0.7rem;
    }
    
    /* Footer - mennyiség és gomb EGY SORBAN */
    .food-detail-footer {
        flex-shrink: 0;
        padding: 10px 16px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-color, #eee);
        background: var(--card-background, #fff);
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .food-detail-quantity {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .food-detail-qty-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .food-detail-qty-value {
        font-size: 1rem;
        min-width: 24px;
    }
    
    .food-detail-add-btn {
        flex: 1;
        padding: 10px 14px;
        font-size: 0.85rem;
        border-radius: 8px;
    }
    
    /* Bezárás gomb kisebb */
    .food-detail-close {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        top: 10px;
        right: 10px;
    }
    
    /* Kedvenc gomb kisebb */
    .food-detail-favorite {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        top: 10px;
        left: 10px;
    }
}

/* Modal fejléc */
.food-detail-header {
    position: relative;
    width: 100%;
    flex-shrink: 0;
}

/* Kép konténer — NÉGYZETES (1:1); a kép középre vágva kitölti (cover), így nincs üres
   sáv és minden étel/placeholder a négyzet közepére kerül. */
.food-detail-image-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* NÉGYZETES — a kép cover-rel középre vágva kitölti */
    overflow: hidden;
    background: var(--bg-secondary, #f5f5f5);
}

.food-detail-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* négyzetbe vágva, középről — kitölti, nincs sáv */
    object-position: center;
}

/* Nincs kép placeholder */
.food-detail-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-muted, #999);
    font-size: 3rem;
}

/* Bezárás gomb */
.food-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s;
    z-index: var(--z-local); /* Lokális kiemelés */
}

.food-detail-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Kedvenc gomb */
.food-detail-favorite {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #ccc;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    z-index: var(--z-local); /* Lokális kiemelés */
}

.food-detail-favorite:hover {
    background: white;
    transform: scale(1.1);
}

.food-detail-favorite.is-favorite {
    color: #e74c3c;
}

.food-detail-favorite.is-favorite i {
    animation: heartPulse 0.3s ease;
}

@keyframes heartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Modal tartalom - görgethetű */
.food-detail-content {
    flex: 1;
    min-height: 0;
    padding: 16px 20px;
    overflow-y: auto;
}

@media (min-width: 769px) {
    .food-detail-content {
        max-height: calc(90vh - 350px);
    }
}

/* Mobil swipe indikátor */
.food-detail-swipe-indicator {
    display: none;
    width: 40px;
    height: 4px;
    background: var(--border-color, #ddd);
    border-radius: 2px;
    margin: 8px auto;
}

@media (max-width: 768px) {
    .food-detail-swipe-indicator {
        display: block;
    }
}

/* Étel név */
.food-detail-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #333);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.food-detail-name .item-number {
    font-size: 0.85em;
    color: var(--text-muted, #888);
    font-weight: normal;
    margin-right: 6px;
}

/* Szezonális badge */
.food-detail-seasonal {
    display: inline-block;
    background: #E53935;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Leírás */
.food-detail-description {
    font-size: 0.95rem;
    color: var(--text-secondary, #555);
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Allergének */
.food-detail-allergens {
    background: rgba(231, 76, 60, 0.1);
    border-left: 3px solid #e74c3c;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 0 8px 8px 0;
}

.food-detail-allergens-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e74c3c;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.food-detail-allergens-list {
    font-size: 0.85rem;
    color: var(--text-secondary, #555);
}

/* Címkék (vegetáriánus, csípős, stb.) */
.food-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.food-detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-secondary, #f0f0f0);
    color: var(--text-secondary, #555);
}

.food-detail-tag.tag-vegetarian { background: #e8f5e9; color: #2e7d32; }
.food-detail-tag.tag-vegan { background: #e8f5e9; color: #1b5e20; }
.food-detail-tag.tag-gluten-free { background: #fff3e0; color: #e65100; }
.food-detail-tag.tag-lactose-free { background: #e3f2fd; color: #1565c0; }
.food-detail-tag.tag-spicy { background: #ffebee; color: #c62828; }
.food-detail-tag.tag-for-kids { background: #fce4ec; color: #ad1457; }
.food-detail-tag.tag-diet { background: #f3e5f5; color: #7b1fa2; }

/* Ár választó */
.food-detail-prices {
    margin-bottom: 16px;
}

.food-detail-prices-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    margin-bottom: 8px;
}

.food-detail-price-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.food-detail-price-option {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card-background, #fff);
}

.food-detail-price-option:hover {
    border-color: var(--primary, #4CAF50);
}

.food-detail-price-option.selected {
    border-color: var(--primary, #4CAF50);
    background: rgba(76, 175, 80, 0.05);
}

.food-detail-price-option input[type="radio"] {
    display: none;
}

.food-detail-price-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, #ccc);
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.food-detail-price-option.selected .food-detail-price-radio {
    border-color: var(--primary, #4CAF50);
}

.food-detail-price-option.selected .food-detail-price-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--primary, #4CAF50);
    border-radius: 50%;
}

.food-detail-price-label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
}

.food-detail-price-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary, #4CAF50);
}

/* Egyetlen ár esetén */
.food-detail-single-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary, #4CAF50);
    margin-bottom: 16px;
}

.food-detail-single-price .unit {
    font-size: 0.8rem;
    font-weight: normal;
    color: var(--text-muted, #888);
    margin-right: 8px;
}

/* Modal lábléc - akció gombok - EGY SORBAN */
.food-detail-footer {
    flex-shrink: 0;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #eee);
    background: var(--card-background, #fff);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/* Mennyiség választó */
.food-detail-quantity {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
}

.food-detail-qty-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color, #ddd);
    background: var(--card-background, #fff);
    color: var(--text-primary, #333);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.food-detail-qty-btn:hover {
    border-color: var(--primary, #4CAF50);
    color: var(--primary, #4CAF50);
}

.food-detail-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.food-detail-qty-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #333);
    min-width: 28px;
    text-align: center;
}

/* Kosárba gomb */
.food-detail-add-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: var(--primary, #4CAF50);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, transform 0.1s;
}

.food-detail-add-btn:hover {
    background: #45a049;
}

.food-detail-add-btn:active {
    transform: scale(0.98);
}

.food-detail-add-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.food-detail-add-btn .btn-price {
    margin-left: auto;
    padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,0.3);
}

/* Loading állapot */
.food-detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.food-detail-loading i {
    font-size: 2rem;
    color: var(--primary, #4CAF50);
    animation: spin 1s linear infinite;
}

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

/* Dark mode támogatás */
[data-theme="dark"] .food-detail-modal {
    background: var(--card-background, #1e1e1e);
}

[data-theme="dark"] .food-detail-name {
    color: var(--text-primary, #f0f0f0);
}

[data-theme="dark"] .food-detail-name .item-number {
    color: var(--text-muted, #999);
}

[data-theme="dark"] .food-detail-description {
    color: var(--text-secondary, #b8b8b8);
}

[data-theme="dark"] .food-detail-single-price .unit {
    color: var(--text-muted, #999);
}

[data-theme="dark"] .food-detail-prices-title {
    color: var(--text-secondary, #b8b8b8);
}

[data-theme="dark"] .food-detail-price-label {
    color: var(--text-primary, #f0f0f0);
}

[data-theme="dark"] .food-detail-qty-value {
    color: var(--text-primary, #f0f0f0);
}

[data-theme="dark"] .food-detail-qty-btn {
    color: var(--text-primary, #f0f0f0);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .food-detail-close {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .food-detail-favorite {
    background: rgba(0, 0, 0, 0.5);
    color: #888;
}

[data-theme="dark"] .food-detail-favorite.is-favorite {
    color: #e74c3c;
}

[data-theme="dark"] .food-detail-no-image {
    background: #2a2a2a;
}

[data-theme="dark"] .food-detail-allergens {
    background: rgba(231, 76, 60, 0.15);
}

[data-theme="dark"] .food-detail-allergens-list {
    color: #e88a82;
}

[data-theme="dark"] .food-detail-price-option {
    background: var(--bg-secondary, #2a2a2a);
}

[data-theme="dark"] .food-detail-price-option.selected {
    background: rgba(76, 175, 80, 0.15);
}

/* === MOBIL OVERRIDE - EGY SOROS FOOTER === */
@media (max-width: 768px) {
    .food-detail-footer {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 10px 12px !important;
    }
    
    .food-detail-quantity {
        display: flex !important;
        flex-direction: row !important;
        margin-bottom: 0 !important;
        gap: 6px !important;
    }
    
    .food-detail-qty-btn {
        width: 30px !important;
        height: 30px !important;
    }
    
    .food-detail-qty-value {
        min-width: 20px !important;
        font-size: 1rem !important;
    }
    
    .food-detail-add-btn {
        flex: 1 !important;
        padding: 10px 12px !important;
    }
    
    /* Árak egymás mellett */
    .food-detail-price-options {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .food-detail-price-option {
        flex: 1 1 45% !important;
        min-width: 0 !important;
        padding: 8px !important;
    }
}

/* Auto theme - rendszer dark mode preferencia esetén */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] .food-detail-modal {
        background: var(--card-background, #1e1e1e);
    }

    [data-theme="auto"] .food-detail-name {
        color: var(--text-primary, #f0f0f0);
    }

    [data-theme="auto"] .food-detail-name .item-number {
        color: var(--text-muted, #999);
    }

    [data-theme="auto"] .food-detail-description {
        color: var(--text-secondary, #b8b8b8);
    }

    [data-theme="auto"] .food-detail-single-price .unit {
        color: var(--text-muted, #999);
    }

    [data-theme="auto"] .food-detail-prices-title {
        color: var(--text-secondary, #b8b8b8);
    }

    [data-theme="auto"] .food-detail-price-label {
        color: var(--text-primary, #f0f0f0);
    }

    [data-theme="auto"] .food-detail-qty-value {
        color: var(--text-primary, #f0f0f0);
    }

    [data-theme="auto"] .food-detail-qty-btn {
        color: var(--text-primary, #f0f0f0);
        border-color: var(--border-color, #444);
    }

    [data-theme="auto"] .food-detail-close {
        background: rgba(255, 255, 255, 0.2);
    }

    [data-theme="auto"] .food-detail-favorite {
        background: rgba(0, 0, 0, 0.5);
        color: #888;
    }

    [data-theme="auto"] .food-detail-favorite.is-favorite {
        color: #e74c3c;
    }

    [data-theme="auto"] .food-detail-no-image {
        background: #2a2a2a;
    }

    [data-theme="auto"] .food-detail-allergens {
        background: rgba(231, 76, 60, 0.15);
    }

    [data-theme="auto"] .food-detail-allergens-list {
        color: #e88a82;
    }

    [data-theme="auto"] .food-detail-price-option {
        background: var(--bg-secondary, #2a2a2a);
    }

    [data-theme="auto"] .food-detail-price-option.selected {
        background: rgba(76, 175, 80, 0.15);
    }
}
