/* planning.css v2 */
@import url("theme.css");

/* ═══════════════════════════════
   サブナビ
═══════════════════════════════ */
.pl-subnav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--secondary-bg);
    border-bottom: 1px solid rgba(0,0,0,0.07);
    position: sticky;
    top: 50px;
    z-index: 900;
    min-height: 48px;
    box-sizing: border-box;
    flex-wrap: wrap;
}
@media (max-width: 768px) { .pl-subnav { top: 100px; } }

.pl-subnav-period {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.pl-date-input {
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 0.88rem;
    background: var(--primary-bg);
    color: var(--text-color);
    font-family: inherit;
    height: 34px;
    box-sizing: border-box;
}

.pl-days-input {
    width: 58px;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 8px;
    padding: 5px 6px;
    font-size: 0.88rem;
    background: var(--primary-bg);
    color: var(--text-color);
    font-family: inherit;
    height: 34px;
    box-sizing: border-box;
    text-align: center;
}

.pl-sep { font-size: 0.85rem; opacity: 0.55; }
.pl-days-label { font-size: 0.82rem; opacity: 0.65; white-space: nowrap; }

.pl-subnav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pl-btn-icon {
    background: none;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-color);
    transition: background 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pl-btn-icon:hover, .pl-btn-icon.active {
    background: var(--container-transparent);
    border-color: var(--accent-color);
}

.pl-btn-secondary {
    background: none;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50px;
    padding: 0 14px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-color);
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    height: 36px;
}
.pl-btn-secondary:hover {
    background: var(--container-transparent);
    border-color: var(--accent-color);
}

.pl-btn-primary {
    background: var(--accent-color);
    border: none;
    border-radius: 50px;
    padding: 0 18px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    white-space: nowrap;
    transition: opacity 0.15s;
    height: 36px;
}
.pl-btn-primary:hover { opacity: 0.85; }

/* ═══════════════════════════════
   ページ
═══════════════════════════════ */
.pl-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 16px 16px 100px;
    box-sizing: border-box;
}

/* ═══════════════════════════════
   設定パネル
═══════════════════════════════ */
.pl-settings-panel {
    display: none;
    margin-bottom: 16px;
}
.pl-settings-panel.open { display: block; }

.pl-card {
    background: var(--section-bg);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 18px 20px;
    margin-bottom: 14px;
    overflow: visible;
}

.pl-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pl-hint {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.5;
}

/* ── 食事パターン ── */
.pl-pattern-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pl-pattern-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pl-meal-label {
    font-size: 0.86rem;
    font-weight: 700;
    min-width: 70px;
    flex-shrink: 0;
}
.pl-breakfast { color: #2e7d32; }
.pl-lunch     { color: #f57f17; }
.pl-dinner    { color: #6a1b9a; }

.pl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pl-chip {
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50px;
    padding: 4px 12px;
    font-size: 0.82rem;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.pl-chip.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
    font-weight: 600;
}
.pl-chip:hover:not(.active) {
    border-color: var(--accent-color);
    background: var(--container-transparent);
}

/* ── 制約条件タブ ── */
.pl-tabs {
    display: flex;
    border-bottom: 2px solid rgba(0,0,0,0.07);
    margin-bottom: 16px;
    gap: 0;
}

.pl-tab {
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    padding: 8px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.5;
    font-family: inherit;
    transition: opacity 0.15s, border-color 0.15s, color 0.15s;
    margin-bottom: -2px;
    white-space: nowrap;
}
.pl-tab.active {
    opacity: 1;
    border-bottom-color: var(--accent-color);
    color: var(--accent-color);
}
.pl-tab:hover:not(.active) { opacity: 0.75; }

.pl-tab-pane { display: none; }
.pl-tab-pane.active { display: block; }

/* ── 数値制限 ── */
.pl-limits {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--primary-bg);
    border-radius: 10px;
}

.pl-limit-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-color);
    flex: 1;
    min-width: 170px;
}

