/* ============================================================
   EC月次診断 - スタイルシート
   PCファースト・シンプル・白ベース
   ============================================================ */

:root {
  --color-primary: #0d1f3c;
  --color-primary-hover: #0a1829;
  --color-text: #0d1f3c;
  --color-text-muted: #8896a7;
  --color-bg: #f7f6f3;
  --color-card: #ffffff;
  --color-border: #e0ddd8;
  --color-success: #059669;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --max-width: 800px;
  --radius: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================================
   Typography
   ============================================================ */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.375rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ============================================================
   Form
   ============================================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--color-text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 31, 60, 0.1);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
  text-decoration: none;
}

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

.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover { background: var(--color-bg); }

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-full { width: 100%; }

/* ============================================================
   Header / Nav
   ============================================================ */
.header {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
}

.header-nav a {
  margin-left: 1.5rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.header-nav a:hover { color: var(--color-text); }

/* ============================================================
   Upload Drop Zone
   ============================================================ */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(13, 31, 60, 0.03);
}

.drop-zone-text {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* ============================================================
   Badge
   ============================================================ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
}

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

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

.badge-info {
  background: #e8edf5;
  color: #0d1f3c;
}

/* ============================================================
   Report / Markdown
   ============================================================ */
.report-content {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  line-height: 1.8;
}

.report-content h1 { font-size: 1.5rem; margin-top: 0; }
.report-content h2 { font-size: 1.25rem; margin-top: 2rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; }
.report-content h3 { font-size: 1.1rem; margin-top: 1.5rem; }
.report-content pre { overflow-x: auto; padding: 1rem; background: var(--color-bg); border-radius: var(--radius); font-size: 0.8125rem; max-width: 100%; }
.report-content code { font-size: 0.8125rem; }
.report-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.report-content th, .report-content td { border: 1px solid var(--color-border); padding: 0.5rem 0.75rem; text-align: left; font-size: 0.875rem; }
.report-content th { background: var(--color-bg); font-weight: 600; }

/* ============================================================
   Alert / Banner
   ============================================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error { background: #fef2f2; color: var(--color-error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: var(--color-warning); border: 1px solid #fde68a; }

/* ============================================================
   Spinner
   ============================================================ */
.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
}

/* ============================================================
   Utilities
   ============================================================ */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.hidden { display: none; }


/* ============================================================
   Section Label
   ============================================================ */
.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #6b7a8d;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.625rem;
}

/* ============================================================
   Dashboard 2-column grid
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* 分析ドット */
.analysis-dots { display: flex; gap: 6px; }
.analysis-dot { width: 24px; height: 24px; border-radius: 50%; }
.analysis-dot.active { background: var(--color-primary); }
.analysis-dot.inactive { background: var(--color-bg); border: 1px solid var(--color-border); }

/* レポートリンクカード */
.report-link-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.report-link-card:hover { border-color: #b8cce0; }

/* アップロードパネル（右カラム） */
.upload-panel {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* プリセットピルボタン */
.preset-pill {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.preset-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.preset-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* プリセットチェックボックスラベル（廃止予定・互換用） */
.preset-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
}

/* ============================================================
   Password Toggle
   ============================================================ */
.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 2.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
}

.password-toggle:hover {
  color: var(--color-text);
}


/* ============================================================
   Report Tab Bar
   ============================================================ */
.report-tab-bar {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.report-tab {
  padding: 0.5rem 1.25rem;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s, border-color 0.15s;
}

.report-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.report-tab:hover:not(.active) {
  color: var(--color-text);
}


/* ============================================================
   Responsive (Mobile)
   ============================================================ */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .header {
    padding: 0.5rem 1rem;
  }

  .header-nav a {
    margin-left: 1rem;
    font-size: 0.8125rem;
  }

  .flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .flex.gap-1 {
    width: 100%;
  }

  .flex.gap-1 .btn {
    flex: 1;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
  }

  .report-tab-bar {
    overflow-x: auto;
  }

  .report-tab {
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
  }

  .report-content {
    padding: 1rem;
    overflow-x: auto;
  }

  .report-content table {
    font-size: 0.75rem;
  }

  .report-content pre {
    display: none;
  }

  .report-content code {
    word-break: break-all;
  }

  h1 {
    font-size: 1.375rem;
  }
}
