/* ============================================================
   csv-download.css
   CSVダウンロード画面 スタイル
   ============================================================ */

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background: #f0f2f5;
}

/* ============================================================
   Layout
   ============================================================ */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1a365d 0%, #2d4a7a 100%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.app-header .header-sub {
  font-size: 12px;
  opacity: 0.8;
}
.app-header .header-note {
  font-size: 12px;
  opacity: 0.7;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  padding: 32px 24px 40px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================
   Download Panel
   ============================================================ */
.download-panel {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid #e8ecf1;
  overflow: hidden;
  margin-bottom: 28px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: #fafbfc;
  border-bottom: 1px solid #e8ecf1;
}
.panel-header-icon {
  font-size: 20px;
}
.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #1a365d;
}

.search-range-limit-hint {
  margin-left: 0;
  text-align: left;
  white-space: nowrap;
}

.panel-body {
  padding: 24px 20px;
}

/* --- Form Grid --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* 検索条件パネル: 横並びレイアウト */
.form-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 0 0 auto;
}
.form-row .form-group input[type="date"] {
  min-width: 160px;
}
.form-row .form-group--btn {
  margin-left: auto;
  align-self: flex-end;
}

.date-range-separator {
  align-self: flex-end;
  height: 40px;
  display: inline-flex;
  align-items: center;
  color: #5a6474;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding-bottom: 1px;
}

.form-grid--full {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #5a6474;
  letter-spacing: 0.3px;
}
.form-group label .required {
  color: #e53e3e;
  margin-left: 2px;
}
.form-group input[type="date"],
.form-group select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #c4cad3;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #2d4a7a;
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.12);
}
.form-hint {
  font-size: 11px;
  color: #8892a0;
  margin-top: 2px;
}

/* --- Action Row --- */
.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #f0f2f5;
  padding-top: 20px;
}

/* --- Buttons --- */
.btn {
  height: 42px;
  padding: 0 28px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-download {
  background: linear-gradient(135deg, #1a365d, #2d4a7a);
  color: #fff;
}
.btn-download:hover {
  background: linear-gradient(135deg, #2d4a7a, #3b5f9a);
  box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
  transform: translateY(-1px);
}
.btn-download:active {
  transform: translateY(0);
}
.btn-download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-download svg {
  width: 18px;
  height: 18px;
}

.btn-search {
  background: linear-gradient(135deg, #2b6cb0, #3182ce);
  color: #fff;
  height: 40px;
  padding: 0 24px;
  font-size: 13px;
}
.btn-search:hover {
  background: linear-gradient(135deg, #3182ce, #4299e1);
  box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
  transform: translateY(-1px);
}
.btn-search:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: #e8ecf1;
  color: #5a6474;
  height: 42px;
  padding: 0 20px;
}
.btn-secondary:hover {
  background: #dde1e6;
}

/* ============================================================
   Status Toast
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: toastIn 0.3s ease;
  max-width: 400px;
}
.toast.toast--success {
  background: #f0fff4;
  color: #22543d;
  border: 1px solid #9ae6b4;
}
.toast.toast--error {
  background: #fff5f5;
  color: #9b2c2c;
  border: 1px solid #feb2b2;
}
.toast.toast--info {
  background: #ebf8ff;
  color: #2a4365;
  border: 1px solid #90cdf4;
}
.toast.toast--hide {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
   File List
   ============================================================ */

/* ツールバー（全選択 + 一括DLボタン） */
.file-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fafbfc;
  border-bottom: 1px solid #e8ecf1;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #5a6474;
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2d4a7a;
}

/* テーブル内チェックボックス列 */
.col-check {
  width: 40px;
  text-align: center;
}
.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2d4a7a;
}

.col-filename {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  color: #2d4a7a;
  font-weight: 500;
}

/* ファイル件数バッジ */
.file-count {
  font-size: 12px;
  font-weight: 600;
  color: #5a6474;
  background: #e8ecf1;
  padding: 2px 10px;
  border-radius: 10px;
  margin-left: auto;
}

.panel-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Download History
   ============================================================ */
.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: #5a6474;
  background: #fafbfc;
  border-bottom: 2px solid #e8ecf1;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f2f5;
  color: #333;
  vertical-align: middle;
}
.history-table tr:hover td {
  background: #f7f8fa;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: #a0a8b4;
  gap: 12px;
}
.history-empty-icon {
  font-size: 40px;
  opacity: 0.4;
}
.history-empty p {
  font-size: 13px;
}

/* Status Badge (in table) */
.dl-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.dl-status--success {
  background: #e6ffed;
  color: #22543d;
  border: 1px solid #9ae6b4;
}
.dl-status--error {
  background: #fee2e2;
  color: #9b2c2c;
  border: 1px solid #feb2b2;
}
.dl-status--loading {
  background: #ebf8ff;
  color: #2a4365;
  border: 1px solid #90cdf4;
}

/* Re-download link */
.re-download-link {
  color: #2d4a7a;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.re-download-link:hover {
  text-decoration: underline;
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-overlay.active {
  display: flex;
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e8ecf1;
  border-top: 4px solid #1a365d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  font-size: 14px;
  color: #5a6474;
  font-weight: 500;
}
@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 12px;
  font-size: 11px;
  color: #a0a8b4;
  background: #f0f2f5;
  border-top: 1px solid #e8ecf1;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .main-content {
    padding: 20px 16px 32px;
  }
  .form-row {
    align-items: stretch;
  }
  .form-row .form-group {
    flex: 1 1 100%;
  }
  .form-row .form-group--btn {
    margin-left: 0;
  }
  .date-range-separator {
    display: none;
  }
  .search-range-limit-hint {
    width: 100%;
    margin-left: 0;
    margin-top: 2px;
    text-align: left;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn {
    justify-content: center;
  }
  .app-header {
    padding: 12px 16px;
  }
  .app-header h1 {
    font-size: 16px;
  }
}
