/* ===== テーマカラー ===== */
:root {
  --theme:        #8080A0;
  --theme-dark:   #6B6B8C;
  --theme-darker: #565676;
  --theme-light:  #A0A0C0;
  --theme-pale:   #EDEDF3;
  --theme-bg:     #F5F5FA;
  --text-on-theme: #FFFFFF;
}

/* ===== 共通 ===== */
body {
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--theme-bg);
  color: #2c2c3c;
}

/* ===== ナビバー ===== */
.navbar.navbar-themed {
  background: var(--theme) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.navbar.navbar-themed .navbar-brand,
.navbar.navbar-themed .nav-link,
.navbar.navbar-themed .navbar-text {
  color: var(--text-on-theme) !important;
}
.navbar.navbar-themed .nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,.12);
  border-radius: 4px;
}
.navbar.navbar-themed .btn-outline-light:hover {
  background: rgba(255,255,255,.2);
  border-color: #fff;
}

/* ===== ボタン（Bootstrapの primary を上書き） ===== */
.btn-primary {
  background-color: var(--theme) !important;
  border-color: var(--theme) !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--theme-dark) !important;
  border-color: var(--theme-dark) !important;
  box-shadow: 0 0 0 .2rem rgba(128,128,160,.25) !important;
}
.btn-outline-primary {
  color: var(--theme) !important;
  border-color: var(--theme) !important;
}
.btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary.active {
  background-color: var(--theme) !important;
  border-color: var(--theme) !important;
  color: #fff !important;
}
a { color: var(--theme-dark); }
a:hover { color: var(--theme-darker); }

