/* ============================================================
   CSV 文字化け修正ツール - スタイルシート v2
   ============================================================ */

/* リセット & ベース */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
  line-height: 1.6;
}

/* ============================================================
   レイアウト
   ============================================================ */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }

.app-main {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ============================================================
   ヘッダー
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, #1a56db 0%, #0ea5e9 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(26,86,219,.3);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
}
.header-left {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.header-logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.55rem; font-weight: 700; letter-spacing: .02em;
}
.header-logo i { font-size: 1.75rem; opacity: .9; }
.header-sub { margin-top: 5px; font-size: .87rem; opacity: .85; font-weight: 300; }

/* ヘッダーロゴ */
.header-brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.header-brand a {
  display: flex;
  align-items: center;
  opacity: .92;
  transition: opacity .2s;
}
.header-brand a:hover { opacity: 1; }
.header-brand-logo {
  height: 44px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.18));
}

/* ============================================================
   ステップバナー
   ============================================================ */
.info-banner {
  background: #fff;
  border-radius: 14px;
  padding: 22px 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 5px rgba(0,0,0,.07);
}
.info-banner-inner {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
}
.info-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; flex: 1; min-width: 100px; text-align: center;
}
.info-item i {
  font-size: 1.7rem; color: #1a56db;
  background: #eff6ff;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.info-item p { font-size: .82rem; color: #4a5568; font-weight: 500; line-height: 1.5; }
.info-arrow { color: #a0aec0; font-size: 1.1rem; flex-shrink: 0; }

/* ============================================================
   変換オプションパネル
   ============================================================ */
.options-panel {
  background: #fff;
  border-radius: 14px;
  padding: 20px 24px 22px;
  margin-bottom: 24px;
  box-shadow: 0 1px 5px rgba(0,0,0,.07);
}
.options-title {
  font-size: 1rem; font-weight: 700; color: #2d3748;
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.options-title i { color: #1a56db; }

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.option-group { display: flex; flex-direction: column; gap: 6px; }

.option-label {
  font-size: .85rem; font-weight: 600; color: #374151;
  display: flex; align-items: center; gap: 6px;
}
.option-label i { color: #1a56db; }

.select-wrap { position: relative; }
.option-select {
  width: 100%;
  appearance: none;
  background: #f9fafb;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 9px 36px 9px 12px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  color: #1f2937;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.option-select:focus {
  outline: none;
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.select-arrow {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: #9ca3af; font-size: .75rem; pointer-events: none;
}
.option-hint { font-size: .77rem; color: #9ca3af; }

/* ============================================================
   ドロップゾーン
   ============================================================ */
.drop-section { margin-bottom: 24px; }

.drop-zone {
  background: #fff;
  border: 2.5px dashed #93c5fd;
  border-radius: 16px;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .25s ease;
}
.drop-zone:hover {
  border-color: #1a56db; background: #eff6ff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26,86,219,.12);
}
.drop-zone.drag-over {
  border-color: #1a56db; background: #dbeafe;
  transform: scale(1.01);
  box-shadow: 0 12px 32px rgba(26,86,219,.2);
}
.drop-zone-content { pointer-events: none; }
.drop-zone-content label,
.drop-zone-content input { pointer-events: all; }

.drop-icon-wrap { margin-bottom: 14px; }
.drop-icon {
  font-size: 3.8rem; color: #93c5fd;
  transition: color .25s, transform .25s;
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  color: #1a56db;
  transform: translateY(-4px) scale(1.1);
}
.drop-main-text { font-size: 1.15rem; font-weight: 600; color: #2d3748; margin-bottom: 8px; }
.drop-sub-text  { font-size: .88rem; color: #a0aec0; margin-bottom: 14px; }
.file-select-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
  color: #fff; padding: 11px 26px; border-radius: 50px;
  font-size: .93rem; font-weight: 600; cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 12px rgba(26,86,219,.3);
}
.file-select-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(26,86,219,.4); }
#fileInput, #addMoreInput { display: none; }
.drop-note { margin-top: 12px; font-size: .78rem; color: #a0aec0; }

/* ============================================================
   ファイルリストセクション
   ============================================================ */
.file-list-section {
  background: #fff; border-radius: 16px;
  padding: 22px 22px 16px;
  margin-bottom: 24px;
  box-shadow: 0 1px 5px rgba(0,0,0,.07);
}
.file-list-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.file-list-header h2 {
  font-size: 1.05rem; font-weight: 700; color: #2d3748;
  display: flex; align-items: center; gap: 8px;
}
.file-list-header h2 i { color: #1a56db; }
.file-list-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   ファイルアイテム
   ============================================================ */
.file-list { display: flex; flex-direction: column; gap: 8px; }

.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; transition: all .2s; flex-wrap: wrap;
  animation: fadeInUp .28s ease both;
}
.file-item:hover { background: #eff6ff; border-color: #bfdbfe; }

.file-item-icon {
  flex-shrink: 0; width: 38px; height: 38px;
  background: #dbeafe; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #1a56db; font-size: 1rem;
}
.file-item-info { flex: 1; min-width: 0; }
.file-item-name {
  font-size: .92rem; font-weight: 600; color: #2d3748;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-item-meta {
  display: flex; gap: 8px; margin-top: 3px; flex-wrap: wrap; align-items: center;
}
.file-item-size  { font-size: .76rem; color: #718096; }
.file-item-encoding {
  font-size: .74rem; padding: 2px 8px;
  border-radius: 50px; font-weight: 600;
}
.encoding-utf8    { background: #fef3c7; color: #92400e; }
.encoding-sjis    { background: #d1fae5; color: #065f46; }
.encoding-other   { background: #fce7f3; color: #9d174d; }
.encoding-unknown { background: #f3f4f6; color: #6b7280; }

/* プログレスバー */
.file-item-progress {
  width: 100%; height: 3px; background: #e2e8f0;
  border-radius: 2px; margin-top: 6px; overflow: hidden;
}
.file-item-progress-bar {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #1a56db, #0ea5e9);
  transition: width .4s ease;
}

/* ステータス */
.file-item-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; flex-shrink: 0;
  min-width: 80px; justify-content: flex-end;
}
.status-waiting    { color: #9ca3af; }
.status-converting { color: #d97706; }
.status-done       { color: #059669; }
.status-error      { color: #dc2626; }

/* アクションボタン */
.file-item-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* プレビューボタン */
.btn-preview {
  background: #eff6ff; color: #1a56db;
  border: 1.5px solid #bfdbfe;
  padding: 6px 10px; border-radius: 7px;
  font-size: .82rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all .2s; white-space: nowrap;
  font-family: inherit; font-weight: 600;
}
.btn-preview:hover { background: #dbeafe; border-color: #93c5fd; transform: translateY(-1px); }
.btn-preview:disabled { background: #f3f4f6; color: #9ca3af; border-color: #e5e7eb; cursor: not-allowed; transform: none; }

/* DLボタン */
.btn-download-single {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; padding: 6px 13px; font-size: .82rem;
  border-radius: 7px; border: none;
  font-family: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all .2s; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(5,150,105,.25);
}
.btn-download-single:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(5,150,105,.35); }
.btn-download-single:disabled {
  background: #d1d5db; color: #9ca3af;
  cursor: not-allowed; transform: none; box-shadow: none;
}

/* 削除ボタン */
.btn-remove {
  background: transparent; color: #9ca3af;
  border: none; padding: 6px; cursor: pointer;
  border-radius: 6px; font-size: .88rem;
  transition: all .15s;
}
.btn-remove:hover { background: #fee2e2; color: #dc2626; }

/* ============================================================
   一括ダウンロードバー
   ============================================================ */
.bulk-download-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding: 14px 18px;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border: 1px solid #6ee7b7; border-radius: 12px;
  flex-wrap: wrap; gap: 12px;
}
.bulk-info {
  display: flex; align-items: center; gap: 10px;
  font-size: .92rem; font-weight: 700; color: #065f46;
}
.bulk-info i { font-size: 1.25rem; color: #059669; }

/* ============================================================
   共通ボタン
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: 8px;
  font-family: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-sm  { padding: 7px 12px; font-size: .82rem; }
.btn-lg  { padding: 11px 22px; font-size: .93rem; }
.btn-primary {
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
  color: #fff; box-shadow: 0 2px 8px rgba(26,86,219,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,.35); }
.btn-secondary {
  background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #e5e7eb; transform: translateY(-1px); }
.btn-download {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; box-shadow: 0 3px 10px rgba(5,150,105,.3);
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(5,150,105,.4); }

/* ============================================================
   使い方ガイド
   ============================================================ */
.guide-section { margin-top: 32px; }
.guide-section h2 {
  font-size: 1.05rem; font-weight: 700; color: #2d3748; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.guide-section h2 i { color: #1a56db; }
.guide-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px;
}
.guide-card {
  background: #fff; border-radius: 12px; padding: 20px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: transform .2s, box-shadow .2s;
}
.guide-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.guide-step {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
  color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .88rem; margin-bottom: 10px;
}
.guide-card h3 { font-size: .92rem; font-weight: 700; color: #2d3748; margin-bottom: 6px; }
.guide-card p  { font-size: .8rem; color: #718096; line-height: 1.6; }

/* ============================================================
   フッター
   ============================================================ */
.app-footer {
  background: #1e293b; color: #94a3b8;
  text-align: center; padding: 16px 20px; font-size: .8rem;
}
.app-footer i { color: #38bdf8; margin-right: 4px; }

/* ============================================================
   アニメーション
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(22px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(22px); }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fa-spin-custom { animation: spin 1s linear infinite; display: inline-block; }

/* ============================================================
   トースト通知
   ============================================================ */
.toast-container {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-radius: 10px;
  font-size: .86rem; font-weight: 500;
  min-width: 250px; max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,.13);
  animation: slideInRight .28s ease;
}
.toast-success { background: #d1fae5; color: #065f46; border-left: 4px solid #059669; }
.toast-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.toast-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #1a56db; }

/* ============================================================
   プレビューモーダル
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  z-index: 8000;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%; max-width: 900px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: modalIn .28s ease;
  overflow: hidden;
}

/* モーダルヘッダー */
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1.5px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}
.modal-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1rem; font-weight: 700; color: #1e293b;
  min-width: 0;
}
.modal-title i { color: #1a56db; flex-shrink: 0; }
.modal-filename {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-close {
  background: #f1f5f9; border: none; color: #64748b;
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; }

/* タブ */
.modal-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1.5px solid #e2e8f0;
  flex-shrink: 0; flex-wrap: wrap;
}
.modal-tab {
  padding: 8px 18px; border: none; border-radius: 8px 8px 0 0;
  background: transparent; color: #64748b;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  border-bottom: 2.5px solid transparent;
  display: flex; align-items: center; gap: 6px;
}
.modal-tab-label {
  padding: 8px 18px;
  color: #1a56db;
  font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 2.5px solid #1a56db;
}
.preview-row-count {
  margin-left: auto; font-size: .78rem; color: #94a3b8; font-weight: 500;
  padding-bottom: 4px;
}

/* モーダルボディ */
.modal-body {
  flex: 1; overflow: auto; padding: 0;
}

/* プレビューテーブルラッパー */
.preview-table-wrap {
  padding: 16px;
  overflow-x: auto;
  min-height: 200px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  white-space: nowrap;
}
.preview-table th {
  position: sticky; top: 0;
  background: #1e293b; color: #e2e8f0;
  padding: 9px 14px; text-align: left;
  font-weight: 600; font-size: .8rem;
  border-right: 1px solid #334155;
  z-index: 1;
}
.preview-table th:last-child { border-right: none; }
.preview-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  color: #374151; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis;
}
.preview-table td:last-child { border-right: none; }
.preview-table tbody tr:hover { background: #f0f9ff; }
.preview-table tbody tr:nth-child(even) { background: #fafafa; }
.preview-table tbody tr:nth-child(even):hover { background: #f0f9ff; }

.preview-empty {
  text-align: center; color: #94a3b8;
  padding: 40px 20px; font-size: .9rem;
}
.preview-loading {
  text-align: center; color: #64748b;
  padding: 40px 20px; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.preview-truncate {
  text-align: center; color: #d97706;
  font-size: .8rem; padding: 10px;
  background: #fef3c7; border-radius: 8px; margin-top: 10px;
}

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 640px) {
  .header-logo { font-size: 1.2rem; }
  .header-brand-logo { height: 34px; }
  .info-arrow  { display: none; }
  .info-item   { min-width: 80px; }
  .drop-zone   { padding: 34px 16px; }
  .drop-main-text { font-size: 1rem; }
  .file-list-header { flex-direction: column; align-items: flex-start; }
  .bulk-download-bar { flex-direction: column; align-items: flex-start; }
  .guide-grid { grid-template-columns: 1fr 1fr; }
  .toast-container { bottom: 10px; right: 10px; left: 10px; }
  .toast { min-width: 0; max-width: 100%; }
  .modal-box { max-height: 96vh; border-radius: 12px; }
  .file-item-status { min-width: auto; }
}
@media (max-width: 420px) {
  .guide-grid { grid-template-columns: 1fr; }
  .options-grid { grid-template-columns: 1fr; }
}
