/**
 * checkout-cart.css
 * カート・チェックアウトフローの UI/UX 改善スタイル
 *
 * 【改善ポイント】
 * - 価格表示: 等幅フォント、3桁区切り、右寄せ
 * - カート商品: カードレイアウト、+/−数量ボタン
 * - 合計セクション: 送料・税込み価格の明確化
 * - モバイル最適化: CTA固定、タップ領域拡大
 */

/* ========== 価格表示の共通スタイル ========== */
.price-value {
    font-family: 'Roboto Mono', 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    text-align: right;
}

.price-value--sm {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.price-value--md {
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

.price-value--lg {
    font-size: 24px;
    font-weight: 700;
    color: #111;
}

.price-label {
    font-size: 12px;
    color: #666;
    font-weight: 400;
}

.price-currency {
    font-size: 0.85em;
    margin-right: 2px;
}

/* ========== カート商品アイテム ========== */
.cart-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s ease;
}

.cart-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cart-item__image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}

.cart-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item__info {
    flex: 1;
    min-width: 0;
}

.cart-item__name {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin: 0 0 4px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-item__price-unit {
    font-size: 12px;
    color: #666;
}

.cart-item__price-unit .price-value {
    display: inline;
}

/* 数量コントロール（+/−ボタン） */
.cart-item__quantity {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.cart-item__qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item__qty-btn:hover {
    background: #e8e8e8;
}

.cart-item__qty-btn:active {
    background: #ddd;
}

.cart-item__qty-btn:disabled {
    color: #bbb;
    cursor: not-allowed;
}

.cart-item__qty-input {
    width: 48px;
    height: 36px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #222;
    -moz-appearance: textfield;
    appearance: textfield;
}

.cart-item__qty-input::-webkit-outer-spin-button,
.cart-item__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* 小計 */
.cart-item__subtotal {
    text-align: right;
    min-width: 100px;
}

.cart-item__subtotal-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
}

.cart-item__subtotal-value {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    font-family: 'Roboto Mono', 'SF Mono', monospace;
}

/* 削除ボタン */
.cart-item__remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item__remove:hover {
    background: #fee;
    color: #e53935;
}

.cart-item__remove svg {
    width: 18px;
    height: 18px;
}

/* ========== カート合計セクション ========== */
.cart-summary {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 20px;
    margin-top: 24px;
}

.cart-summary__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #e0e0e0;
}

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

.cart-summary__label {
    font-size: 14px;
    color: #555;
}

.cart-summary__value {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    font-family: 'Roboto Mono', 'SF Mono', monospace;
}

.cart-summary__row--shipping .cart-summary__value small {
    font-size: 11px;
    color: #888;
    font-weight: normal;
    margin-left: 4px;
}

.cart-summary__row--total {
    padding-top: 16px;
    margin-top: 8px;
    border-top: 2px solid #ddd;
    border-bottom: none;
}

.cart-summary__row--total .cart-summary__label {
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

.cart-summary__row--total .cart-summary__value {
    font-size: 24px;
    font-weight: 700;
    color: #111;
}

/* 送料無料バッジ */
.cart-summary__free-shipping {
    color: #2e7d32;
    font-weight: 600;
}

.cart-summary__free-shipping::before {
    content: '✓ ';
}

/* ========== 信頼性バッジ ========== */
.trust-badges {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.trust-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #666;
}

.trust-badge__icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.trust-badge__icon svg {
    width: 18px;
    height: 18px;
    color: #4caf50;
}

/* ========== ゲスト購入バナー ========== */
.guest-checkout-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #e8f5e9;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #2e7d32;
}

.guest-checkout-banner__icon {
    font-size: 16px;
}

/* ========== 空のカート表示 ========== */
.cart-empty {
    text-align: center;
    padding: 60px 20px;
}

.cart-empty__icon {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 16px;
}

.cart-empty__title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.cart-empty__message {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
}

