/* 既存のCSS（省略） */

/* --- 汎用ボタンのスタイル --- */
.btn {
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-decoration: none; /* リンクとして使用する場合のアンダーラインを削除 */
    color: white; /* デフォルトの文字色 */
}

.btn:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary {
    background-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-success {
    background-color: #28a745;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-outline {
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
}

.btn-outline:hover {
    background-color: #ddd;
    box-shadow: none;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* --- 基本設定の拡大 --- 
/* --- 基本設定の拡大 --- */
body { 
    font-family: sans-serif; 
    margin: 0; 
    padding: 20px 20px 12em 20px; /* ミニカートバーの高さに合わせたpadding */
    font-size: 16px; 
    background-color: #f4f4f4;
}
h1 {
    font-size: 2em; 
    margin-bottom: 25px;
}

/* 注文ステータスアイコン */
.order-status-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2.5em;
    color: #007bff;
    cursor: pointer;
    transition: color 0.3s ease;
}

.order-status-icon:hover {
    color: #0056b3;
}

input[type="text"],
input[type="number"],
input[type="file"],
textarea,
select {
    padding: 12px;
    font-size: 1em; /* 汎用的なフォントサイズに調整 */
    border-radius: 8px;
    border: 1px solid #ccc;
    margin-bottom: 15px;
    box-sizing: border-box;
    width: 100%;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
textarea:focus,
select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

/* アレルギーチェックボックスグループのスタイル */
.allergen-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.allergen-checkbox-group label {
    font-weight: normal;
    margin-bottom: 0;
    display: flex; /* チェックボックスとテキストを横並びにする */
    align-items: center;
    padding: 8px 12px; /* パディングを追加 */
    border: 1px solid #ddd; /* 枠線を追加 */
    border-radius: 5px; /* 角丸を追加 */
    background-color: #fff; /* 背景色を追加 */
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    position: relative; /* ::before の基準位置 */
}

.allergen-checkbox-group label input[type="checkbox"] {
    /* ネイティブのチェックボックスを非表示にする */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.allergen-checkbox-group label span {
    position: relative;
    padding-left: 25px; /* カスタムチェックボックス分のスペース */
    display: flex;
    align-items: center;
    height: 100%;
}

.allergen-checkbox-group input[type="checkbox"] + span::before {
    content: '';
    display: block;
    position: absolute;
    left: 0px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    background-color: #fff;
    transition: background-color 0.2s, border-color 0.2s;
}

.allergen-checkbox-group input[type="checkbox"]:checked + span::before {
    background-color: #007bff; /* チェック時の背景色 */
    border-color: #007bff; /* チェック時の枠線色 */
}

.allergen-checkbox-group input[type="checkbox"]:checked + span::after {
    content: '\2713'; /* チェックマーク */
    display: block;
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

.allergen-checkbox-group input[type="checkbox"]:checked + label {
    background-color: #e0f7fa; /* チェックされた時の背景色 */
    border-color: #00bcd4; /* チェックされた時の枠線色 */
}

/* input[type="number"] の幅調整 */
.quantity-control input[type="number"] {
    width: 80px; /* 数量コントロール内のinputの幅を調整 */
    margin-bottom: 0;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
}

/* --- 1. 商品リスト (product-card) の調整 --- */
#product-list { 
    display: grid; 
    /* スマートフォンで2列表示を維持しやすいようminmaxを調整 */
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); 
    gap: 15px; 
}
.product-card { 
    background-color: white; border: 1px solid #ddd; border-radius: 12px; 
    padding: 15px; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); 
    display: flex; flex-flow: column; justify-content: end; 
    cursor: pointer; 
    min-height: 250px; 
    font-size: 1.8em;
}
.product-card:hover { background-color: #f9f9f9; }

.product-name {
    font-size: 1.25em; 
    font-weight: bold; margin-bottom: 5px; 
    height: 2.5em; overflow: hidden; line-height: 1.25;
}
.product-price {
    font-size: 1.5em; 
    color: #e60023;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: right;
}
.product-info {
    font-size: 0.95em; 
    color: #666; flex-grow: 1; overflow: hidden;
}

.product-card input[type="number"] { width: 60px; padding: 5px; border: 1px solid #ccc; border-radius: 4px; }
/* ---------------------------------------------------- */
/* ★ 注文概要 (order-summary) を画面下部に固定するCSS ★ */
/* ---------------------------------------------------- */

/* 画面下部を占有するコンテナ（bodyのpaddingを調整するため）*/
.fixed-cart-container {
    position: fixed; /* 画面に対して位置を固定 */
    bottom: 0; /* 画面の一番下に配置 */
    left: 0;
    width: 100%;
    z-index: 500; /* 他の要素より手前に表示 */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* 影をつけて区切りを明確に */
    background-color: white; /* 背景は白にする */
    padding: 10px 0; /* 上下のパディング */
}

/* ---------------------------------------------------- */
/* ★ ミニカートバーのCSS ★ */
/* ---------------------------------------------------- */

.fixed-cart-container {
    position: fixed; bottom: 0; left: 0; width: 100%; z-index: 500; 
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); 
    background-color: white; 
    padding: 0;
}

.mini-cart-bar {
    display: flex; justify-content: space-between; align-items: center;
    width: 90%; max-width: 800px; height: 100%; margin: 0 auto; padding: 1.5em 0;
}

.cart-info {
    font-size: 2.4em; 
    font-weight: bold;
}
#total-price-mini {
    font-size: 1.6em; 
    color: #e60023;
}

.view-cart-button {
    font-size: 3.2em; /* 特定のフォントサイズを維持 */
}

/* 注文概要エリア（既存のスタイルを調整） */
.order-summary { 
    /* fixed-cart-container内に配置されるため、position:fixedのプロパティを削除 */
    background-color: #e9e9e9; 
    padding: 0;
    border-radius: 8px; 
    margin: 0 auto; /* 中央揃え */
    width: 90%; /* 画面幅の90%を使用 */
    max-width: 600px; /* PCなど大画面でも広がりすぎないように制限 */
}

.submit-button {
    padding: 18px; /* 特定のパディングを維持 */
    font-size: 1.4em; /* 特定のフォントサイズを維持 */
    border-radius: 10px; /* 特定の角丸を維持 */
    margin-top: 20px;
    display: block; width: 100%;
}
.submit-button:hover {
    /* ホバー時のスタイルは.btn-primaryで定義されるため、ここでは不要 */
    cursor: pointer;
}
.error { color: red; font-weight: bold; margin-bottom: 10px; }

.close {
    color: #aaa; float: right; font-size: 50px; font-weight: bold;
}
.close:hover,
.close:focus {
    color: #000; text-decoration: none; cursor: pointer;
}

/* ★ モーダルウィンドウのCSSここから */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto;
    background-color: rgba(0,0,0,0.7); padding-top: 20px;
    justify-content: center; align-items: center;
}
.modal-content {
    font-size: 1.6em;
    background-color: #fefefe;
    padding: 0px 25px 30px;
    border: 1px solid #888;
    width: 95%; max-width: 700px;
    border-radius: 12px;
}

