/* ═══════════════════════════════════════════
   Menu Story — Stitch Premium Dark Theme
   ═══════════════════════════════════════════ */
:root {
    --bg: #0a0f1e;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.08);
    --border-accent: rgba(56,189,248,0.35);
    --text: #f1f5f9;
    --text-muted: #64748b;
    --text-sub: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-emerald: #34d399;
    --accent-amber: #fbbf24;
    --accent-rose: #fb7185;
    --glow-blue: rgba(56,189,248,0.15);
    --glow-emerald: rgba(52,211,153,0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 24px rgba(56,189,248,0.2);
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56,189,248,0.07) 0%, transparent 60%);
    color: var(--text);
    font-family: 'Inter', 'Noto Serif KR', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── App Wrapper ── */
.app-wrapper {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ── Icon Buttons ── */
.icon-btn {
    background: rgba(15,23,42,0.8);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition);
}
.icon-btn:hover { background: rgba(56,189,248,0.1); border-color: var(--border-accent); }
.icon-btn.top-right { position: fixed; top: 20px; right: 20px; z-index: 200; }

/* ── 손님 언어 선택 (각 손님이 본인 휴대폰에서 선택) ── */
.lang-switcher {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 250;
    background: rgba(15,23,42,0.85);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.88em;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2394a3b8' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition);
}
.lang-switcher:hover,
.lang-switcher:focus {
    border-color: var(--border-accent);
}
.lang-switcher option {
    background: #1e293b;
    color: var(--text);
}

/* ── Context Header ── */
.context-header {
    padding: 72px 0 20px;
    text-align: center;
}
.context-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9em;
}
.weather-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56,189,248,0.12);
    color: var(--accent-blue);
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 0.9em;
    font-weight: 600;
    border: 1px solid rgba(56,189,248,0.25);
    margin-bottom: 12px;
    backdrop-filter: blur(4px);
}
.header-greeting {
    color: var(--text-sub);
    font-size: 0.95em;
}

/* ── Store Info ── */
.store-info {
    text-align: center;
    padding: 16px 0 24px;
}
.store-name {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.8em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}
.store-tagline {
    color: var(--text-muted);
    font-size: 0.9em;
    font-style: italic;
}

/* ── Menu List ── */
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Menu Card ── */
.menu-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform var(--transition), box-shadow var(--transition);
    animation: fadeUp 0.4s ease both;
}
.menu-card:active { transform: scale(0.98); }
.menu-card.highlight {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.menu-image {
    height: 210px;
    background-size: cover;
    background-position: center;
    position: relative;
}
.menu-image::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-card));
}

.menu-content { padding: 18px 20px 22px; }

.menu-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.menu-name {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.25em;
    font-weight: 700;
    color: var(--accent-emerald);
    line-height: 1.3;
    flex: 1;
}

.price {
    font-size: 1em;
    font-weight: 700;
    color: var(--accent-amber);
    white-space: nowrap;
}

.story {
    color: var(--text-sub);
    font-size: 0.92em;
    line-height: 1.7;
    margin-bottom: 12px;
}
.story.muted { color: var(--text-muted); font-size: 0.85em; }

.badge-today {
    display: inline-block;
    background: linear-gradient(135deg, rgba(52,211,153,0.2), rgba(56,189,248,0.2));
    color: var(--accent-emerald);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
    border: 1px solid rgba(52,211,153,0.3);
}

/* Phase 8 — 영양소 + 기능 태그 (손님 화면. verified=true 인 항목만 노출) */
.menu-nutrition {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}
.nutri-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 8px;
}
.nutri-cell {
    font-size: 0.78em;
    color: var(--text-sub);
}
.nutri-cell b {
    color: var(--text);
    font-weight: 700;
    margin-right: 2px;
}
.menu-function-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.menu-function-tags .tag {
    background: rgba(52,211,153,0.12);
    color: var(--accent-emerald);
    border: 1px solid rgba(52,211,153,0.25);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
}
.nutrition-disclaimer {
    margin: 24px 0 8px;
    padding: 12px 14px;
    background: rgba(251,191,36,0.08);
    border: 1px solid rgba(251,191,36,0.2);
    border-radius: 10px;
    color: var(--text-sub);
    font-size: 0.78em;
    line-height: 1.55;
    text-align: center;
}

