/* ==========================================================================
   NutriTrack Custom Styles
   ========================================================================== */

:root {
    color-scheme: dark;
}

body {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

input, textarea, select {
    user-select: auto;
}

/* Plynulé animace a touch cíle */
button, input, select, textarea {
    touch-action: manipulation;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Rodičovské kontejnery jídel nesmí ořezávat dropdown našeptávače (overflow nesmí být hidden ani scroll/auto) */
#meals-container,
#meals-container > div,
.meal-card,
.card {
    overflow: visible !important;
}

.flex:has(select):has(button),
.flex:has(.food-combobox-wrapper):has(button) {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
}

.flex:has(select):has(button) select {
    flex: 1 1 140px !important;
    min-width: 0 !important;
}

.food-combobox-wrapper,
.choices {
    position: relative !important;
    flex: 1 1 160px !important;
    min-width: 0 !important;
}

.food-combobox-wrapper:focus-within,
.food-combobox-wrapper:has(.food-combobox-dropdown:not(.hidden)) {
    z-index: 50;
}

.flex:has(select):has(button) input[type="number"],
.flex:has(.food-combobox-wrapper):has(button) input[type="number"] {
    width: 70px !important;
    flex-shrink: 0 !important;
}

.flex:has(select):has(button) button,
.flex:has(.food-combobox-wrapper):has(button) button {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

/* ==========================================================================
   Fulltext Combobox Našeptávač surovin & Choices.js dropdown
   ========================================================================== */
.food-combobox-dropdown,
.choices__list--dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 50 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}

.food-combobox-dropdown::-webkit-scrollbar {
    width: 6px;
}

.food-combobox-dropdown::-webkit-scrollbar-track {
    background: #0f172a;
}

.food-combobox-dropdown::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.food-combobox-item {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.food-combobox-item:hover,
.food-combobox-item.active {
    background-color: rgba(30, 41, 59, 0.95); /* slate-800 */
}

.food-combobox-item.active .food-name-text,
.food-combobox-item:hover .food-name-text {
    color: #34d399; /* emerald-400 */
}

/* ==========================================================================
   Tlačítka Akce: Upravit & Smazat
   ========================================================================== */

.btn-delete, button.btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 64px;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: #f87171; /* decentní červený text */
    background-color: rgba(239, 68, 68, 0.12); /* jemný červený tón */
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-delete:hover, button.btn-delete:hover {
    background-color: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fecaca;
    box-shadow: 0 1px 3px 0 rgba(239, 68, 68, 0.2);
}

.btn-delete:active, button.btn-delete:active {
    background-color: rgba(239, 68, 68, 0.4);
    transform: scale(0.97);
}

.btn-edit, button.btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 58px;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    background-color: rgba(51, 65, 85, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.6);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-edit:hover, button.btn-edit:hover {
    background-color: rgba(71, 85, 105, 0.8);
    color: #f8fafc;
}

/* ==========================================================================
   Formátování a paddingy tabulky katalogu surovin
   ========================================================================== */

.foods-table,
#foods-table,
#dashboard-foods-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.8125rem;
}

/* Kompaktní padding buněk tabulky (th, td) */
.foods-table th,
#foods-table th,
#dashboard-foods-table th {
    padding: 8px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.foods-table td,
#foods-table td,
#dashboard-foods-table td {
    padding: 8px 10px;
    vertical-align: middle;
    font-size: 0.8125rem;
}

/* Zarovnání sloupců shodně s hodnotami */
.foods-table th.col-name,
.foods-table td.col-name,
.foods-table th:first-child,
.foods-table td:first-child {
    text-align: left;
}

.foods-table th.col-unit,
.foods-table td.col-unit {
    text-align: right;
    white-space: nowrap;
}

.foods-table th.col-num,
.foods-table td.col-num {
    text-align: right;
    white-space: nowrap;
}

/* Sloupec 'Akce' zarovnaný doprava, pevná minimální šířka s flex gapem */
.foods-table th.col-actions,
.foods-table td.col-actions,
.foods-table th:last-child,
.foods-table td:last-child {
    text-align: right;
    min-width: 140px;
    width: 140px;
    white-space: nowrap;
}

.action-buttons,
.foods-table td .action-buttons,
.foods-table td:last-child > div {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 140px;
}

/* ==========================================================================
   Responzivní šířka kontejneru pro PC / Desktop (min-width: 768px)
   Povoluje šířku 900px až 1100px (max-width: 95%), aby se všech 8 sloupců
   vešlo vedle sebe bez horizontálního overflow-x / scrollu.
   ========================================================================== */

@media (min-width: 768px) {
    main,
    body > main,
    header > div,
    nav > div {
        max-width: 1050px !important;
        width: 95% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Obalovací prvek tabulky surovin na desktopu bez nutnosti horizontálního posouvání */
    .catalog-table-container,
    .foods-table-wrapper,
    .overflow-x-auto:has(.foods-table),
    .overflow-x-auto:has(#foods-table),
    #foods-catalog-section .overflow-x-auto {
        max-width: 100% !important;
        overflow-x: visible !important;
    }

    .foods-table,
    #foods-table,
    #dashboard-foods-table {
        table-layout: auto;
        width: 100% !important;
    }
}

/* ==========================================================================
   Mobilní zobrazení (max-width: 767px)
   Plynulý horizontální scroll a kompaktní paddingy pro telefony
   ========================================================================== */

@media (max-width: 767px) {
    main {
        max-width: 100% !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .catalog-table-container,
    .foods-table-wrapper,
    .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .foods-table th,
    .foods-table td,
    #foods-table th,
    #foods-table td {
        padding: 6px 8px;
    }

    .foods-table th.col-actions,
    .foods-table td.col-actions,
    .foods-table th:last-child,
    .foods-table td:last-child {
        min-width: 135px;
        width: 135px;
    }

    .action-buttons,
    .foods-table td:last-child > div {
        gap: 0.375rem;
        min-width: 135px;
    }
}

/* ==========================================================================
   Modální okno profilu - robustní explicitní výška pro mobilní zařízení
   ========================================================================== */

#profile-modal {
    overflow-y: auto;
}

#profile-form {
    max-height: calc(85vh - 4rem);
    overflow-y: auto;
    min-height: 0;
    width: 100%;
}

/* ==========================================================================
   7denní kalorická banka - responzivní chování a ochrana proti kolizím
   ========================================================================== */
#calorie-bank-wrapper {
    width: 100%;
}

#calorie-bank-wrapper.hidden,
#calorie-bank-badge.hidden {
    display: none !important;
}

#calorie-bank-badge {
    max-width: 100%;
    word-break: break-word;
}

/* ==========================================================================
   Modální okno Changelog - jednotný design a plynulý scroll
   ========================================================================== */
#changelog-modal {
    overflow-y: auto;
}

#changelog-body {
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}