.pl-limit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pl-limit-input {
    width: 78px;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.9rem;
    background: var(--section-bg);
    color: var(--text-color);
    font-family: inherit;
    text-align: right;
    height: 32px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.pl-limit-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.pl-limit-unit {
    font-size: 0.74rem;
    opacity: 0.55;
    white-space: nowrap;
    font-weight: 400;
}

/* ── タグフィールド ── */
.pl-tag-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pl-tag-block {
    border: 1.5px solid rgba(0,0,0,0.07);
    border-radius: 10px;
    padding: 12px 14px;
}

.pl-tag-block-label {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pl-tag-search {
    width: 100%;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.88rem;
    background: var(--primary-bg);
    color: var(--text-color);
    font-family: inherit;
    height: 34px;
    box-sizing: border-box;
    transition: border-color 0.15s;
    margin-bottom: 6px;
}
.pl-tag-search:focus {
    outline: none;
    border-color: var(--accent-color);
}

.pl-autocomplete {
    list-style: none;
    padding: 4px 0;
    margin: 0 0 8px;
    background: var(--section-bg);
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    max-height: 160px;
    overflow-y: auto;
    position: relative;
    z-index: 200;
}

.pl-autocomplete li {
    padding: 7px 12px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-color);
    transition: background 0.1s;
}
.pl-autocomplete li:hover {
    background: var(--container-transparent);
    color: var(--accent-color);
}

.pl-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 18px;
}

.pl-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-color);
    color: #fff;
    border-radius: 50px;
    padding: 3px 10px 3px 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pl-tag-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    transition: color 0.1s;
}
.pl-tag-remove:hover { color: #fff; }

/* ── 設定フッター ── */
.pl-settings-footer {
    display: flex;
    justify-content: flex-end;
    padding: 2px 0 6px;
}

.pl-save-btn {
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 28px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}
.pl-save-btn:hover { opacity: 0.85; }

/* ═══════════════════════════════
   計画グリッド
═══════════════════════════════ */
.pl-grid-section { margin-top: 4px; }

.pl-grid-placeholder {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-color);
    opacity: 0.45;
}
.pl-placeholder-icon { font-size: 3rem; margin-bottom: 14px; }
.pl-grid-placeholder p { font-size: 0.9rem; line-height: 1.7; }

.pl-grid-scroll {
    overflow-x: auto;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.pl-grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--section-bg);
    table-layout: fixed;
}

.pl-grid thead th {
    background: var(--primary-bg);
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-color);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid rgba(0,0,0,0.07);
    white-space: nowrap;
}
.pl-col-date { width: 72px; }
.pl-col-meal { width: calc((100% - 72px) / 3); }

.pl-grid tbody tr {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: background 0.1s;
}
.pl-grid tbody tr:last-child { border-bottom: none; }
.pl-grid tbody tr:hover { background: var(--container-transparent); }

.pl-date-cell {
    padding: 10px 10px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-color);
    vertical-align: top;
    white-space: nowrap;
    border-right: 1px solid rgba(0,0,0,0.05);
}

