/* style.css */
body { font-family: 'Segoe UI', system-ui, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; background-color: #f0f2f5; color: #333; box-sizing: border-box; }
* { box-sizing: border-box; }

/* Navigace */
.nav-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 2px solid #ddd; padding-bottom: 0; overflow-x: auto; }
.nav-btn { padding: 12px 20px; border: none; background: #e0e0e0; cursor: pointer; font-size: 1rem; border-radius: 8px 8px 0 0; font-weight: bold; color: #555; white-space: nowrap; flex: 1; }
.nav-btn.active { background: #2c3e50; color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

/* Layout */
.container { display: flex; gap: 20px; align-items: flex-start; }
.panel { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); width: 100%; }
.editor-panel { flex: 6; }
.library-panel { flex: 4; max-height: 85vh; overflow-y: auto; }

/* Formuláře */
.input-group { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 15px; background: #f8f9fa; padding: 15px; border-radius: 10px; flex-wrap: wrap; }
label { font-size: 0.75rem; font-weight: bold; display: block; margin-bottom: 4px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { padding: 10px; border: 1px solid #ccc; border-radius: 6px; width: 100%; font-size: 16px; }
textarea { font-family: inherit; resize: vertical; min-height: 80px; }

/* Sekce Energie */
.energy-section { background: #fff8e1; border: 1px solid #ffe0b2; padding: 15px; border-radius: 10px; margin: 20px 0; }
.energy-header { font-weight: bold; margin-bottom: 15px; color: #f57c00; display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; }
.energy-inputs { display: flex; gap: 10px; }

/* Nutriční přehled */
.nutrition-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; font-size: 0.9rem; }
.nutri-box { flex: 1; background: #fff; border: 1px solid #ddd; padding: 8px; border-radius: 6px; text-align: center; min-width: 70px; }
.nutri-label { font-size: 0.7rem; color: #777; text-transform: uppercase; display: block; margin-bottom: 2px; }
.nutri-value { font-weight: bold; color: #333; }

/* --- TABULKY (VYLEPŠENO) --- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; border: 1px solid #eee; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 800px; /* Vynutí šířku, aby se nedeformovala */ }
th, td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
th { background: #f1f1f1; color: #555; font-size: 0.85rem; text-transform: uppercase; white-space: nowrap; }

/* Styly pro inputy uvnitř tabulky skladu */
.ing-row input { 
    width: 100%; 
    min-width: 70px; /* Větší šířka pro čísla */
    padding: 8px; 
    border: 1px solid transparent; 
    background: transparent; 
    font-size: 0.95rem;
    text-align: right; /* Čísla zarovnaná doprava */
}
.ing-row input:focus { border: 1px solid #3498db; background: white; border-radius: 4px; }
.ing-row input[type="text"] { text-align: left; min-width: 150px; font-weight: 500; }

/* Tlačítka */
button { padding: 12px 18px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: 0.2s; white-space: nowrap; font-size: 0.95rem; }
button:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-green { background: #27ae60; color: white; }
.btn-blue { background: #3498db; color: white; }
.btn-red { background: #e74c3c; color: white; padding: 6px 10px; font-size: 0.85rem; }
.btn-orange { background: #f39c12; color: white; padding: 6px 10px; font-size: 0.85rem; }

/* Status bar */
.status-bar { margin-bottom: 20px; padding: 15px; border-radius: 8px; text-align: center; font-weight: bold; display: none; position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; width: 90%; max-width: 400px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.status-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Seznam receptů */
.recipe-item { border-bottom: 1px solid #eee; padding: 15px 0; display: flex; justify-content: space-between; align-items: center; }
.recipe-item div:first-child { padding-right: 10px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.recipe-card { background: white; width: 100%; max-width: 600px; padding: 30px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); position: relative; max-height: 90vh; overflow-y: auto; }
.close-modal { position: absolute; top: 10px; right: 15px; font-size: 2rem; cursor: pointer; color: #999; }
.print-btn { display: block; width: 100%; margin-top: 20px; padding: 15px; background: #34495e; color: white; text-align: center; }

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
    body { padding: 10px; padding-bottom: 80px; } 
    .container { flex-direction: column; } 
    .panel { width: 100%; margin-bottom: 20px; padding: 15px; }
    .input-group { flex-direction: column; gap: 10px; }
    .input-group > div { width: 100%; }
    .energy-inputs { flex-direction: column; }
    .energy-header { flex-direction: column; align-items: flex-start; gap: 5px; }
    
    /* Na mobilu skryjeme méně důležité sloupce v přehledu receptů, pokud by zavazely, 
       ale pro tabulku skladu necháme scrollování */
    
    .recipe-item { flex-direction: column; align-items: flex-start; }
    .recipe-item > div { width: 100%; }
    .recipe-item button { flex: 1; display: inline-block; margin: 5px 2px; }
    .modal-overlay { padding: 0; }
    .recipe-card { height: 100%; max-height: 100vh; border-radius: 0; padding: 20px; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media print { body * { visibility: hidden; } .modal-overlay, .recipe-card, .recipe-card * { visibility: visible; } .modal-overlay { position: absolute; left: 0; top: 0; background: white; } .print-btn, .close-modal { display: none; } }

/* --- ODSTRANĚNÍ ŠIPEK (SPINNERŮ) U ČÍSEL --- */

/* Pro Firefox */
input[type=number] {
  -moz-appearance: textfield;
}

/* Pro Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* --- OPRAVA MODÁLNÍHO OKNA (RESPONSIVITA + VLÁKNINA) --- */

/* Tabulka uvnitř karty receptu se musí chovat jinak než ta ve skladu */
.recipe-card table {
    min-width: auto !important; /* Zruší vynucenou šířku */
    width: 100%;
    table-layout: fixed; /* Zajistí, že sloupce nepřetečou */
}

.recipe-card td, .recipe-card th {
    padding: 8px 5px; /* Menší padding pro mobil */
    font-size: 0.95rem;
    white-space: normal; /* Povolit zalamování textu */
    vertical-align: top;
}

/* Sloupec s názvem bude mít přednost */
.recipe-card td:first-child {
    width: 50%;
    font-weight: 500;
}

/* Sloupce s čísly zarovnáme doprava a dáme jim pevnou šířku */
.recipe-card td:nth-child(2),
.recipe-card td:nth-child(3) {
    text-align: right;
    width: 25%;
    white-space: nowrap; /* Čísla a jednotky nezalamovat */
}

/* Nutriční boxy - aby se vláknina vlezla */
.nutrition-summary {
    justify-content: center;
}
.nutri-box {
    min-width: 60px; /* Zmenšeno, aby se jich vešlo 5 vedle sebe */
    padding: 5px;
}

/* --- VYLEPŠENÍ TLAČÍTEK V SEZNAMU RECEPTŮ --- */
.recipe-item div:last-child {
    display: flex;
    gap: 8px;
}

/* --- VYLEPŠENÍ ZOBRAZENÍ ENERGIE (DETAIL) --- */
.card-energy-box {
    margin-top: 15px;
    padding: 15px;
    background: #fff3e0; /* Jemná oranžová */
    border: 1px solid #ffe0b2;
    border-radius: 8px;
    color: #e65100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.energy-icon { font-size: 1.5rem; margin-right: 10px; }
.energy-details { display: flex; flex-direction: column; font-size: 0.9rem; color: #f57c00; }
.energy-price-tag { font-size: 1.3rem; font-weight: bold; color: #e65100; }

/* --- STYL PRO MARKDOWN POZNÁMKU --- */
.card-comment-box { 
    margin-top: 20px; 
    padding: 15px; 
    background: #f8f9fa; 
    border-left: 4px solid #3498db; 
    color: #444;
    line-height: 1.6;
}
/* Aby seznamy a odstavce v Markdownu vypadaly hezky */
.card-comment-box ul, .card-comment-box ol { margin: 10px 0; padding-left: 20px; }
.card-comment-box p { margin-bottom: 10px; }
.card-comment-box p:last-child { margin-bottom: 0; }
.card-comment-box strong { color: #2c3e50; }

/* --- MOBILE OPTIMIZATION (Upraveno) --- */
@media (max-width: 768px) {
    /* ... (předchozí styly nechej) ... */

    /* 1. Tlačítka v seznamu receptů - VELKÁ PRO PALEC */
    .recipe-item { flex-direction: column; align-items: flex-start; padding-bottom: 15px; }
    .recipe-item > div { width: 100%; }
    
    /* Kontejner pro tlačítka na mobilu */
    .recipe-item div:last-child { 
        margin-top: 10px; 
        border-top: 1px solid #f0f0f0; 
        padding-top: 10px; 
        display: flex; 
        gap: 10px; 
    }
    
    /* Samotná tlačítka - roztažená na 50% každé a vysoká */
    .recipe-item button { 
        flex: 1; 
        padding: 12px 0; 
        font-size: 1rem; 
        margin: 0; 
        height: 44px; /* Minimální doporučená výška pro dotyk */
    }

    /* 2. Energie v detailu na mobilu */
    .card-energy-box {
        flex-direction: row; /* Necháme vedle sebe, pokud se vejde */
        align-items: center;
        padding: 12px;
    }
    .energy-details { font-size: 0.85rem; }
    .energy-price-tag { font-size: 1.1rem; }
}


/* Přidej do style.css */

.btn-edit { 
    background-color: #3498db; 
    color: white; 
    padding: 6px 12px; 
    font-size: 0.85rem; 
    margin-right: 5px;
}

.btn-cancel {
    background-color: #95a5a6;
    color: white;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    display: none; /* Ve výchozím stavu skryté */
}

/* Úprava pro mobil, aby se tlačítka vlezla vedle seba */
@media (max-width: 768px) {
    .recipe-actions {
        display: flex;
        gap: 5px;
        width: 100%;
    }
    .recipe-actions button {
        flex: 1;
        padding: 12px 0;
        margin: 0;
        height: 44px;
    }
}