/* =============================================
   組織運営アシストシステム - メインスタイル
   ============================================= */

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;

  --bg: #f1f5f9;
  --sidebar-bg: #1e1b4b;
  --sidebar-active: #312e81;
  --sidebar-text: #c7d2fe;
  --sidebar-width: 260px;
  --topbar-height: 64px;

  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 24px rgba(79,70,229,.15);

  --transition: .2s ease;
}

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

html { font-size: 15px; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   サイドバー
   ============================================= */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo-area i {
  font-size: 1.5rem;
  color: #a5b4fc;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}

.logo-sub {
  font-size: .72rem;
  color: #818cf8;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.sidebar-nav ul { list-style: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  opacity: .8;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 3px solid #818cf8;
}

.nav-item.active i { opacity: 1; }

.nav-item.active::after {
  content: '';
  position: absolute;
  right: -1px; top: 0;
  width: 3px; height: 100%;
  background: #818cf8;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: .9rem;
  flex-shrink: 0;
}

.user-name {
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
}

.user-role {
  font-size: .72rem;
  color: #818cf8;
}

/* =============================================
   メインラッパー
   ============================================= */
#main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* トップバー */
#topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

#sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

#sidebar-toggle:hover { background: var(--bg); }

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-actions { display: flex; gap: 8px; }

.btn-icon {
  background: none;
  border: none;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition);
}

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

/* =============================================
   コンテンツエリア
   ============================================= */
#content-area {
  flex: 1;
  padding: 28px 32px;
}

.page { display: none; }
.page.active { display: block; }

/* ページヘッダー */
.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h2 i {
  color: var(--primary);
}

.page-header p {
  color: var(--text-muted);
  font-size: .88rem;
  margin-top: 4px;
}

/* ツールバー */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* 検索ボックス */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 220px;
}

.search-box i { color: var(--text-light); }

.search-box input {
  border: none;
  outline: none;
  font-size: .88rem;
  color: var(--text);
  background: transparent;
  width: 100%;
}

/* =============================================
   ボタン
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

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

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

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: .78rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

/* =============================================
   ダッシュボード - 統計カード
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border-left: 4px solid var(--accent);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--accent);
  flex-shrink: 0;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ダッシュボード下段グリッド */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dash-card-header h3 {
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-more {
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.link-more:hover { text-decoration: underline; }

.dash-list { display: flex; flex-direction: column; gap: 8px; }

.dash-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .85rem;
}

.dash-item-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.dash-item-meta {
  font-size: .75rem;
  color: var(--text-muted);
}

/* =============================================
   役割カードグリッド
   ============================================= */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.role-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
  transition: transform var(--transition), box-shadow var(--transition);
}

.role-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.09);
}

.role-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.role-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.role-name { font-size: 1rem; font-weight: 700; }
.role-position { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.role-level {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

.role-scope {
  font-size: .83rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.role-tasks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag {
  font-size: .73rem;
  padding: 2px 9px;
  border-radius: 99px;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* =============================================
   リストコンテナ（マニュアル・判断基準など）
   ============================================= */
.list-container { display: flex; flex-direction: column; gap: 12px; }

.list-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
  border-left: 4px solid var(--primary);
}

.list-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

.list-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.list-item-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.list-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.badge {
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-orange { background: #fff7ed; color: #c2410c; }

.list-item-body {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.list-item-body pre {
  white-space: pre-wrap;
  font-family: inherit;
}

.list-item-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* =============================================
   評価制度
   ============================================= */
.eval-container { display: flex; flex-direction: column; gap: 12px; }

.eval-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 20px;
}

.eval-weight {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
}

.eval-info { flex: 1; }

.eval-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.eval-category-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.eval-desc {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* =============================================
   成長ステップ タイムライン
   ============================================= */
.growth-timeline {
  position: relative;
  padding-left: 32px;
}

.growth-timeline::before {
  content: '';
  position: absolute;
  left: 14px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), #a5b4fc);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: -25px; top: 18px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(79,70,229,.4);
  border: 3px solid #fff;
  z-index: 1;
}

.timeline-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition);
}

.timeline-card:hover { transform: translateX(4px); }

.timeline-stage {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.timeline-period {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.timeline-section {
  margin-top: 10px;
}

.timeline-section-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.timeline-section-content {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.timeline-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* =============================================
   フィルタータブ
   ============================================= */
.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.filter-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.filter-tab.active,
.filter-tab:hover {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* =============================================
   モーダル
   ============================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,15,35,.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal-overlay.open { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  animation: slideUp .2s ease;
}

.modal-wide { max-width: 640px; }
.modal-sm   { max-width: 360px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* フォーム */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}

.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-group textarea { resize: vertical; line-height: 1.6; }

/* =============================================
   トースト
   ============================================= */
.toast {
  position: fixed;
  bottom: 32px; right: 32px;
  background: #1e293b;
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 999;
  max-width: 320px;
  pointer-events: none;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }

/* =============================================
   空メッセージ
   ============================================= */
.empty-msg {
  text-align: center;
  color: var(--text-light);
  font-size: .85rem;
  padding: 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  color: var(--text-light);
  gap: 12px;
}

.empty-state i { font-size: 3rem; opacity: .3; }
.empty-state p { font-size: .9rem; }

/* =============================================
   レスポンシブ
   ============================================= */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
  }

  #main-wrapper {
    margin-left: 0;
  }

  #content-area {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .form-row { flex-direction: column; }

  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: auto; }
}
