/* ==================== 
   商品名自動修正侍 - CSS
   楽天カラーテーマ
   ==================== */

/* ========== 変数 ========== */
:root {
  --rakuten-red: #bf0000;
  --rakuten-red-dark: #a00000;
  --rakuten-red-light: #ff4444;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ========== リセット ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== ヘッダー ========== */
.header {
  background: var(--rakuten-red);
  color: var(--white);
  padding: 0 20px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: bold;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 18px;
  letter-spacing: 1px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ========== メイン ========== */
.main {
  flex: 1;
  padding: 40px 20px;
}

/* ========== ログイン画面 ========== */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login-header {
  background: var(--rakuten-red);
  color: var(--white);
  padding: 30px;
  text-align: center;
}

.login-icon {
  font-size: 50px;
  margin-bottom: 10px;
}

.login-header h1 {
  font-size: 22px;
  margin-bottom: 5px;
}

.login-header p {
  font-size: 13px;
  opacity: 0.9;
}

.login-form {
  padding: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--rakuten-red);
  box-shadow: 0 0 0 3px rgba(191, 0, 0, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--gray-400);
}

.form-group small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--gray-500);
}

.error-message {
  color: var(--error);
  font-size: 14px;
  margin-bottom: 15px;
  padding: 10px;
  background: #fef2f2;
  border-radius: var(--radius);
  display: none;
}

.error-message.show {
  display: block;
}

.login-footer {
  padding: 15px 30px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
}

/* ========== ボタン ========== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--rakuten-red);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--rakuten-red-dark);
}

.btn-primary:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 18px;
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-danger {
  padding: 10px 18px;
  background: var(--error);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 18px;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1;
}

.btn-loading {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== スピナー ========== */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner-dark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--rakuten-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.spinner-large {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--rakuten-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== ダッシュボード ========== */
.dashboard {
  background: var(--gray-100);
}

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

/* ステータスカード */
.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
}

.card-icon {
  font-size: 36px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.card-content h3 {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: normal;
  margin-bottom: 4px;
}

.card-content p {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}

/* カード */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 25px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 20px;
}

.card-header .card-title {
  margin-bottom: 0;
}

/* 商品サマリー */
.items-summary {
  margin-bottom: 15px;
  padding: 10px 15px;
  background: var(--gray-50);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-600);
}

/* タブナビゲーション */
.tab-nav {
  display: flex;
  gap: 5px;
  background: var(--white);
  padding: 5px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.tab-btn.active {
  background: var(--rakuten-red);
  color: var(--white);
}

/* タブコンテンツ */
.tab-content {
  display: none;
}

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

/* 設定フォーム */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
  margin-bottom: 25px;
}

.checkbox-group {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--rakuten-red);
}

.form-actions {
  display: flex;
  gap: 15px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

.form-actions .btn-primary {
  width: auto;
  padding: 12px 30px;
}

/* テーブル */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table .loading {
  text-align: center;
  color: var(--gray-500);
  padding: 30px;
}

.data-table .item-number {
  font-family: monospace;
  font-size: 13px;
  color: var(--gray-800);
}

.data-table .item-title {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--gray-600);
}

/* ステータスバッジ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-active {
  background: var(--rakuten-red);
  color: var(--white);
}

.badge-gray {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* 手動実行 */
.manual-run-section {
  text-align: center;
}

.warning-box {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 30px;
  text-align: left;
}

.warning-box strong {
  color: #92400e;
}

.warning-box p {
  margin-top: 8px;
  font-size: 14px;
  color: #78350f;
}

.run-actions {
  margin: 30px 0;
}

.run-result {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  text-align: left;
}

.run-result h4 {
  margin-bottom: 10px;
  color: var(--gray-700);
}

.run-result.success {
  background: #d1fae5;
  border: 1px solid var(--success);
}

.run-result.error {
  background: #fee2e2;
  border: 1px solid var(--error);
}

/* ========== モーダル ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-sm {
  max-width: 400px;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

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

.modal-body {
  padding: 25px;
  overflow-y: auto;
}

.modal-body .form-group:last-child {
  margin-bottom: 0;
}

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

.modal-footer .btn-primary {
  width: auto;
  padding: 10px 20px;
}

.delete-target {
  margin: 15px 0;
  padding: 15px;
  background: var(--gray-100);
  border-radius: var(--radius);
  text-align: center;
  font-size: 15px;
}

.text-muted {
  color: var(--gray-500);
  font-size: 13px;
}

/* ========== モーダルローディングオーバーレイ（リッチアニメーション版） ========== */
.modal-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: var(--radius-lg);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-loading-content {
  text-align: center;
  padding: 30px;
}

