/* ============================================================
   BRIZM 卸売発注システム — 共通スタイルシート
   テーマカラー: #2c2c2c (グリーン)
   ============================================================ */

/* ── リセット & ベース ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Meiryo', sans-serif;
    background: #ffffff;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── ヘッダー ── */
.site-header {
    background: #2c2c2c;
    color: #fff;
    padding: 0 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    text-decoration: none;
}

.site-logo span.brand {
    background: #fff;
    color: #2c2c2c;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.site-logo-img {
    height: 36px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
}

.site-header-store {
    font-size: 0.85rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
}

/* ── メインコンテンツ ── */
.main-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* ── カード ── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

/* ── ページタイトル ── */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-subtitle {
    font-size: 0.875rem;
    color: #666666;
    margin-bottom: 1.5rem;
}

/* ── フォームグループ ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #3a3a3a;
}

.form-label .required {
    color: #c0392b;
    margin-left: 0.25rem;
}

.form-control {
    border: 1.5px solid #c0c0c0;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: #2c2c2c;
    box-shadow: 0 0 0 3px rgba(44, 44, 44, 0.15);
}

input[type="date"].form-control {
    cursor: pointer;
}

/* ── 数量入力 ── */
.qty-input {
    width: 70px;
    text-align: center;
    border: 1.5px solid #c0c0c0;
    border-radius: 6px;
    padding: 0.45rem 0.3rem;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.qty-input:focus {
    outline: none;
    border-color: #888888;
    box-shadow: 0 0 0 3px rgba(120, 120, 120, 0.18);
}

.qty-input.has-value {
    border-color: #888888;
    background: #f7f7f7;
}

/* ── ボタン ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.5rem;
    border-radius: 7px;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.2;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: #2c2c2c;
    color: #fff;
    box-shadow: 0 2px 6px rgba(44, 44, 44, 0.3);
}

.btn-primary:hover {
    background: #1a1a1a;
    box-shadow: 0 3px 8px rgba(44, 44, 44, 0.4);
}

.btn-secondary {
    background: #fff;
    color: #2c2c2c;
    border: 2px solid #2c2c2c;
}

.btn-secondary:hover {
    background: #f0faf5;
}

.btn-danger {
    background: #c0392b;
    color: #fff;
}

.btn-danger:hover {
    background: #a93226;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* ── カテゴリヘッダー ── */
.category-header {
    background: #2c2c2c;
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 7px 7px 0 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-top: 1.5rem;
    margin-bottom: 0;
}

.category-header:first-of-type {
    margin-top: 0;
}

/* ── 商品リスト（スタンダード注文） ── */
.product-list {
    background: #fff;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.product-item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.1s;
}

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

.product-item:hover {
    background: #fafafa;
}

.product-discontinued {
    opacity: 0.5;
}

.badge-discontinued {
    display: inline-block;
    background: #999;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

.product-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: #ffffff;
    flex-shrink: 0;
}

.product-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999999;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.product-info {
    min-width: 0;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    margin-bottom: 0.2rem;
}

.product-code {
    font-size: 0.75rem;
    color: #999999;
    font-family: monospace;
}

.product-price {
    font-size: 0.875rem;
    font-weight: 700;
    color: #2c2c2c;
    margin-top: 0.15rem;
}

.product-qty-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.product-qty-label {
    font-size: 0.7rem;
    color: #999999;
}

/* ── トータルバー ── */
.total-bar {
    position: sticky;
    bottom: 0;
    background: #2c2c2c;
    color: #fff;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -3px 10px rgba(0,0,0,0.15);
    z-index: 50;
    gap: 1rem;
}

.total-bar-label {
    font-size: 0.875rem;
    opacity: 0.85;
    white-space: nowrap;
}

.total-bar-amount {
    font-size: 1.35rem;
    font-weight: 800;
    white-space: nowrap;
}

.total-bar-actions {
    display: flex;
    gap: 0.5rem;
}

/* ── ブンブングリッド ── */
.bb-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.bb-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.8rem;
}

.bb-table th,
.bb-table td {
    border: 1px solid #e0e0e0;
    padding: 0.35rem 0.3rem;
    text-align: center;
    white-space: nowrap;
}

.bb-table thead th {
    background: #2c2c2c;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bb-table thead th.product-col {
    text-align: left;
    min-width: 180px;
    padding-left: 0.6rem;
    position: sticky;
    left: 0;
    z-index: 20;
}

.bb-table .cat-header-row th {
    background: #444444;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    padding-left: 0.6rem;
}

.bb-table tbody tr:hover {
    background: #fafafa;
}

.bb-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.bb-table tbody tr:nth-child(even):hover {
    background: #edf7f1;
}

.bb-table td.product-name-cell {
    text-align: left;
    padding-left: 0.6rem;
    font-size: 0.8rem;
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 5;
    border-right: 2px solid #b0ccbe;
}

.bb-table tr:nth-child(even) td.product-name-cell {
    background: #f9f9f9;
}

.bb-table td.price-cell {
    font-weight: 600;
    color: #2c2c2c;
    background: #fafafa;
}

.bb-table .store-total-row td {
    background: #f5f5f5;
    font-weight: 700;
    color: #2c2c2c;
    font-size: 0.82rem;
}

.bb-table .store-total-row td.product-name-cell {
    background: #eeeeee;
}

.bb-qty {
    width: 48px;
    text-align: center;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    padding: 0.25rem 0.1rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
}

.bb-qty:focus {
    outline: none;
    border-color: #888888;
    background: #f7f7f7;
    box-shadow: 0 0 0 2px rgba(120, 120, 120, 0.18);
}