/* ========== モバイル最適化 ========== */
@media (max-width: 768px) {

    /* カート商品を縦並び */
    .cart-item {
        flex-wrap: wrap;
        padding: 12px;
    }

    .cart-item__image {
        width: 64px;
        height: 64px;
    }

    .cart-item__info {
        flex: 1;
        min-width: calc(100% - 80px - 40px);
    }

    .cart-item__quantity {
        order: 3;
        margin-top: 8px;
    }

    .cart-item__subtotal {
        order: 4;
        margin-top: 8px;
        text-align: right;
        flex: 1;
    }

    .cart-item__remove {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .cart-item {
        position: relative;
    }

    /* CTA固定 */
    .checkout-cta-fixed {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .checkout-cta-fixed .c-button--primary {
        width: 100%;
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
    }

    /* CTAがあるページは下部に余白 */
    .has-fixed-cta {
        padding-bottom: 80px;
    }

    /* 信頼バッジを縮小 */
    .trust-badges {
        gap: 12px;
        padding: 12px;
    }

    .trust-badge {
        font-size: 10px;
    }

    .trust-badge__icon {
        width: 28px;
        height: 28px;
    }
}

/* ========== フォーム改善 ========== */
.form-field {
    margin-bottom: 20px;
}

.form-field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.form-field__label--required::after {
    content: '（必須）';
    color: #e53935;
    font-size: 11px;
    font-weight: normal;
    margin-left: 4px;
}

.form-field__input-group {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.form-field__prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px 0 0 6px;
    font-size: 14px;
    color: #666;
}

.form-field__input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field__input:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.form-field__input.is-error {
    border-color: #e53935;
}

.form-field__input.is-success {
    border-color: #4caf50;
}

.form-field__btn-lookup {
    padding: 0 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.form-field__btn-lookup:hover {
    background: #e8e8e8;
}

.form-field__hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.form-field__error {
    font-size: 12px;
    color: #e53935;
    margin-top: 4px;
    display: none;
}

.form-field__error.is-visible {
    display: block;
}

/* ========== 支払方法カード ========== */
.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.payment-method {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.payment-method:hover {
    border-color: #bbb;
}

.payment-method input[type="radio"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    accent-color: #2196f3;
}

.payment-method.is-selected {
    border-color: #2196f3;
    background: #e3f2fd;
}

.payment-method__content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.payment-method__icon {
    font-size: 20px;
}

.payment-method__icons {
    display: flex;
    gap: 4px;
}

.payment-method__icons img {
    height: 20px;
    width: auto;
}

.payment-method__name {
    font-size: 14px;
    font-weight: 600;
    color: #222;
}

.payment-method__note {
    font-size: 12px;
    color: #888;
}

.payment-method__check {
    display: none;
    width: 24px;
    height: 24px;
    background: #2196f3;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    align-items: center;
    justify-content: center;
}

.payment-method.is-selected .payment-method__check {
    display: flex;
}

/* ========== 情報入力ページ（checkout-info）PC 向けレイアウト改善 ========== */
/* 768px 以下は restyle.css のモバイルスタイルのまま。769px 以上でのみ適用しスマホに影響しない */
@media (min-width: 769px) {
    /* フォーム全体の幅を確保しつつ、極端に広がりすぎないよう中央寄せ */
    #checkout-info-form {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }

    #checkout-info-form .p-page__section {
        margin-bottom: 36px;
        padding: 24px;
    }

    #checkout-info-form .p-page__section-title {
        margin-bottom: 16px;
        font-size: 17px;
    }

    /* テーブル行の余白を広げて見やすく・クリックしやすく */
    #checkout-info-form .c-form__table {
        margin: 20px 0;
    }

    #checkout-info-form .c-form__table tbody tr {
        border-bottom: 1px solid #eee;
    }

    #checkout-info-form .c-form__title {
        width: 32%;
        min-width: 140px;
        padding: 14px 24px 14px 0;
        font-size: 14px;
        line-height: 1.45;
    }

    #checkout-info-form .c-form__content {
        width: 68%;
        padding: 14px 0;
    }

    /* 入力欄を PC で大きく・余白を確保（フォーカス・クリックしやすい） */
    #checkout-info-form .c-input--text {
        padding: 10px 14px;
        font-size: 15px;
        line-height: 1.5;
        min-height: 44px;
    }

    #checkout-info-form .c-input--text::placeholder {
        color: #999;
    }

    #checkout-info-form .c-input--select {
        padding: 10px 14px;
        font-size: 15px;
        min-height: 44px;
        cursor: pointer;
    }

    #checkout-info-form .c-form__note {
        margin-top: 6px;
        font-size: 13px;
        color: #666;
    }

    /* 郵便番号エリア：入力欄とボタンの高さを揃えやすく */
    #checkout-info-form .form-field__input-group {
        gap: 10px;
    }

    #checkout-info-form .form-field__input-group .c-input--text {
        flex: 1;
        min-width: 0;
    }

    #checkout-info-form .form-field__btn-lookup {
        padding: 10px 18px;
        font-size: 14px;
        white-space: nowrap;
    }

    /* ラジオ・支払方法のタップ領域拡大（PC でもクリックしやすい） */
    #checkout-info-form .select_rb {
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    #checkout-info-form .select_rb .button input[type="radio"] {
        margin-right: 8px;
        width: 18px;
        height: 18px;
        cursor: pointer;
    }

    #checkout-info-form .select_rb label {
        cursor: pointer;
        font-size: 15px;
    }
}