/* The Goal - Web版 スタイル (最小限) */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-soft: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}

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

/* HTML の hidden 属性を必ず効かせる（display: flex 等の指定を上書き） */
[hidden] { display: none !important; }

/* モーダル表示中は背景スクロール無効 */
body.modal-open { overflow: hidden; }
body {
  font-family: -apple-system, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea {
  font: inherit;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--primary-hover); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  background: white;
}

/* ============ ログイン画面 ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ede9fe 0%, #c7d2fe 100%);
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-sub { color: var(--text-soft); margin: 0 0 24px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--text-soft);
}
.login-card label input {
  font-size: 15px;
  padding: 10px;
}
.login-card button {
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
}

.error-msg {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
}

/* ============ メインアプリ ============ */
.app-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-title {
  font-weight: 700;
  font-size: 16px;
  padding: 14px 0;
}
.view-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.view-tab {
  background: transparent;
  color: var(--text-soft);
  padding: 14px 16px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.view-tab:hover { background: var(--bg); color: var(--text); }
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-area #userBadge {
  font-size: 13px;
  color: var(--text-soft);
}
.user-area button {
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  padding: 6px 10px;
}
.user-area button:hover { background: var(--bg); color: var(--text); }

.app-main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.view-header h2 { margin: 0; font-size: 20px; }
.view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.view-actions input[type="text"] { width: 220px; }

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* ============ タスクカード ============ */
.task-card,
.project-card,
.sns-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.task-card-header h3 { margin: 0; font-size: 15px; }
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 12px;
}
.task-memo {
  background: #f9fafb;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 12px;
}
.task-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.task-card-actions button {
  font-size: 12px;
  padding: 6px 10px;
}
.task-card-actions button:nth-child(n+2) {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.task-card-actions button:nth-child(n+2):hover { background: var(--bg); }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #ddd6fe;
  color: var(--primary-hover);
}
.status-badge.status-done { background: #d1fae5; color: #065f46; }
.status-badge.status-suspended { background: #e5e7eb; color: #6b7280; }
.status-badge.status-active { background: #dbeafe; color: #1e40af; }

.revision { color: var(--danger); font-weight: 600; }
.project-link {
  background: #ede9fe;
  color: #5b21b6;
  padding: 1px 8px;
  border-radius: 8px;
  cursor: pointer;
}

/* ============ パイプライン ============ */
.pipeline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0;
  overflow-x: auto;
}
.stage {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  min-width: 130px;
}
.stage-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  background: var(--bg);
  color: var(--text-soft);
  flex-shrink: 0;
}
.stage-info { flex: 1; min-width: 0; }
.stage-name { font-weight: 600; font-size: 12px; }
.stage-assignee { font-size: 11px; color: var(--text-soft); }
.stage-target {
  display: block;
  font-size: 10px;
  color: var(--text-soft);
}
.stage.done {
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.stage.done .stage-num { background: var(--success); color: white; }
.stage.current {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.stage.current .stage-num { background: var(--primary); color: white; }
.stage.warning {
  background: #fef2f2;
  border-color: #fecaca;
}
.stage.warning .stage-num { background: var(--danger); color: white; }
.stage-arrow {
  color: var(--text-soft);
  font-size: 16px;
}

/* ============ 空状態 ============ */
.empty-state {
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-soft);
}

/* ============ 設定 ============ */
.settings-body details {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
}
.settings-body summary {
  cursor: pointer;
  font-weight: 600;
  padding: 6px 0;
}
.settings-body .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
}
.settings-body .row:last-child { border-bottom: 0; }
.settings-body small { color: var(--text-soft); font-weight: 400; }

.sns-type {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-soft);
}

/* ============ モーダル ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-content {
  position: relative;
  background: white;
  border-radius: 14px;
  width: 720px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.modal-content.modal-sm { width: 460px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  color: var(--text-soft);
  font-size: 24px;
  line-height: 1;
  padding: 0 6px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  align-items: center;
}

.text-btn {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.text-btn:hover { background: var(--bg); }
.danger-btn {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fecaca !important;
}
.danger-btn:hover {
  background: #fecaca !important;
}

/* ============ フォーム ============ */
.form-field {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-field > label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-row > .form-field {
  flex: 1;
}
.form-section-label {
  font-weight: 600;
  font-size: 13px;
  margin: 18px 0 6px;
  color: var(--text-soft);
}
.checkbox-label {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px !important;
  color: var(--text) !important;
}
.checkbox-label input {
  width: auto !important;
  margin: 0;
}
.required {
  color: var(--danger);
  font-weight: 700;
}

/* ============ stages editor ============ */
.stages-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stage-row {
  display: grid;
  grid-template-columns: 24px 1fr 1fr 80px 130px 30px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.stage-row .stage-num-pill {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.stage-row input,
.stage-row select {
  background: white;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.stage-row .stage-del-btn {
  background: transparent;
  color: var(--danger);
  padding: 0;
  font-size: 18px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
}
.stage-row .stage-del-btn:hover {
  background: #fee2e2;
}

/* SNS / プロジェクト用に grid を縮める（status enum を含む） */
.stage-row.proj-stage {
  grid-template-columns: 24px 1.5fr 1.2fr 90px 110px 30px;
}

/* ============ 引継ぎサマリー ============ */
.handoff-summary {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.handoff-summary .from,
.handoff-summary .to {
  display: flex;
  gap: 8px;
  align-items: center;
}
.handoff-summary .arrow {
  text-align: center;
  font-size: 18px;
  color: var(--text-soft);
  margin: 6px 0;
}

/* ============ 納期表示 ============ */
.deadline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.confirmed-date {
  font-weight: 600;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 6px;
}

/* ============ 一覧UIの行 ============ */
.list-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.list-body .list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
}
.list-body .list-row:hover {
  background: #e5e7eb;
  cursor: pointer;
}
.list-body .list-row-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.list-body .list-row-info strong { font-size: 13px; }
.list-body .list-row-info small { color: var(--text-soft); font-size: 12px; }

.text-btn.small {
  padding: 3px 8px;
  font-size: 11px;
  margin-left: 8px;
}

.hint {
  background: #f0f9ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  margin: 0;
}

.settings-body summary {
  display: flex;
  align-items: center;
}

/* ============ レスポンシブ調整 ============ */
@media (max-width: 700px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .stage-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