#modal-image-container {
    width: 100%; overflow: hidden; margin-bottom: 15px; border-radius: 8px;
    display: flex; justify-content: center; align-items: center;
}
#modal-image-container img {
    width: 100%; height: 100%; object-fit: cover;
}

/* モーダル内の数量コントロール */
#modal-order-controls {
    display: flex; align-items: center; gap: 20px; margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee;
}
.quantity-control {
    display: flex; align-items: center; border: 1px solid #ccc; border-radius: 8px; overflow: hidden; 
}
.qty-button {
    width: 60px; height: 60px; font-size: 1.2em; /* 特定のサイズとフォントサイズを維持 */
    display: inline-flex; justify-content: center; align-items: center
}
.qty-button:hover { /* ホバー時のスタイルは.btn-outlineで定義されるため、ここでは不要 */ }
#modal-quantity, .item-quantity { /* .item-quantity を追加 */
    width: 80px; height: 60px; font-size: 1.2em; padding: 0; border: none; text-align: center;
    -moz-appearance: textfield; 
}
#modal-quantity::-webkit-outer-spin-button,
#modal-quantity::-webkit-inner-spin-button,
.cart-item .item-quantity::-webkit-outer-spin-button,
.cart-item .item-quantity::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
#add-to-cart-button {
    padding: 15px 20px; font-size: 1.2em; border-radius: 8px; flex-grow: 1;
    height: 70px;
}
/* ★ モーダルウィンドウのCSSここまで */