/* ===== カード ===== */
.card { border-color: #e3e3eb; }
.card-header.themed {
  background: var(--theme) !important;
  color: var(--text-on-theme);
  border-bottom: none;
}
.card-header.themed h1,
.card-header.themed h2,
.card-header.themed a { color: var(--text-on-theme) !important; }
.card-header.themed a:hover { color: #f0f0ff !important; }

/* テーブル */
.table-themed > thead { background: var(--theme); color: #fff; }
.table-themed > thead th { background: var(--theme); color: #fff; border-color: var(--theme-dark); }

/* アラート（メッセージ） */
.alert-success { background: #e6f4ea; color: #1e5128; border-color: #cfe5d6; }
.alert-info    { background: var(--theme-pale); color: var(--theme-darker); border-color: #d6d6e3; }

/* ===== Frappe Gantt（プロジェクトビュー） ===== */
.gantt .grid-row:nth-child(even) { fill: #fafafd; }
.gantt .today-highlight { fill: rgba(231, 76, 60, .12); }
/* バー本体のデフォルト色を少し濃いめのグレーに */
.gantt .bar { fill: #8a96a3; }

/* ステータス別カラー（custom_class="status-XXX" 経由） */
/* 未着手：薄オレンジ（未着手の注意喚起） */
.gantt .status-not_started .bar          { fill: #fce4b8; }
.gantt .status-not_started .bar-progress { fill: #e89432; }

/* 進行中：青 */
.gantt .status-in_progress .bar          { fill: #aecbe6; }
.gantt .status-in_progress .bar-progress { fill: #3498db; }

/* 完了：濃いめグレー（完了済 = 落ち着いた色） */
.gantt .status-completed .bar            { fill: #c8cdd2; }
.gantt .status-completed .bar-progress   { fill: #6c757d; }

/* 保留：薄グレー（一時停止 = 控えめ） */
.gantt .status-on_hold .bar              { fill: #e1e3e6; }
.gantt .status-on_hold .bar-progress     { fill: #adb5bd; }

/* 中止：赤・薄め（取り消し線風） */
.gantt .status-cancelled .bar            { fill: #e8b0ad; opacity: 0.7; }
.gantt .status-cancelled .bar-progress   { fill: #e74c3c; opacity: 0.7; }
.gantt .status-cancelled .bar-label      { text-decoration: line-through; }

/* ラベル文字色：グレー系（完了/保留）は白、それ以外は黒 */
.gantt .status-completed   .bar-label:not(.big),
.gantt .status-on_hold     .bar-label:not(.big) { fill: #fff; }
.gantt .status-not_started .bar-label:not(.big),
.gantt .status-in_progress .bar-label:not(.big),
.gantt .status-cancelled   .bar-label:not(.big) { fill: #000; }

/* ===== プロジェクトガント：左端タスク一覧パネル =====
   Frappe Gantt の header_height=50, bar_height=20, padding=18 に合わせて
   ヘッダ60px / 行38px */
.pg-wrap { display: flex; align-items: flex-start; }
.pg-left {
  flex: 0 0 220px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  position: sticky; left: 0; z-index: 4;
}
.pg-left-header {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px; font-weight: 600; color: #555;
}
.pg-left-row {
  height: 38px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  font-size: 12px;
  border-bottom: 1px solid #f5f5f7;
  background: #fff;
  cursor: grab;
  user-select: none;
  transition: background .12s;
}
.pg-left-row:hover { background: #f0f4ff; }
.pg-left-row.alt { background: #fafafd; }
.pg-left-row.alt:hover { background: #e8edff; }
.pg-left-row.dragging { opacity: 0.4; cursor: grabbing; }
.pg-left-row.drag-over-top { box-shadow: inset 0 3px 0 0 var(--theme); }
.pg-left-row.drag-over-bottom { box-shadow: inset 0 -3px 0 0 var(--theme); }
.pg-drag-handle {
  color: #adb5bd;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}
.pg-left-row a {
  display: block;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2c2c3c;
}
.pg-left-row a:hover { color: var(--theme); }
.pg-right { flex: 1 1 auto; overflow-x: auto; min-width: 0; }

/* ===== ビュー2：担当者別ガント（div構造） ===== */
.ug-wrap {
  background: #fff;
  border: 1px solid #d6d6e0;
  border-radius: .35rem;
  overflow-x: auto;
  min-width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.ug-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid #eef0f5;
}
.ug-name {
  flex: 0 0 180px; width: 180px;
  padding: 2px 8px;
  background: #fafafd;
  border-right: 1px solid #e8e8f0;
  font-size: 11.5px;
  line-height: 1.2;
  overflow: hidden;
}
.ug-track {
  flex: 1 1 auto;
  position: relative;
  min-height: 20px;
  background: #fff;
  border-right: 1px solid #e0e0e0;  /* 最終列の右端を閉じる */
}

/* 単位別の最小幅（.ug-user / .ug-user-header もスクロール幅まで伸ばす） */
.ug-wrap.unit-day   .ug-row,
.ug-wrap.unit-day   .ug-user,
.ug-wrap.unit-day   .ug-user-header { min-width: 3000px; }  /* 1日 ≒ 90px */
.ug-wrap.unit-week  .ug-row,
.ug-wrap.unit-week  .ug-user,
.ug-wrap.unit-week  .ug-user-header { min-width: 1100px; }
.ug-wrap.unit-month .ug-row,
.ug-wrap.unit-month .ug-user,
.ug-wrap.unit-month .ug-user-header { min-width: 1300px; }

/* ヘッダー（Frappe Gantt のヘッダーと同じテイスト：白背景・ダーク文字） */
.ug-header {
  background: #FFFFFF !important;
  color: #555;
  font-weight: 500; font-size: 11px;
  position: sticky; top: 0; z-index: 3;
  border-bottom: 1px solid #e0e0e0;
}
.ug-header .ug-name {
  background: #f7f7fb;
  color: #555;
  border-right-color: #e0e0e0;
  font-weight: 600;
}
.ug-header .ug-track { min-height: 28px; background: #FFFFFF; }
.ug-cell {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid #e0e0e0;
  padding: 6px 6px;
  text-align: left;
  white-space: nowrap;
  font-size: 11px;
  color: #555;
  overflow: hidden;
}
.ug-cell.weekend { background: #eef0f5; }
.ug-cell.sat { color: #4a78c8; }
.ug-cell.sun { color: #c84a4a; }
.ug-cell.today-cell {
  background: #fff5e6;
  color: #d35400;
  font-weight: 700;
}
.ug-cell.today-cell.sat { color: #c46a00; }
.ug-cell.today-cell.sun { color: #c46a00; }

/* 担当者セクション */
.ug-user { border-bottom: 2px solid var(--theme-light); }
.ug-user-header {
  background: var(--theme-pale);
  color: var(--theme-darker);
  padding: 3px 10px;
  font-weight: 600; font-size: 12px;
  border-bottom: 1px solid #d6d6e3;
  border-left: 4px solid var(--theme);
}

/* グリッド線・本日線・週末背景 */
.ug-grid-line {
  position: absolute; top: 0; bottom: 0;
  width: 1px; background: #eef0f5;
  pointer-events: none;
}
.ug-weekend-bg {
  position: absolute; top: 0; bottom: 0;
  background: #eef0f5;
  pointer-events: none;
  z-index: 0;
}
.ug-today-bg {
  position: absolute; top: 0; bottom: 0;
  background: #fff5e6;
  pointer-events: none;
  z-index: 0;
}
.ug-today {
  position: absolute; top: 0; bottom: 0;
  width: 2px; background: rgba(231, 76, 60, .65);
  z-index: 5; pointer-events: none;
}

/* タスクバー（2層構造：外枠＝プロジェクト色を薄めた色／進捗＝プロジェクト色そのもの） */
.ug-bar {
  position: absolute; top: 3px; bottom: 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--bar-color, #b8c2cc) 35%, #fff);
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  transition: filter .12s, box-shadow .12s;
}
.ug-bar-progress {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--bar-color, #a3a3ff);
  z-index: 1;
}
.ug-bar-label {
  position: relative;
  z-index: 2;
  width: 100%;
  color: #2c2c3c;
  font-size: 10.5px; line-height: 1;
  padding: 0 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.ug-bar:hover { filter: brightness(1.05); box-shadow: 0 2px 6px rgba(0,0,0,.18); z-index: 4; }

/* 期限超過：強調 */
.ug-bar.ug-bar-overdue {
  outline: 1px solid #c0392b;
  outline-offset: -1px;
}
.ug-bar.ug-bar-overdue .ug-bar-label { color: #fff; font-weight: 600; }

.user-color-chip {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
  border: 1px solid rgba(0,0,0,.1);
}

/* ===== flatpickr（テーマカラー適応） ===== */
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange:focus,
.flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: var(--theme); border-color: var(--theme); color: #fff;
}
.flatpickr-day.inRange {
  background: var(--theme-pale); border-color: var(--theme-pale); color: var(--theme-darker);
  box-shadow: -5px 0 0 var(--theme-pale), 5px 0 0 var(--theme-pale);
}
.flatpickr-day.today { border-color: var(--theme); }
.flatpickr-day.today:hover { background: var(--theme-light); color: #fff; border-color: var(--theme); }
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekdays, span.flatpickr-weekday {
  background: var(--theme); color: #fff;
}
span.flatpickr-weekday { color: rgba(255,255,255,.85); }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { fill: #fff; }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: #f0f0ff; }
.numInputWrapper:hover { background: rgba(255,255,255,.1); }

/* ===== フォームアクションボタン（同一幅） ===== */
.form-action-btn {
  min-width: 110px;
  text-align: center;
}

/* ===== バッジ ===== */
.badge.bg-theme { background: var(--theme) !important; color: #fff; }

/* ===== プログレスバー ===== */
.progress-bar.bg-theme { background-color: var(--theme) !important; }

/* ===== フォーム入力フォーカス ===== */
.form-control:focus, .form-select:focus {
  border-color: var(--theme-light);
  box-shadow: 0 0 0 .2rem rgba(128,128,160,.20);
}

/* ===== ログイン画面 ===== */
.login-wrap {
  background: linear-gradient(135deg, var(--theme) 0%, var(--theme-darker) 100%);
  min-height: 100vh;
}
.login-card { box-shadow: 0 10px 30px rgba(86,86,118,.3); }
.login-brand { color: var(--theme); }
