/* ==========================================================================
   ResumeDateCalc - プロトコル第18条 / プロジェクト統計ツール準拠スタイルシート
   ========================================================================== */

:root {
  --bg-app: #09090b;
  --bg-card: #121215;
  --bg-card-hover: #18181c;
  --bg-inset: #050506;
  --border-color: #27272a;
  --border-color-hover: #3f3f46;
  --border-focus: #3b82f6;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #8b8b95;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-color-hover);
}

/* App Container */
.app-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Header */
.app-header {
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.badge-privacy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 3px 10px;
  border-radius: 9999px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
}

.app-subtitle {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Card Component */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-color-hover);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  color: var(--accent-blue);
}

/* Form Elements */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

/* 3択のセグメントは狭い列に入れるとラベルが縦積みになるため、行いっぱいに広げる (I-01 の見た目) */
.form-group:has(.segmented-control) {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.select-input,
.text-input {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.select-input:focus,
.text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.text-input::placeholder {
  color: var(--text-muted);
}

/* Radio Group & Segmented Control */
.segmented-control {
  display: flex;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 3px;
  gap: 4px;
}

@media (max-width: 520px) {
  /* 画面が狭いときは3択を縦に並べる（1列に3つ並べるとラベルが縦積みになるため） */
  .segmented-control {
    flex-direction: column;
  }
  .segmented-control label {
    text-align: left;
  }
}

.segmented-control label {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.segmented-control input[type="radio"] {
  /* display:none だと Tab で到達できず、キーボードで選択できない (I-01)。
     見た目は label 側で描くため、要素自体は 1px の透明な状態で残す。 */
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.segmented-control input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.segmented-control input[type="radio"]:checked + label {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color-hover);
}

/* Metrics Grid (プロジェクト統計ツール MetricCards準拠) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease;
}

.metric-card:hover {
  border-color: var(--border-color-hover);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Notice Banner (厄年・年祝い) */
.banner-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.banner-yakudoshi {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
}

.banner-celebration {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.banner-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.banner-yakudoshi .banner-tag {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.banner-celebration .banner-tag {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
}

/* Academic History Table */
.table-container {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  /* スマホ幅では表がはみ出すため、切り取らず横スクロールさせる */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
}

.resume-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.resume-table th {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.resume-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  vertical-align: middle;
}

.resume-table tr:last-child td {
  border-bottom: none;
}

.resume-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.col-date {
  font-family: var(--font-mono);
  color: var(--text-primary);
  white-space: nowrap;
  width: 260px;
}

.col-status {
  width: 100px;
}

.col-school {
  min-width: 240px;
}

.badge-status {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
}

.badge-enter {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-grad {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.table-input {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 6px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease;
}

.table-input:focus {
  border-color: var(--border-focus);
}

/* Action Area */
.action-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

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

.btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #60a5fa;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.action-tip {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Footer */
.app-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--text-primary);
}

/* Toast Component */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: #18181c;
  color: var(--text-primary);
  border: 1px solid var(--border-color-hover);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  color: var(--accent-emerald);
}

/* Responsive Design */
@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .col-date {
    width: auto;
    font-size: 0.8125rem;
  }

  .action-area {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    justify-content: center;
  }
}

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

  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }
}
