/* ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #e74c3c;
    --primary-hover: #c0392b;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), #c0392b);
    color: white;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* セクション */
.step-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.step-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 700;
}

/* バッジグリッド */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.badge-item {
    border: 3px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    background: var(--card-bg);
}

.badge-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.badge-item.selected {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.badge-item img {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    margin-bottom: 8px;
}

.badge-item .badge-name {
    font-size: 0.75rem;
    color: var(--text-light);
    word-break: break-word;
}

/* サイズプレビューコンテナ */
.size-preview-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.size-preview-image {
    position: relative;
    width: 300px;
    height: 300px;
    background: #f0f0f0;
    border-radius: 0;
    overflow: hidden;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.size-preview-image #size-preview-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.size-preview-badge {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    transition: width 0.15s ease;
}

.size-controls-panel {
    flex: 1;
    min-width: 250px;
}

/* サイズコントロール */
.size-control {
    margin-bottom: 20px;
}

.size-control label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.size-control input[type="range"] {
    flex: 1;
    min-width: 150px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 4px;
    outline: none;
}

.size-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.size-control input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

#size-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 60px;
    text-align: center;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* サンプル画像アップロード */
.sample-image-upload {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.sample-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f0f0f0;
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-top: 8px;
}

.sample-upload-btn:hover {
    background: #e0e0e0;
}

.sample-upload-btn svg {
    width: 18px;
    height: 18px;
}

/* アップロードエリア */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.upload-icon {
    width: 60px;
    height: 60px;
    color: var(--text-light);
    margin-bottom: 15px;
}

.upload-content p {
    margin-bottom: 10px;
    color: var(--text-color);
}

.or {
    color: var(--text-light);
    font-size: 0.9rem;
}

.file-select-btn {
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    margin: 15px 0;
}

.file-select-btn:hover {
    background: var(--primary-hover);
}

.file-types {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ファイルリスト */
.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-item .file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-item .file-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.file-item .file-name {
    font-size: 0.9rem;
}

.file-item .remove-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 5px;
    font-size: 1.2rem;
}

/* プレビュー */
.preview-count {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--text-light);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 25px;
}

.preview-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.preview-item .preview-filename {
    font-size: 0.85rem;
    color: var(--text-color);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-item .preview-images {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.preview-item .preview-img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: var(--shadow);
}

.preview-item .preview-arrow {
    font-size: 1.5rem;
    color: var(--text-light);
}

/* プレビューコントロール */
.preview-controls {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.position-selector,
.size-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}

.size-selector {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.control-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-right: 5px;
    min-width: 45px;
}

.pos-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.pos-btn:hover {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.pos-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.size-slider {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.size-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 35px;
    text-align: right;
}

.preview-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.nav-btn {
    padding: 8px 16px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-btn:hover:not(:disabled) {
    background: #2980b9;
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#preview-page-info {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* 旧プレビュー（互換性のため残す） */
.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.preview-box {
    text-align: center;
}

.preview-box h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.preview-box img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.preview-arrow {
    font-size: 2rem;
    color: var(--text-light);
}

/* ボタン */
.action-section {
    text-align: center;
    padding: 20px 0;
}

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.primary-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.primary-btn svg,
.secondary-btn svg {
    width: 24px;
    height: 24px;
}

.secondary-btn {
    background: var(--secondary-color);
    color: white;
    margin-top: 20px;
}

.secondary-btn:hover {
    background: #2980b9;
}

/* 結果セクション */
.result-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}

.result-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.result-summary {
    padding: 15px;
    background: #e8f5e9;
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--success-color);
    font-weight: 500;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.result-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s;
}

.result-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.result-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.result-item .result-info {
    padding: 12px;
}

.result-item .result-filename {
    font-size: 0.85rem;
    color: var(--text-color);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-item .download-btn {
    display: block;
    width: 100%;
    padding: 8px;
    background: var(--success-color);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.result-item .download-btn:hover {
    background: #219a52;
}

/* ローディング */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 1.1rem;
}

/* フッター */
footer {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* セクションヘッダー */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 {
    margin-bottom: 0;
}

.add-badge-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-badge-btn:hover {
    background: #219a52;
    transform: translateY(-1px);
}

.add-badge-btn svg {
    width: 18px;
    height: 18px;
}

/* バッジ削除ボタン */
.badge-item {
    position: relative;
}

.badge-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-item:hover .badge-delete-btn {
    opacity: 1;
}

.badge-delete-btn:hover {
    background: #c0392b;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-hover);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.cancel-btn,
.confirm-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn {
    background: #eee;
    color: var(--text-color);
}

.cancel-btn:hover {
    background: #ddd;
}

.confirm-btn {
    background: var(--success-color);
    color: white;
}

.confirm-btn:hover:not(:disabled) {
    background: #219a52;
}

.confirm-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* バッジアップロードエリア */
.badge-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.badge-upload-area:hover,
.badge-upload-area.dragover {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.badge-upload-area .upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.badge-preview-area {
    text-align: center;
    padding: 20px;
}

.badge-preview-area img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.badge-preview-area p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 30px 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .step-section {
        padding: 20px;
    }

    .badge-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .preview-container {
        flex-direction: column;
    }

    .preview-arrow {
        transform: rotate(90deg);
    }

    .preview-box img {
        max-width: 100%;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        padding: 14px 20px;
    }
}
