/* 町中華風 赤白ベース モダンデザイン */
:root {
    --primary-red: #D32F2F;      /* 深みのある町中華レッド */
    --accent-red: #E53935;       /* やや明るい赤 */
    --bg-white: #FAFAFA;         /* 真っ白ではない、少し温かみのある白 */
    --card-white: #FFFFFF;
    --text-main: #333333;
    --text-light: #757575;
    --border-color: #EEEEEE;
    --gold: #FFC107;             /* 中華のアクセントとしての金（黄色） */
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-white);
    color: var(--text-main);
    padding-bottom: 80px; /* 下部カートバーの余白 */
    -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
.app-header {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--accent-red) 100%);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-main { text-align: left; }

.app-header h1 {
    font-weight: 900;
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.app-header p {
    font-size: 0.75rem;
    color: #FFEbee;
    margin-top: 2px;
}

.history-btn {
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.6);
    color: white;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.history-btn:hover { background: rgba(255,255,255,0.25); }

/* 注文履歴モーダル */
.history-modal-content {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 2px solid var(--primary-red);
    flex-shrink: 0;
}

.history-modal-header h2 { font-size: 1.1rem; }

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 4px 8px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.history-loading,
.history-empty {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-size: 0.95rem;
}

/* 注文履歴カード */
.hist-order-card {
    border-radius: 10px;
    border-left: 5px solid var(--border-color);
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.hist-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0.9rem;
    background: #F9F9F9;
    border-radius: 8px 8px 0 0;
}

.hist-time {
    font-size: 0.9rem;
    color: #555;
    font-weight: 700;
}

.hist-status-badge {
    font-size: 0.82rem;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 20px;
}

/* ステータス別スタイル */
.hist-order-card.hist-pending   { border-left-color: #FFC107; }
.hist-order-card.hist-preparing { border-left-color: #1976D2; }
.hist-order-card.hist-completed { border-left-color: #388E3C; }

.hist-status-badge.hist-pending   { background: #FFF3CD; color: #856404; }
.hist-status-badge.hist-preparing { background: #CCE5FF; color: #004085; }
.hist-status-badge.hist-completed { background: #D4EDDA; color: #155724; }

.hist-items {
    padding: 0.6rem 0.9rem;
    border-top: 1px solid #EEEEEE;
}

.hist-item-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    font-size: 0.9rem;
    padding: 4px 0;
    color: #333;
}

.hist-total {
    padding: 0.6rem 0.9rem;
    text-align: right;
    font-weight: 900;
    color: var(--primary-red);
    font-size: 1rem;
    border-top: 1px solid #EEEEEE;
}

/* カテゴリータブ */
.category-tabs-wrapper {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-tabs {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.tab-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--primary-red);
    border-color: var(--primary-red);
    color: white;
}

/* メニューリスト */
.app-main {
    padding: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
}

.menu-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.menu-card {
    background: var(--card-white);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.menu-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

/* 画像ラッパー（バッジ重ね用） */
.menu-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #F5F5F5;
}

.menu-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 画像がない場合のプレースホルダー */
.menu-image-placeholder {
    width: 100%;
    height: 100%;
    background: #F5F5F5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
}

/* カード下部：名前・価格・ボタン */
.menu-card-body {
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.menu-name {
    font-size: 0.85rem;
    font-weight: 900;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.menu-price {
    font-weight: bold;
    color: var(--primary-red);
    font-size: 0.9rem;
}

/* 注文数バッジ（画像の右上に重ねる） */
.item-count-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-red);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 22px;
    height: 22px;
    border-radius: 50px;
    padding: 0 5px;
    animation: badge-pop 0.2s ease;
}

@keyframes badge-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.add-button {
    width: 100%;
    background-color: var(--card-white);
    color: var(--primary-red);
    border: 2px solid var(--primary-red);
    border-radius: 8px;
    padding: 6px 2px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: auto;
}

.add-button:hover, .add-button:active {
    background-color: var(--primary-red);
    color: white;
}

/* フローティングカートバー */
.cart-floating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: white;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 2px solid var(--primary-red);
    z-index: 1000;
}

.cart-info {
    display: flex;
    flex-direction: column;
}

.cart-count {
    font-size: 0.8rem;
    color: var(--text-light);
}

.cart-total {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary-red);
}

.cart-button {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--accent-red) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(211,47,47,0.3);
    cursor: pointer;
}

/* モーダルUI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none; /* 初期非表示 */
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--bg-white);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-red);
    padding-bottom: 0.5rem;
}

.cart-items-list {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.cart-item-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-red);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

.cancel-button {
    background-color: var(--border-color);
    color: var(--text-main);
}

.submit-button {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--accent-red) 100%);
    color: white;
}

/* テーブル選択モーダル */
.table-modal-content {
    text-align: center;
}

.table-modal-desc {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0.5rem 0 1.25rem;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}

.table-btn {
    padding: 14px 8px;
    border-radius: 10px;
    border: 2px solid var(--primary-red);
    background: white;
    color: var(--primary-red);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.table-btn:hover, .table-btn:active {
    background: var(--primary-red);
    color: white;
}

/* カートバーのテーブル番号表示 */
.cart-table-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 2px;
}
