/* ==========================================================================
   RSD - 共通スタイル
   Primary: #1e293b (ネイビー)   Accent: #3b82f6 (ブルー)
   ========================================================================== */

:root {
  --color-primary: #1e293b;
  --color-primary-dark: #0f172a;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-danger: #dc2626;
  --color-info: #3b82f6;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --sidebar-width: 220px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic Pro",
               "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0 0 0.6em 0;
  color: var(--color-primary);
  font-weight: 600;
}
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover,
.btn:hover { background: var(--color-accent-hover); }
button.secondary,
.btn.secondary {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.secondary:hover,
.btn.secondary:hover { background: #f1f5f9; }
button.danger,
.btn.danger { background: var(--color-danger); }
button.danger:hover { background: #b91c1c; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  box-sizing: border-box;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
textarea { min-height: 120px; resize: vertical; }

label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-field { margin-bottom: 14px; }

/* ===== レイアウト（サイドバー + メイン） ===== */
.layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-primary);
  color: #cbd5e1;
  padding: 20px 0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 0 20px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #334155;
  margin-bottom: 14px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #cbd5e1;
  font-size: 14px;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover {
  background: #334155;
  color: #fff;
}
.sidebar nav a.active {
  background: #334155;
  color: #fff;
  border-left-color: var(--color-accent);
}
.sidebar .user-box {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  font-size: 12px;
  color: #94a3b8;
  border-top: 1px solid #334155;
  padding-top: 12px;
}
.sidebar .user-box .name { color: #fff; font-weight: 600; margin-bottom: 4px; }
.sidebar .user-box button.logout {
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid #475569;
  font-size: 12px;
  padding: 6px;
}
.sidebar .user-box button.logout:hover { background: #334155; }

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  max-width: calc(100vw - var(--sidebar-width));
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* ===== カード ===== */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ===== テーブル ===== */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
th {
  background: #f1f5f9;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:hover td { background: #f8fafc; }

/* ===== バッジ ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-todo        { background: #e2e8f0; color: #475569; }
.badge-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-done        { background: #dcfce7; color: #15803d; }
.badge-active      { background: #dcfce7; color: #15803d; }
.badge-paused      { background: #fef3c7; color: #a16207; }
.badge-completed   { background: #e2e8f0; color: #475569; }
.badge-high        { background: #fee2e2; color: #b91c1c; }
.badge-medium      { background: #fef3c7; color: #a16207; }
.badge-low         { background: #e2e8f0; color: #475569; }

/* ===== アラート ===== */
.alert-overdue {
  background: #fee2e2;
  border-left: 4px solid var(--color-danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.alert-soon {
  background: #ffedd5;
  border-left: 4px solid var(--color-warning);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
}

/* ===== プログレスバー ===== */
.progress {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s;
}

/* ===== タブ ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 20px;
}
.tabs button {
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  padding: 10px 18px;
  font-weight: 500;
}
.tabs button.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
.tabs button:hover { background: #f1f5f9; color: var(--color-accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== モーダル ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}
.modal h2 { margin-top: 0; }
.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ===== ログインページ ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  padding: 36px 32px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  text-align: center;
  margin-bottom: 24px;
}
.login-card .brand-sub {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: -16px;
  margin-bottom: 24px;
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
}
.login-card .error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  display: none;
}
.login-card .error-msg.show { display: block; }

/* ===== カンバン ===== */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kanban-col {
  background: #f1f5f9;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 400px;
}
.kanban-col h3 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kanban-card {
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  border-left: 3px solid var(--color-accent);
  font-size: 13px;
}
.kanban-card:hover { box-shadow: var(--shadow-hover); }
.kanban-col .add-btn {
  width: 100%;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px dashed #94a3b8;
  padding: 8px;
  margin-top: 4px;
  font-size: 12px;
}
.kanban-col .add-btn:hover { background: #e2e8f0; color: var(--color-text); }

/* ===== WBSツリー ===== */
.wbs-tree { list-style: none; padding: 0; margin: 0; }
.wbs-tree li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.wbs-tree li.level-1 { font-weight: 600; background: #f8fafc; }
.wbs-tree li.level-2 { padding-left: 32px; }
.wbs-tree li.level-3 { padding-left: 56px; font-size: 13px; color: var(--color-text-muted); }
.wbs-tree .wbs-title { flex: 1; }
.wbs-tree .wbs-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}
.wbs-tree input[type="range"] { width: 80px; }

/* ===== Wiki ===== */
.markdown-body {
  background: #fff;
  padding: 24px 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  line-height: 1.8;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 { margin-top: 1.2em; }
.markdown-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
}
.markdown-body code {
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.markdown-body blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: 14px;
  color: var(--color-text-muted);
  margin-left: 0;
}

/* ===== ユーティリティ ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap-8 { display: flex; gap: 8px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 12px; }
.hidden { display: none !important; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
