/* 購入ページ専用スタイル */

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ページコンテナ */
.purchase-container {
    padding: 1rem;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
}

/* ページヘッダー */
.page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

/* .page-header .icon-square のスタイルは common.css で定義済み */

.page-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #3a3a3a;
}


/* ステップインジケーター */
.purchase-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ddd;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background-color: #FF6B6B;
    color: white;
}

.step-text {
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    white-space: nowrap;
}

.step.active .step-text {
    color: #333;
    font-weight: 500;
}

.step-connector {
    width: 60px;
    height: 2px;
    background-color: #ddd;
    margin: 0 0.5rem;
    margin-bottom: 1.5rem;
}

/* コンテンツセクション */
.purchase-content {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.section-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 1.5rem;
}

/* テンプレート選択セクション */
.template-selector {
    margin-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
}

.template-label {
    display: block;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.template-dropdown {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.5rem;
    padding-right: 3rem;
}

.template-dropdown:hover {
    border-color: #4A90E2;
}

.template-dropdown:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 選択されたテンプレート詳細 */
.selected-template-detail {
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    clear: both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-detail-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    min-height: 300px;
}

.template-detail-image {
    flex: none;
    width: 100%;
    aspect-ratio: 1;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    margin: 0 0 1rem 0;
}

.template-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.template-detail-image::before {
    content: 'テンプレートプレビュー';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 0.875rem;
    text-align: center;
    z-index: 1;
}


.template-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    text-align: left;
}

.template-detail-info h4 {
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 0.75rem;
    font-weight: bold;
    white-space: normal;
    line-height: 1.4;
    word-wrap: break-word;
}

.template-detail-info p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.template-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    text-align: left;
}

.meta-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
}

.meta-label {
    color: #666;
    font-size: 0.875rem;
    font-weight: 500;
}

.meta-value {
    color: #333;
    font-size: 0.875rem;
}

.meta-value.template-price {
    font-size: 1.125rem;
    font-weight: bold;
    color: #FF6B6B;
}

.template-actions {
    margin-top: auto;
    text-align: left;
}

.sample-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #4A90E2;
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sample-link:hover {
    background: #357ABD;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

/* テンプレート選択グリッド（旧・非表示） */
.template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .template-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.template-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.template-card:hover {
    border-color: #FFD93D;
    box-shadow: 0 4px 12px rgba(255, 217, 61, 0.2);
}

.template-card.active {
    border-color: #FFD93D;
    background-color: #FFFEF5;
}

.template-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #f5f5f5;
    overflow: hidden;
}

.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #FF6B6B;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: bold;
}

.template-info {
    padding: 1rem;
}

.template-info h4 {
    font-size: 1.125rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.template-info p {
    color: #666;
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.template-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.recommended-users {
    color: #666;
    font-size: 0.875rem;
}

.sample-link {
    color: #4A90E2;
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.sample-link:hover {
    color: #357ABD;
    text-decoration: underline;
}

.template-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: #FF6B6B;
    margin-bottom: 1rem;
}

.btn-select {
    width: 100%;
    padding: 0.75rem;
    background: #FFD93D;
    color: #333;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-select:hover {
    background: #FFC107;
    transform: translateY(-1px);
}

.template-card.active .btn-select {
    background: #4CAF50;
    color: white;
}

.template-card.active .btn-select::after {
    content: '✓ 選択中';
}

/* 選択されたテンプレート表示 */
.selected-template {
    margin-bottom: 2rem;
}

.selected-template-info {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
}

.selected-preview {
    flex: 0 0 200px;
}

.selected-preview img {
    width: 100%;
    border-radius: 8px;
}

.selected-details {
    flex: 1;
}

.selected-details h4 {
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.selected-details p {
    color: #666;
    margin-bottom: 1rem;
}

.selected-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.selected-meta span {
    color: #666;
    font-size: 0.875rem;
}

.selected-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: #FF6B6B;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* テンプレート確認セクション（古い）*/
.template-preview-large {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.template-preview-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.loading-spinner.active {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #FF6B6B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.template-details h4 {
    font-size: 1.125rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.template-details p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.template-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feature-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.feature-label {
    color: #666;
    font-size: 0.875rem;
}

.feature-value {
    color: #333;
    font-weight: 500;
}

/* プラン選択セクション */
.storage-plans {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.plan-option {
    position: relative;
}

.plan-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.plan-option label {
    display: block;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.plan-option input[type="radio"]:checked + label {
    border-color: #FF6B6B;
    background-color: #FFF5F5;
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.plan-name {
    font-weight: bold;
    color: #333;
}

.plan-price {
    color: #FF6B6B;
    font-weight: bold;
}

.plan-desc {
    color: #666;
    font-size: 0.875rem;
}

/* 追加オプション */
.additional-options {
    margin-bottom: 2rem;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 8px;
}

.option-label {
    color: #333;
    font-size: 0.875rem;
}

.option-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #f5f5f5;
}

.qty-btn:active {
    transform: scale(0.95);
}

#additional-cards {
    width: 50px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.25rem;
}

/* 料金内訳 */
.price-summary {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.price-line {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.price-line:last-of-type {
    border-bottom: none;
}

.price-label {
    color: #666;
    font-size: 0.875rem;
}

.price-value {
    color: #333;
    font-weight: 500;
}

.price-total {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0 0;
    margin-top: 0.5rem;
    border-top: 2px solid #333;
}

.price-total .price-label {
    font-size: 1rem;
    font-weight: bold;
    color: #333;
}

.price-total .price-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #FF6B6B;
}

/* チェックアウト情報 */
.checkout-info {
    background: #FFF5F5;
    border-left: 3px solid #FF6B6B;
    padding: 1rem;
    margin-bottom: 2rem;
}

.checkout-info p {
    color: #666;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0.5rem 0;
}

/* アクションボタン */
.step-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    min-width: 120px;
    box-sizing: border-box;
}

.btn-primary {
    background: #FF6B6B;
    color: white;
}

.btn-primary:hover {
    background: #FF5555;
}

.btn-secondary {
    background: #e0e0e0;
    color: #666;
}

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

.btn-checkout {
    flex: 1;
    background: #FFD93D;
    color: #333;
    font-size: 1.125rem;
    padding: 1rem;
    font-weight: bold;
}

.btn-checkout:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(255, 217, 61, 0.4);
    background: #FFE566;
}

/* モバイル専用調整 */
@media (max-width: 767px) {
    .step-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
    
    .template-detail-card {
        padding: 1rem;
        gap: 1rem;
    }
    
    .purchase-content {
        padding: 1rem;
    }
}

/* レスポンシブ調整 */
@media (min-width: 768px) {
    .purchase-container {
        max-width: 720px;
        padding: 2rem;
    }
    
    .purchase-steps {
        margin-bottom: 3rem;
    }
    
    .storage-plans {
        flex-direction: row;
        gap: 1.5rem;
    }
    
    .plan-option {
        flex: 1;
    }
}