@import url("theme.css");

/* ── Layout ─────────────────────────────────────────── */
.inv-page {
    padding: 12px 16px;
    max-width: 100%;
}

/* ── Subnav ──────────────────────────────────────────── */
.inv-subnav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--section-bg, #fff);
    border-bottom: 1px solid var(--border-color, #ddd);
    position: sticky;
    top: 50px;
    z-index: 100;
    flex-wrap: wrap;
}
@media (max-width: 767px) {
    .inv-subnav { top: 100px; gap: 6px; padding: 6px 10px; }
}

/* ── Tabs ────────────────────────────────────────────── */
.inv-tabs {
    display: flex;
    gap: 4px;
}
.inv-tab {
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #ccc);
    background: transparent;
    color: var(--text-color, #333);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.inv-tab.active {
    background: var(--accent-color, #0070f3);
    color: #fff;
    border-color: var(--accent-color, #0070f3);
}
.inv-tab:hover:not(.active) {
    background: var(--secondary-bg, #f5f5f5);
}

/* ── Badge ───────────────────────────────────────────── */
.inv-badge {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
    margin-left: 5px;
    vertical-align: middle;
}
.inv-badge:empty { display: none; }

/* ── Tab Actions ─────────────────────────────────────── */
.inv-tab-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
    flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────── */
.inv-btn-primary, .inv-btn-secondary, .inv-btn-danger, .inv-btn-icon {
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.inv-btn-primary {
    background: var(--accent-color, #0070f3);
    color: #fff;
}
.inv-btn-secondary {
    background: var(--secondary-bg, #f0f0f0);
    color: var(--text-color, #333);
    border: 1px solid var(--border-color, #ccc);
}
.inv-btn-danger {
    background: #ef4444;
    color: #fff;
}
.inv-btn-icon {
    background: transparent;
    color: var(--text-color, #333);
    font-size: 15px;
    padding: 4px 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 6px;
}
.inv-btn-primary:hover, .inv-btn-secondary:hover, .inv-btn-danger:hover, .inv-btn-icon:hover {
    opacity: 0.8;
}
.inv-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Accordion ───────────────────────────────────────── */
.accordion {
    background: var(--accent-color, #007BFF);
    color: #fff;
    cursor: pointer;
    padding: 12px 16px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 16px;
    border-radius: 6px;
    margin-top: 8px;
    margin-bottom: 4px;
    transition: background 0.2s;
}
.accordion:hover, .accordion.active {
    background: var(--accent-hover, #0056b3);
}

/* ── Table ───────────────────────────────────────────── */
.ingredientTableContainer {
    overflow-x: auto;
    margin-bottom: 8px;
}
.table-scroll-wrapper {
    overflow-x: auto;
    width: 100%;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
}
th, td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: center;
    white-space: nowrap;
}
th { background: var(--secondary-bg, #f5f5f5); font-weight: 600; }

input[type="number"],
input[type="text"] {
    width: 50px;
    padding: 2px 4px;
    border: 0;
    border-radius: 4px;
    font-size: 13px;
    background: transparent;
}
.name > input { width: 140px; }
select {
    width: 80px;
    padding: 2px 4px;
    border: 0;
    border-radius: 4px;
    font-size: 13px;
    background: transparent;
}

/* ── Suggestion Box ──────────────────────────────────── */
.suggestion-box {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    min-width: 150px;
    max-width: 250px;
    list-style: none;
    padding: 4px;
    margin: 0;
    z-index: 1000;
    max-height: 150px;
    overflow-y: auto;
    display: none;
    white-space: nowrap;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.suggestion-item {
    padding: 4px 6px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
}
.suggestion-item:hover { background: #f1f1f1; }

/* ── Column Visibility ───────────────────────────────── */
.hidden-column { display: none !important; }
.missing-ingredient-master input { background: #ffe5e5 !important; }

/* ── UIkit modal override ────────────────────────────── */
.uk-modal-dialog { max-width: 520px; }
#columnSettings label { font-size: 13px; }

/* ── Wizard ──────────────────────────────────────────── */
#inv-pane-wizard {
    padding: 0 8px;
}

.inv-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0 16px;
}
.inv-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.inv-prog-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-bg, #e5e5e5);
    color: var(--text-muted, #888);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}
.inv-progress-step.active .inv-prog-dot {
    background: var(--accent-color, #0070f3);
    color: #fff;
}
.inv-progress-step.done .inv-prog-dot {
    background: #22c55e;
    color: #fff;
}
.inv-prog-label {
    font-size: 11px;
    color: var(--text-muted, #888);
}
.inv-progress-step.active .inv-prog-label {
    color: var(--accent-color, #0070f3);
    font-weight: 600;
}
.inv-progress-line {
    flex: 1;
    height: 2px;
    background: var(--border-color, #ddd);
    margin-bottom: 18px;
    min-width: 48px;
    max-width: 80px;
}

.inv-wiz-pane {
    max-width: 640px;
    margin: 0 auto;
}
.inv-wiz-header { margin-bottom: 16px; }
.inv-wiz-header h3 { margin: 0 0 4px; font-size: 18px; }
.inv-wiz-header p { margin: 0; color: var(--text-muted, #666); font-size: 13px; }

/* Scan result */
.inv-scan-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}
.inv-scan-card {
    background: var(--section-bg, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 10px;
    padding: 20px 16px;
    text-align: center;
}
.inv-scan-num {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
}
.inv-scan-label {
    font-size: 12px;
    color: var(--text-muted, #666);
    margin-top: 4px;
}
.inv-scan-card.ok { border-color: #22c55e; }
.inv-scan-card.ok .inv-scan-num { color: #22c55e; }
.inv-scan-card.warn { border-color: #f59e0b; }
.inv-scan-card.warn .inv-scan-num { color: #f59e0b; }
.inv-scan-empty {
    text-align: center;
    padding: 24px 16px 8px;
    color: var(--text-muted, #666);
    font-size: 14px;
}
.inv-scan-icon { font-size: 40px; margin-bottom: 8px; }

/* Wizard step 2 items */
.inv-wiz-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px 0;
}
.inv-wiz-item {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 8px;
    align-items: center;
    background: var(--section-bg, #fff);
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 8px;
    padding: 10px 12px;
    transition: opacity 0.2s;
}
.inv-wiz-item.excluded { opacity: 0.4; }
.inv-wiz-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}
.inv-wiz-item input[type="text"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 5px;
    font-size: 13px;
    background: var(--primary-bg, #fff);
}
.inv-wiz-item select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 5px;
    font-size: 13px;
    background: var(--primary-bg, #fff);
}
@media (max-width: 600px) {
    .inv-wiz-item {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }
    .inv-wiz-item select { grid-column: 2; }
}

/* Wizard step 3 confirm */
.inv-wiz-summary {
    font-size: 14px;
    color: var(--text-muted, #555);
    margin: 0 0 12px;
}
.inv-wiz-confirm-list {
    background: var(--section-bg, #f9f9f9);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    overflow: hidden;
    margin: 0 0 12px;
}
.inv-wiz-confirm-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color, #eee);
    font-size: 13px;
}
.inv-wiz-confirm-row:last-child { border-bottom: none; }
.inv-wiz-confirm-name { font-weight: 600; flex: 1; }
.inv-wiz-confirm-cat {
    color: var(--text-muted, #666);
    font-size: 11px;
    background: var(--secondary-bg, #f0f0f0);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Wizard footer */
.inv-wiz-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #eee);
}

/* ── Blocked Modal ───────────────────────────────────── */
#blockedModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.inv-blocked-inner {
    background: var(--primary-bg, #fff);
    border-radius: 10px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.inv-blocked-inner h5 { margin: 0 0 12px; font-size: 16px; }

/* ── 食材マスターテーブル 列幅 ──────────────────────────── */
#master-ingredient-table {
    table-layout: fixed;
    width: 100%;
}
#master-ingredient-table th,
#master-ingredient-table td {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
}
/* 選択チェックボックス */
#master-ingredient-table th:first-child,
#master-ingredient-table td:first-child { width: 36px; text-align: center; }
/* 食材名 */
#master-ingredient-table .name { width: 180px; }
#master-ingredient-table .name .ingredient-input { width: 100%; min-width: 0; box-sizing: border-box; }
/* カテゴリー */
#master-ingredient-table .category { width: 160px; }
#master-ingredient-table .category .category-select { width: 100%; min-width: 0; box-sizing: border-box; }
/* 単位 */
#master-ingredient-table .unit { width: 72px; }
#master-ingredient-table .unit select { width: 100%; min-width: 0; box-sizing: border-box; }
/* 基準重量・重量タイプ */
#master-ingredient-table .weight_g { width: 80px; }
#master-ingredient-table .weight_g input { width: 100%; min-width: 0; box-sizing: border-box; }
#master-ingredient-table .weight_type { width: 72px; }
#master-ingredient-table .weight_type select { width: 100%; min-width: 0; box-sizing: border-box; }
/* 栄養素数値列（残りを均等分割） */
#master-ingredient-table .energy_kcal,
#master-ingredient-table .protein_g,
#master-ingredient-table .fat_g,
#master-ingredient-table .carbohydrates_g,
#master-ingredient-table .salt_equivalent_g { width: 72px; }
#master-ingredient-table .energy_kcal input,
#master-ingredient-table .protein_g input,
#master-ingredient-table .fat_g input,
#master-ingredient-table .carbohydrates_g input,
#master-ingredient-table .salt_equivalent_g input { width: 100%; min-width: 0; box-sizing: border-box; }

/* ── 文科省DB列 ──────────────────────────────────────── */
#master-ingredient-table .fooddb-col { width: 60px; text-align: center; }

/* ── Spinner ─────────────────────────────────────────── */
.inv-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: inv-spin 0.8s linear infinite;
}
@keyframes inv-spin { to { transform: rotate(360deg); } }