#products-list li {
    list-style: none; padding: 0;
    display: flex; flex-wrap: wrap; gap: 15px;
}
#products-list li {
    background-color: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 15px; width: 45%; 
    box-sizing: border-box; display: flex; flex-direction: column; min-height: 350px; 
}
.product-image-container {
    width: 100%; max-height: 180px; 
    overflow: hidden; margin-bottom: 20px; border-radius: 8px; 
    background-color: #f8f8f8; display: flex; justify-content: center; align-items: center;
}
.product-image {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.product-name {
    font-size: 1.1em; font-weight: bold; margin-bottom: 5px; height: 2.5em; overflow: hidden; line-height: 1.25; display: inline;
}
.product-price {
    font-size: 1.2em; color: #e60023; margin-bottom: 10px;
}
.product-info {
    font-size: 0.85em; color: #666; flex-grow: 1; overflow: hidden;
}

/* ローディングオーバーレイ */
.loading-overlay {
    display: none; /* 初期状態では非表示 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* 半透明の黒 */
    z-index: 9999; /* 他の要素より前面に表示 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.5em;
}

/* ローディングスピナー */
.loading-spinner {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 2s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 結果表示モーダルのボタン */
#result-modal .modal-content button {
    padding: 15px 20px;
    font-size: 1.2em;
    border-radius: 8px;
    margin-top: 20px;
    width: 100%;
}

/* カートアイテムのスタイル */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap; /* 追加: 要素が収まらない場合に折り返す */
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item .item-name {
    flex-grow: 1;
    font-weight: bold;
    order: 1;
    white-space: nowrap; /* 追加: 改行させない */
    overflow: hidden; /* 追加: はみ出た部分を隠す */
    text-overflow: ellipsis; /* 追加: はみ出た部分を...で表示 */
    min-width: 0; /* flexアイテムの最小幅を0に設定 */
}
.cart-item .item-price {
    margin-right: 10px;
    font-weight: bold;
    order: 2;
    flex-shrink: 0; /* 追加: 縮小させない */
}

.cart-item .item-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    order: 4; /* 変更: item-name, item-price の後に来るように order を調整 */
    flex-basis: 100%; /* 追加: 新しい行を占有する */
    justify-content: flex-end; /* 追加: 右寄せにする */
    margin-top: 5px; /* 追加: 上部に少し余白 */
}

/* .cart-item .item-quantity のスタイルは#modal-quantityと共通化するため削除 */

.cart-item .qty-button, .remove-item-button {
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
}

.cart-item .qty-button {
    background-color: #f0f0f0;
}

.cart-item .qty-button:hover {
    background-color: #ddd;
}

.cart-item .remove-item-button {
    padding: 10px 15px; /* 大きくする */
    font-size: 1.2em; /* 大きくする */
    margin-right: 10px; /* 右側に間隔 */
    order: 0; /* 一番左に配置 */
    flex-shrink: 0; /* 追加: 縮小させない */
}

.empty-cart-message {
    text-align: center;
    color: #666;
    padding: 20px 0;
}

/* オプション選択UIのスタイル */
.option-group {
    margin-bottom: 10px;
}

.option-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.option-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.cart-item-options {
    font-size: 0.85em;
    color: #666;
    margin-top: 2px;
    margin-bottom: 5px;
}

/* 注文ステータス表示用のスタイル */
.status-new {
    color: #007bff;
    font-weight: bold;
}
.status-accepted {
    color: #28a745;
    font-weight: bold;
}
.status-cooking {
    color: #ffc107;
    font-weight: bold;
}
.status-delivering {
    color: #17a2b8;
    font-weight: bold;
}
.status-completed {
    color: #6c757d;
    font-weight: bold;
}
.status-cancelled {
    color: #dc3545;
    font-weight: bold;
}

.order-items-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.order-items-list li {
    padding: 8px 0;
    border-bottom: 1px dotted #eee;
}

.order-items-list li:last-child {
    border-bottom: none;
}

.order-items-list small {
    color: #666;
}

/* スマートフォン向け調整 */
@media screen and (max-width: 768px) {
    body {
        font-size: 14px; /* 基本フォントサイズを調整 */
    }

    /* 商品カード関連 */
    #product-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* 商品カードの列数を調整 */
        gap: 10px;
    }
    .product-card {
        font-size: 1em; /* 商品カード全体のフォントサイズを調整 */
        padding: 10px;
        min-height: 200px;
    }
    .product-name {
        font-size: 1.1em; /* 商品名のフォントサイズを調整 */
        height: auto; /* 高さを自動調整 */
    }
    .product-price {
        font-size: 1.2em; /* 価格のフォントサイズを調整 */
    }

    /* ミニカートバー関連 */
    .mini-cart-bar {
        width: 95%;
        padding: 1em 0;
    }
    .cart-info {
        font-size: 1.4em; /* カート情報のフォントサイズを調整 */
    }
    #total-price-mini {
        font-size: 1.1em; /* 合計金額のフォントサイズを調整 */
    }
    .view-cart-button {
        font-size: 1.2em; /* 「注文へ進む」ボタンのフォントサイズを調整 */
        padding: 8px 12px;
    }

    /* モーダル関連 */
    .modal-content {
        font-size: 1em; /* モーダルコンテンツのフォントサイズを調整 */
        padding: 15px;
    }
    .close {
        font-size: 30px; /* 閉じるボタンのフォントサイズを調整 */
    }
    #modal-order-controls {
        flex-direction: column; /* 数量コントロールを縦並びに */
        gap: 10px;
    }
    .quantity-control {
        justify-content: center;
    }
    .qty-button {
        width: 40px;
        height: 40px;
        font-size: 1em;
    }
    #modal-quantity, .item-quantity {
        width: 60px;
        height: 40px;
        font-size: 1em;
    }
    #add-to-cart-button {
        width: 100%;
        height: 50px;
        font-size: 1em;
    }

    /* 注文確認モーダル */
    #order-confirm-modal h2 {
        font-size: 1.5em;
    }
    #order-confirm-modal label {
        font-size: 0.9em;
    }
    #order-confirm-modal input[type="text"], #order-confirm-modal textarea {
        padding: 8px;
        font-size: 0.9em;
    }
    #order-confirm-modal .submit-button {
        padding: 12px;
        font-size: 1.1em;
    }

    /* 注文ステータスアイコン */
    .order-status-icon {
        font-size: 2em;
        top: 15px;
        right: 15px;
    }

    /* ローディングオーバーレイ */
    .loading-overlay {
        font-size: 1.2em;
    }
    .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 6px;
    }
}