.bb-qty.has-value {
    border-color: #888888;
    background: #f7f7f7;
}

/* ── アラート ── */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 7px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
}

.alert-success {
    background: #f5f5f5;
    border: 1px solid #e0a3ab;
    color: #2c2c2c;
}

.alert-error {
    background: #fdf0ee;
    border: 1px solid #f0a89e;
    color: #c0392b;
}

.alert-warning {
    background: #fef9e7;
    border: 1px solid #f5cba7;
    color: #7d6608;
}

.alert-info {
    background: #eaf4fb;
    border: 1px solid #a9d0e8;
    color: #1a5276;
}

/* ── エラーページ ── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.75rem;
}

.error-message {
    font-size: 0.95rem;
    color: #666666;
    max-width: 400px;
    line-height: 1.7;
}

/* ── サンクスページ ── */
.thanks-icon {
    font-size: 3.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.thanks-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c2c2c;
    text-align: center;
    margin-bottom: 0.5rem;
}

.thanks-sub {
    text-align: center;
    color: #666666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ── 注文サマリーテーブル ── */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.summary-table th,
.summary-table td {
    padding: 0.55rem 0.75rem;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.summary-table thead th {
    background: #2c2c2c;
    color: #fff;
    font-weight: 600;
}

.summary-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.summary-table tfoot td {
    background: #f5f5f5;
    font-weight: 700;
    color: #2c2c2c;
}

.summary-table td.text-right,
.summary-table th.text-right {
    text-align: right;
}

/* ── 情報テーブル（店舗情報等） ── */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.info-table th,
.info-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: top;
}

.info-table th {
    width: 35%;
    color: #666666;
    font-weight: 600;
    background: #fafafa;
    white-space: nowrap;
}

/* ── セットアップページ ── */
.setup-result {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    background: #1a1a1a;
    color: #e0a3ab;
    padding: 1rem;
    border-radius: 7px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.8;
}

.setup-result .ok   { color: #2ecc71; }
.setup-result .skip { color: #f39c12; }
.setup-result .err  { color: #e74c3c; }

/* ── バッジ ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
}

.badge-green {
    background: #eeeeee;
    color: #2c2c2c;
}

.badge-gray {
    background: #e8ece9;
    color: #666666;
}

.badge-blue {
    background: #daeaf7;
    color: #1a5276;
}

/* ── 区切り線 ── */
.divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 1rem 0;
}

/* ── テキストユーティリティ ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #999999; }
.text-green  { color: #2c2c2c; }
.text-danger { color: #c0392b; }
.fw-bold     { font-weight: 700; }

/* ── スペーサー ── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── フレックスユーティリティ ── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* ── フッター ── */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.78rem;
    color: #999999;
    background: #f5f5f5;
    margin-top: 2rem;
}

/* ── 日付フォーム行 ── */
.order-meta-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.order-meta-row .form-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.order-meta-row .notes-group {
    flex: 2;
}

/* ── ブンブンのstore-totals セクション ── */
.bb-totals-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 1rem;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.bb-store-total-chip {
    flex-shrink: 0;
    background: #f9f9f9;
    border: 1.5px solid #e0a3ab;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    text-align: center;
    min-width: 70px;
}

.bb-store-total-chip .chip-name {
    font-size: 0.72rem;
    color: #666666;
    font-weight: 600;
}

.bb-store-total-chip .chip-amount {
    font-size: 0.82rem;
    font-weight: 800;
    color: #2c2c2c;
    display: block;
    margin-top: 0.1rem;
}

/* ── 発注ボタン（目立つ色） ── */
.btn-order {
    background: #e22b4b;
    color: #fff;
    box-shadow: 0 2px 8px rgba(226, 43, 75, 0.40);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.btn-order:hover {
    background: #c4213e;
    box-shadow: 0 3px 10px rgba(226, 43, 75, 0.50);
}

/* 確定ボタン */
.btn-confirm {
    background: #27ae60;
    color: #fff;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.4);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-confirm:hover {
    background: #229954;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.5);
}

.btn-confirm:active {
    transform: translateY(1px);
}

/* ── 確認モーダル ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.modal-open {
    display: flex;
}

.modal-dialog {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    background: #2c2c2c;
    color: #fff;
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    background: #fafafa;
}

/* ── ローディング ── */
.btn-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 600px) {
    .site-header-inner {
        height: 50px;
    }

    .site-logo {
        font-size: 0.95rem;
    }

    .main-container {
        padding: 1rem 0.75rem 4rem;
    }

    .product-item {
        grid-template-columns: 48px 1fr auto;
        gap: 0.5rem;
        padding: 0.65rem 0.75rem;
    }

    .product-thumb,
    .product-thumb-placeholder {
        width: 48px;
        height: 48px;
    }

    .product-name {
        font-size: 0.82rem;
    }

    .qty-input {
        width: 60px;
    }

    .total-bar {
        padding: 0.7rem 0.75rem;
    }

    .total-bar-amount {
        font-size: 1.15rem;
    }

    .btn-lg {
        padding: 0.8rem 1.25rem;
        font-size: 1rem;
    }

    .card {
        padding: 1rem 0.875rem;
    }

    .order-meta-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .order-meta-row .form-group {
        min-width: 100%;
    }
}

@media (min-width: 768px) {
    .main-container {
        padding: 2rem 1.5rem 4rem;
    }

    .product-item {
        grid-template-columns: 72px 1fr auto;
        gap: 1rem;
        padding: 0.85rem 1.25rem;
    }

    .product-thumb,
    .product-thumb-placeholder {
        width: 72px;
        height: 72px;
    }

    .qty-input {
        width: 80px;
    }
}
