/* モーダルオーバーレイ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* アドレス入力モーダルのスタイル */
.address-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    transform: scale(0.8) translateY(-30px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.modal-overlay.show .address-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.order-summary {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid #dee2e6;
}

.order-summary h4 {
    color: #0066cc;
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.order-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.order-item:last-child {
    border-bottom: none;
}

.order-item.total-price {
    font-weight: 600;
    font-size: 1.1rem;
    color: #0066cc;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 2px solid #0066cc;
}

.address-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 0.95rem;
}

.required {
    color: #dc3545;
    margin-left: 4px;
}

.form-control {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-control:invalid {
    border-color: #dc3545;
}

.form-control:valid {
    border-color: #28a745;
}

.field-error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: "⚠";
    font-size: 0.9rem;
}

.purchase-type-selection {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.purchase-type-selection h4 {
    margin-bottom: 16px;
    color: #333;
    font-size: 1rem;
    font-weight: 600;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.radio-option:hover {
    background: rgba(0, 102, 204, 0.05);
    border-color: rgba(0, 102, 204, 0.2);
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
}

.radio-option input[type="radio"]:checked + .radio-custom {
    border-color: #0066cc;
    background: #0066cc;
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.agreement-section {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
}

.checkbox-option input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom {
    border-color: #0066cc;
    background: #0066cc;
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid #e9ecef;
    margin-top: 24px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #0066cc, #3399ff);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #0052a3, #2980ff);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 102, 204, 0.3);
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary .fas.fa-spinner {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.purchase-complete-message {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-radius: 12px;
    border: 1px solid #b8dabd;
    color: #155724;
}

.purchase-complete-message i {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
    color: #28a745;
}

.purchase-complete-message span {
    font-weight: 600;
    font-size: 1.1rem;
}

/* PayPal決済ボタンの無効化スタイル */
.paypal-payment-section.disabled {
    opacity: 0.6;
}

.paypal-btn.disabled {
    background: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.paypal-btn.disabled:hover {
    background: #6c757d !important;
    transform: none !important;
    box-shadow: none !important;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .address-modal {
        margin: 20px;
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 40px);
    }
    
    .order-summary {
        padding: 16px;
    }
    
    .address-form {
        gap: 16px;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 14px 24px;
    }
    
    .radio-group {
        gap: 8px;
    }
    
    .radio-option {
        padding: 10px;
    }
}

/* フォーカス状態の改善 */
.form-control:focus,
.radio-option:focus-within,
.checkbox-option:focus-within {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* モーダルヘッダー */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 24px;
}

.modal-header h3 {
    color: #0066cc;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #dc3545;
    transform: scale(1.1);
}

.modal-body {
    padding: 0 24px;
}

/* クローズアニメーション */
.modal-overlay.closing {
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.closing .address-modal {
    transform: scale(0.8) translateY(-30px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.field-error {
    animation: errorSlideIn 0.3s ease-out;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}