/* ── Skeleton Loader ── */
.skeleton-card {
    height: 320px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.06) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ── Spinner ── */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Floating Chat Button ── */
.chat-fab {
    position: fixed;
    bottom: 28px; right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    color: #0a0f1e;
    border: none;
    border-radius: 28px;
    padding: 14px 20px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(56,189,248,0.35);
    z-index: 300;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(56,189,248,0.45); }
.chat-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }
.fab-icon { font-size: 1.1em; }

/* ── Chat Overlay ── */
.chat-overlay {
    position: fixed;
    bottom: 24px; right: 16px;
    width: calc(100% - 32px);
    max-width: 420px;
    height: 520px;
    /* 작은 핸드폰(아이폰 SE 등)에서 화면 폭/높이 초과 방지 */
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    background: rgba(10,15,30,0.96);
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    z-index: 400;
    box-shadow: var(--shadow), var(--shadow-glow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.97);
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}
.chat-overlay.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chat-title { font-weight: 700; font-size: 1em; }
.chat-subtitle { font-size: 0.75em; color: var(--text-muted); margin-top: 2px; }

.close-btn {
    background: none; border: none;
    color: var(--text-muted); font-size: 18px;
    cursor: pointer; padding: 4px;
    border-radius: 6px;
    transition: color var(--transition);
}
.close-btn:hover { color: var(--text); }

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9em;
    line-height: 1.6;
    animation: fadeUp 0.2s ease;
}
.message.ai {
    background: rgba(255,255,255,0.07);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.message.user {
    background: var(--accent-blue);
    color: #0a0f1e;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 600;
}

/* Typing Animation */
.typing-dots span {
    display: inline-block;
    animation: blink 1.2s infinite;
    font-size: 1.4em;
    line-height: 0;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity:0.2; } 40% { opacity:1; } }

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: center;
}
.chat-input-area input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 0.9em;
    outline: none;
    transition: border-color var(--transition);
}
.chat-input-area input:focus { border-color: var(--accent-blue); }
.chat-input-area input::placeholder { color: var(--text-muted); }
#send-btn {
    background: var(--accent-blue);
    color: #0a0f1e;
    border: none;
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition);
}
#send-btn:hover { transform: scale(1.1); }

/* ── Modal ── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
    background: #131c30;
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}
.modal-title { color: var(--accent-blue); font-size: 1.15em; margin-bottom: 12px; }
.modal-desc { color: var(--text-muted); font-size: 0.88em; margin-bottom: 18px; line-height: 1.6; }
.modal-input {
    width: 100%; padding: 12px 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 0.9em;
    outline: none; margin-bottom: 20px;
    transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--accent-blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary {
    background: var(--accent-blue); color: #0a0f1e;
    border: none; padding: 10px 22px;
    border-radius: var(--radius-sm); font-weight: 700;
    cursor: pointer; transition: transform var(--transition);
}
.btn-primary:hover { transform: scale(1.03); }
.btn-secondary {
    background: rgba(255,255,255,0.07); color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 22px; border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ── Toast ── */
.toast {
    position: fixed; bottom: 100px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30,41,59,0.95);
    color: var(--text); font-size: 0.88em;
    padding: 10px 20px; border-radius: 24px;
    border: 1px solid var(--border);
    opacity: 0; transition: all 0.3s; z-index: 9999;
    backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Admin Link ── */
.admin-link {
    position: fixed; bottom: 28px; left: 20px;
    color: var(--text-muted); font-size: 0.75em;
    text-decoration: none;
    opacity: 0.4;
    transition: opacity var(--transition);
}
.admin-link:hover { opacity: 0.9; }