.pl-date-dow {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.55;
    display: block;
}
.pl-date-dow.sun { color: #e53935; opacity: 1; }
.pl-date-dow.sat { color: #1976d2; opacity: 1; }

.pl-meal-cell {
    padding: 8px 10px;
    vertical-align: top;
    border-right: 1px solid rgba(0,0,0,0.04);
    position: relative;
}
.pl-meal-cell:last-child { border-right: none; }

.pl-meal-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 4px;
}

.pl-meal-item {
    font-size: 0.81rem;
    color: var(--text-color);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.pl-meal-cat {
    font-size: 0.7rem;
    flex-shrink: 0;
}

.pl-meal-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.pl-meal-empty {
    font-size: 0.78rem;
    color: var(--text-color);
    opacity: 0.3;
    font-style: italic;
}

.pl-cell-actions { margin-top: 4px; }

.pl-reroll-btn {
    background: none;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 0.73rem;
    cursor: pointer;
    color: var(--text-color);
    font-family: inherit;
    opacity: 0;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.pl-meal-cell:hover .pl-reroll-btn,
.pl-meal-cell:focus-within .pl-reroll-btn { opacity: 1; }
.pl-reroll-btn:hover {
    border-color: var(--accent-color);
    background: var(--container-transparent);
    color: var(--accent-color);
}
@media (hover: none) { .pl-reroll-btn { opacity: 0.65; } }

.pl-grid-footer {
    display: flex;
    justify-content: flex-end;
    padding: 14px 0 4px;
}

.pl-commit-btn {
    background: none;
    border: 1.5px solid var(--accent-color);
    border-radius: 50px;
    padding: 8px 22px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--accent-color);
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.pl-commit-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

/* ═══════════════════════════════
   候補選択モーダル
═══════════════════════════════ */
.pl-modal {
    background: var(--section-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: min(540px, 92vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pl-modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    flex-shrink: 0;
}

.pl-modal-title {
    font-size: 0.98rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    color: var(--text-color);
}

.pl-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.45;
    padding: 0;
    line-height: 1;
    transition: opacity 0.15s;
}
.pl-modal-close:hover { opacity: 1; }

.pl-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.pl-candidate-group { margin-bottom: 18px; }
.pl-candidate-group-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.pl-candidate-item {
    background: var(--primary-bg);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.pl-candidate-info { flex: 1; min-width: 0; }
.pl-candidate-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pl-candidate-meta {
    font-size: 0.74rem;
    color: var(--text-color);
    opacity: 0.55;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pl-candidate-select {
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.pl-candidate-select:hover { opacity: 0.85; }

/* ═══════════════════════════════
   音声FAB・オーバーレイ
═══════════════════════════════ */
.pl-voice-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 1.4rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.22);
    z-index: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pl-voice-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.pl-voice-fab.recording {
    background: #e53935;
    animation: pl-pulse 1s ease-in-out infinite;
}

@keyframes pl-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 14px rgba(229,57,53,0.4); }
    50% { transform: scale(1.12); box-shadow: 0 6px 24px rgba(229,57,53,0.65); }
}

.pl-voice-modal {
    background: var(--section-bg);
    border-radius: 20px;
    padding: 32px 28px 24px;
    width: min(360px, 90vw);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.pl-voice-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    animation: pl-pulse 1.2s ease-in-out infinite;
}

.pl-voice-status {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 8px;
}

.pl-voice-transcript {
    min-height: 44px;
    font-size: 1.05rem;
    color: var(--accent-color);
    font-weight: 600;
    margin: 0 0 14px;
    word-break: break-all;
    line-height: 1.5;
}

.pl-voice-hint {
    background: var(--primary-bg);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 18px;
}
.pl-voice-hint p {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.6;
    margin: 0;
    line-height: 1.6;
    text-align: left;
}

.pl-voice-cancel {
    background: none;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50px;
    padding: 8px 24px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-color);
    font-family: inherit;
    transition: border-color 0.15s;
}
.pl-voice-cancel:hover { border-color: var(--accent-color); }

/* ═══════════════════════════════
   Toast
═══════════════════════════════ */
.pl-toast {
    position: fixed;
    bottom: 92px;
    right: 24px;
    background: rgba(30,30,30,0.92);
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.87rem;
    z-index: 9999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    max-width: 300px;
    line-height: 1.45;
}
.pl-toast.show { opacity: 1; transform: translateY(0); }

/* ═══════════════════════════════
   ローディング
═══════════════════════════════ */
.pl-loading-box {
    background: var(--section-bg);
    border-radius: 16px;
    padding: 28px 40px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.pl-loading-box p {
    font-size: 0.9rem;
    color: var(--text-color);
    margin: 12px 0 0;
}

.pl-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: pl-spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════
   モバイル
═══════════════════════════════ */

/* 480px以下：期間を全幅にしてアクションを次行へ折り返す */
@media (max-width: 480px) {
    .pl-subnav { padding: 6px 10px; gap: 4px; }
    .pl-subnav-period {
        flex: 0 0 100%;   /* 全幅 → actions が次行へ */
        gap: 4px;
    }
    .pl-subnav-actions {
        margin-left: auto;
        gap: 6px;
    }
    .pl-btn-secondary { padding: 0 10px; font-size: 0.82rem; }
    .pl-btn-primary   { padding: 0 14px; }
}

@media (max-width: 640px) {
    .pl-page { padding: 12px 12px 100px; }
    .pl-days-label { display: none; }

    /* グリッドをカード形式に */
    .pl-grid, .pl-grid thead, .pl-grid tbody,
    .pl-grid tr, .pl-grid th, .pl-grid td { display: block; }
    .pl-grid thead tr { display: none; }

    .pl-grid tbody tr {
        background: var(--section-bg);
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.07);
        margin-bottom: 10px;
        border: none;
    }

    .pl-date-cell {
        background: var(--primary-bg);
        border-radius: 12px 12px 0 0;
        padding: 8px 14px;
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.06);
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .pl-date-dow { display: inline; }

    .pl-meal-cell {
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        padding: 10px 14px;
    }
    .pl-meal-cell:last-child { border-bottom: none; }
    .pl-meal-cell::before {
        content: attr(data-label);
        font-size: 0.74rem;
        font-weight: 700;
        opacity: 0.5;
        display: block;
        margin-bottom: 5px;
    }

    .pl-reroll-btn { opacity: 0.65; }
    .pl-pattern-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .pl-limits { flex-direction: column; }
    .pl-limit-label { min-width: unset; }
}