/* ========== 商品追加用アニメーション ========== */
.loading-animation {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 25px;
}

/* 中央のパッケージアイコン */
.loading-package {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 50px;
  animation: packageBounce 1s ease-in-out infinite;
  z-index: 2;
}

@keyframes packageBounce {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
  }
  50% { 
    transform: translate(-50%, -60%) scale(1.1);
  }
}

/* 回転するリング */
.loading-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 4px solid transparent;
  border-top-color: var(--rakuten-red);
  border-radius: 50%;
  animation: ringRotate 1.2s linear infinite;
}

.loading-ring::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border: 4px solid transparent;
  border-top-color: var(--rakuten-red-light);
  border-radius: 50%;
  animation: ringRotate 1.5s linear infinite reverse;
}

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

/* パルスエフェクト */
.loading-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  margin: -40px 0 0 -40px;
  border-radius: 50%;
  background: var(--rakuten-red);
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}

.loading-pulse:nth-child(2) {
  animation-delay: 0.5s;
}

@keyframes pulse {
  0% {
    transform: scale(0.5);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ドットアニメーション */
.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.loading-dot {
  width: 10px;
  height: 10px;
  background: var(--rakuten-red);
  border-radius: 50%;
  animation: dotJump 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotJump {
  0%, 60%, 100% { 
    transform: translateY(0);
    background: var(--rakuten-red);
  }
  30% { 
    transform: translateY(-12px);
    background: var(--rakuten-red-light);
  }
}

/* プログレスバー */
.loading-progress {
  width: 200px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto 20px;
  position: relative;
}

.loading-progress-bar {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--rakuten-red), var(--rakuten-red-light));
  border-radius: 3px;
  animation: progressMove 1.5s ease-in-out infinite;
}

@keyframes progressMove {
  0% { 
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(250%);
  }
  100% { 
    transform: translateX(-100%);
  }
}

/* テキスト */
.loading-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 13px;
  color: var(--gray-500);
}

/* ========== 削除用アニメーション ========== */
.loading-delete-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
}

.loading-delete-icon {
  font-size: 50px;
  animation: deleteShake 0.4s ease-in-out infinite;
}

@keyframes deleteShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  75% { transform: rotate(15deg); }
}

/* 消えていくパーティクル */
.delete-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
}

.delete-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  animation: particleFly 1s ease-out infinite;
}

.delete-particle:nth-child(1) { animation-delay: 0s; top: 50%; left: 50%; }
.delete-particle:nth-child(2) { animation-delay: 0.1s; top: 50%; left: 50%; }
.delete-particle:nth-child(3) { animation-delay: 0.2s; top: 50%; left: 50%; }
.delete-particle:nth-child(4) { animation-delay: 0.3s; top: 50%; left: 50%; }

@keyframes particleFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx, 30px), var(--ty, -30px)) scale(0);
    opacity: 0;
  }
}

.delete-particle:nth-child(1) { --tx: -40px; --ty: -40px; }
.delete-particle:nth-child(2) { --tx: 40px; --ty: -40px; }
.delete-particle:nth-child(3) { --tx: -40px; --ty: 40px; }
.delete-particle:nth-child(4) { --tx: 40px; --ty: 40px; }

/* ========== フッター ========== */
.footer {
  background: var(--gray-800);
  color: var(--gray-400);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* ========== トースト通知 ========== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

.toast.warning {
  background: var(--warning);
  color: var(--gray-800);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========== レスポンシブ ========== */
@media (max-width: 768px) {
  .header-inner {
    height: 55px;
  }
  
  .logo-text {
    font-size: 15px;
  }
  
  .main {
    padding: 20px 15px;
  }
  
  .tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-btn {
    flex: none;
    min-width: auto;
    padding: 10px 15px;
    font-size: 13px;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn-primary {
    width: 100%;
  }
  
  .data-table {
    font-size: 12px;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .header-actions .btn-sm {
    flex: 1;
  }
}
