/* ===== リセット & ベーススタイル ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 
               'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 
               Meiryo, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* ===== ヘッダー ===== */
.header {
  background: #f8f9fa;
  color: #333;
  padding: 30px 40px;
  text-align: center;
  border-bottom: 1px solid #dee2e6;
}

.main-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 16px;
  opacity: 0.9;
  font-weight: 300;
}

/* ===== プログレスバー ===== */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 40px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dee2e6;
  color: #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  transition: all 0.3s;
}

.progress-step.active .step-number {
  background: #2c3e50;
  color: white;
  transform: scale(1.1);
}

.progress-step.completed .step-number {
  background: #27ae60;
  color: white;
}

.step-label {
  font-size: 12px;
  color: #6c757d;
  font-weight: 500;
}

.progress-step.active .step-label {
  color: #2c3e50;
  font-weight: 600;
}

.progress-line {
  width: 60px;
  height: 2px;
  background: #dee2e6;
  margin: 0 10px;
}

/* ===== ステップセクション ===== */
.step-section {
  padding: 40px;
}

.step-header {
  margin-bottom: 30px;
}

.step-header h2 {
  font-size: 24px;
  color: #2c3e50;
  margin-bottom: 8px;
}

.step-description {
  color: #6c757d;
  font-size: 14px;
}

/* ===== アップロードゾーン ===== */
.upload-zone {
  border: 3px dashed #cbd5e0;
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #f8f9fa;
}

.upload-zone:hover {
  border-color: #2c3e50;
  background: #f8f9fa;
  transform: translateY(-2px);
}

.upload-zone.dragover {
  border-color: #2c3e50;
  background: #e9ecef;
  transform: scale(1.02);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.upload-text {
  font-size: 18px;
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 13px;
  color: #6c757d;
}

/* ===== ステータスメッセージ ===== */
.status-message {
  margin-top: 20px;
  padding: 15px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  display: none;
}

.status-message.success {
  display: block;
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-message.error {
  display: block;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* ===== 画像プレビューグリッド ===== */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  margin-top: 30px;
}

.preview-item {
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 10px;
  background: white;
  transition: all 0.2s;
}

.preview-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.preview-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

.preview-filename {
  font-size: 10px;
  color: #6c757d;
  word-break: break-all;
  text-align: center;
}

/* ===== CSV情報ボックス ===== */
.csv-info-box {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}

.csv-info-box h3 {
  font-size: 16px;
  color: #2c3e50;
  margin-bottom: 12px;
}

.csv-info-box pre {
  background: white;
  padding: 15px;
  border-radius: 6px;
  font-size: 12px;
  overflow-x: auto;
  border: 1px solid #bbdefb;
  font-family: 'Courier New', monospace;
}

.template-link {
  display: inline-block;
  margin-top: 12px;
  color: #1565c0;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.template-link:hover {
  text-decoration: underline;
}

/* ===== CSVプレビュー ===== */
.csv-preview {
  margin-top: 25px;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  display: none;
}

.csv-preview.show {
  display: block;
}

.csv-preview h3 {
  font-size: 16px;
  margin-bottom: 15px;
  color: #2c3e50;
}

.csv-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
}

.csv-table th {
  background: #2c3e50;
  color: white;
  padding: 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.csv-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e9ecef;
  font-size: 12px;
}

.csv-table tr:hover {
  background: #f8f9fa;
}

/* ===== マッチング画面 ===== */
.matching-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 25px;
}

.status-indicator {
  font-size: 16px;
  font-weight: 600;
}

.status-label {
  color: #6c757d;
}

.status-count {
  color: #2c3e50;
  margin-left: 10px;
}

.progress-percentage {
  font-size: 24px;
  font-weight: 700;
  color: #27ae60;
}

.matching-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
}

.product-panel,
.gallery-panel {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  max-height: 700px;
  overflow-y: auto;
}

.product-panel {
  overflow-y: auto;
}

.gallery-panel {
  display: flex;
  flex-direction: column;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #dee2e6;
}

/* ===== 商品カード ===== */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.product-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 15px;
  transition: all 0.2s;
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-header {
  margin-bottom: 12px;
}

.product-name {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 6px;
}

.product-meta {
  display: flex;
  gap: 15px;
  font-size: 13px;
  color: #6c757d;
}

.product-price {
  font-weight: 600;
  color: #2c3e50;
}

.product-taste {
  background: #f8f9fa;
  padding: 2px 8px;
  border-radius: 4px;
}

.drop-zone {
  border: 2px dashed #cbd5e0;
  border-radius: 8px;
  padding: 15px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  transition: all 0.3s;
  text-align: center;
  color: #6c757d;
  font-size: 13px;
}

.drop-zone.dragover {
  border-color: #667eea;
  background: #e3edff;
  transform: scale(1.02);
}

.drop-zone.has-image {
  border-color: #28a745;
  background: #d4edda;
  padding: 10px;
}

.drop-zone img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
  border-radius: 4px;
}

/* ===== 画像ギャラリー ===== */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  padding-right: 10px;
}

.product-panel::-webkit-scrollbar,
.gallery-panel::-webkit-scrollbar {
  width: 8px;
}

.product-panel::-webkit-scrollbar-track,
.gallery-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.product-panel::-webkit-scrollbar-thumb,
.gallery-panel::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 10px;
}

.product-panel::-webkit-scrollbar-thumb:hover,
.gallery-panel::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.gallery-item {
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 8px;
  background: white;
  cursor: grab;
  transition: all 0.2s;
}

.gallery-item:active {
  cursor: grabbing;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-color: #667eea;
}

.gallery-item.used {
  opacity: 0.4;
  cursor: not-allowed;
}

.gallery-item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 6px;
}

.gallery-filename {
  font-size: 9px;
  color: #6c757d;
  word-break: break-all;
  text-align: center;
  line-height: 1.3;
}

/* ===== 生成セクション ===== */
.generate-section {
  text-align: center;
  padding: 40px;
}

.generate-btn {
  background: #2c3e50;
  color: white;
  border: none;
  padding: 18px 50px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.generate-btn:hover:not(:disabled) {
  background: #34495e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(-1px);
}

.generate-btn:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-icon {
  font-size: 24px;
}

.generate-hint {
  margin-top: 15px;
  color: #6c757d;
  font-size: 14px;
}

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

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 6px 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-text {
  color: white;
  margin-top: 20px;
  font-size: 18px;
  font-weight: 600;
}

/* ===== レスポンシブ ===== */
@media (max-width: 1024px) {
  .matching-area {
    grid-template-columns: 1fr;
  }
  
  .gallery-panel {
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  .container {
    border-radius: 0;
  }
  
  .main-title {
    font-size: 24px;
  }
  
  .progress-bar {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .progress-line {
    display: none;
  }
  
  .step-section {
    padding: 20px;
  }
  
  .generate-btn {
    padding: 15px 40px;
    font-size: 16px;
  }
}
