/* =========================================================
   styles.css (FULL / cleaned)
   - Desktop: horizontal timeline
   - Mobile: vertical list + tabs (no horizontal scroll)
   - Tooltips: always black
   - Task time text: always white
   - Color filter: dim others (desktop + mobile)
   ========================================================= */

:root{
  --left-col: 190px;
  --header-h1: 44px;  /* 時間行 */
  --header-h2: 28px;  /* 15分行 */
  --lane-h: 56px;

  /* JSで上書き */
  --slot-w: 60px;
  --hour-w: 240px;
  --track-w: 5760px;

  --bg-a: #f7f9ff;
  --bg-b: #ffffff;

  --line-15: rgba(15, 23, 42, 0.07);
  --line-hour: rgba(15, 23, 42, 0.16);

  --head-grad: linear-gradient(90deg, #1d4ed8 0%, #2563eb 60%, #3b82f6 100%);

  /* task theme vars (default / light) */
  --task-bg: rgba(59, 130, 246, 0.16);
  --task-border: rgba(59, 130, 246, 0.38);
  --task-text: #0f172a;
  --task-time-text: rgba(15, 23, 42, 0.70);

  --task-handle-strong: rgba(15, 23, 42, 0.22);
  --task-handle-fade: rgba(15, 23, 42, 0.00);
  --task-handle-border: rgba(15, 23, 42, 0.16);
  --task-handle-grip: rgba(15, 23, 42, 0.35);
}

html[data-bs-theme="dark"]{
  --bg-a: rgba(15, 23, 42, 0.55);
  --bg-b: rgba(2, 6, 23, 0.45);

  --line-15: rgba(226, 232, 240, 0.07);
  --line-hour: rgba(226, 232, 240, 0.14);

  --head-grad: linear-gradient(90deg, #0b1224 0%, #0f172a 60%, #111c33 100%);

  --task-bg: rgba(56, 189, 248, 0.18);
  --task-border: rgba(56, 189, 248, 0.45);
  --task-text: rgba(226, 232, 240, 0.95);
  --task-time-text: rgba(226, 232, 240, 0.78);

  --task-handle-strong: rgba(248, 250, 252, 0.22);
  --task-handle-fade: rgba(248, 250, 252, 0.00);
  --task-handle-border: rgba(248, 250, 252, 0.16);
  --task-handle-grip: rgba(248, 250, 252, 0.40);
}

/* =========================================================
   Desktop scheduler (timeline)
   ========================================================= */

.scheduler-wrap{
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 14px;
  background: var(--bs-body-bg);
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}

/* 中身は横に長くなる */
.scheduler{
  display: grid;
  grid-template-columns: var(--left-col) var(--track-w);
  width: calc(var(--left-col) + var(--track-w));
  min-width: calc(var(--left-col) + var(--track-w));
}

/* --- header left --- */
.sch-header-left{
  position: sticky;
  left: 0;
  z-index: 30;
  background: var(--head-grad);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,0.25);
  height: calc(var(--header-h1) + var(--header-h2));
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

/* --- header right (2 rows) --- */
.sch-header-right{
  background: var(--head-grad);
  color: #fff;
  height: calc(var(--header-h1) + var(--header-h2));
  position: sticky;
  top: 0;
  z-index: 29;
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

/* end-label が被らないように右余白 */
.hours-row{
  height: var(--header-h1);
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--slot-w));
  align-items: center;
  position: relative;
  padding-right: 56px;
  box-sizing: border-box;
}

.hour-cell{
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 12px;
  font-weight: 900;
  font-size: 16px;
  border-left: 2px solid rgba(255,255,255,0.55);
  user-select: none;
  white-space: nowrap;
}

.end-label{
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 900;
  font-size: 14px;
  opacity: 0.98;
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(4px);
}

/* 15分表示行 */
.quarters-row{
  height: var(--header-h2);
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--slot-w));
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.18);
}

.quarter-cell{
  height: 100%;
  border-left: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  opacity: 0.95;
  user-select: none;
  white-space: nowrap;
}

.quarter-cell.hour{
  border-left: 2px solid rgba(255,255,255,0.55);
  font-size: 12px;
  opacity: 1;
}

/* --- rows --- */
.group-cell{
  position: sticky;
  left: 0;
  z-index: 20;
  padding: 14px 14px;
  border-right: 1px solid rgba(15,23,42,0.10);
  border-top: 1px solid rgba(15,23,42,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-clip: padding-box;
}

.group-cell.row-bg-a{ background-color: var(--bg-a); }
.group-cell.row-bg-b{ background-color: var(--bg-b); }

.group-name{
  font-size: 18px;
  font-weight: 900;
  color: var(--bs-body-color);
}

.group-actions{
  display: flex;
  gap: 6px;
  align-items: center;
}

.group-edit-btn, .group-del-btn{
  padding: 0 8px;
  line-height: 1.2;
  border-radius: 10px;
}

/* timeline */
.timeline{
  position: relative;
  border-top: 1px solid rgba(15,23,42,0.08);
  user-select: none;
  overflow: hidden;
  width: var(--track-w);

  background-color: var(--bs-body-bg);
  background-image:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--slot-w) - 1px),
      var(--line-15) calc(var(--slot-w) - 1px),
      var(--line-15) var(--slot-w)
    ),
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--hour-w) - 1px),
      var(--line-hour) calc(var(--hour-w) - 1px),
      var(--line-hour) var(--hour-w)
    );
}

.timeline.row-bg-a{ background-color: var(--bg-a); }
.timeline.row-bg-b{ background-color: var(--bg-b); }

.timeline.drop-target{
  outline: 2px solid rgba(37,99,235,0.35);
  outline-offset: -2px;
}

/* inactive time fade */
.inactive-shade{
  position: absolute;
  top: 0; bottom: 0;
  pointer-events: none;
  z-index: 1;
  background: rgba(15, 23, 42, 0.10);
}
html[data-bs-theme="dark"] .inactive-shade{
  background: rgba(0, 0, 0, 0.35);
}

/* now line */
.now-line{
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: #ef4444;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.20);
}

/* --- tasks --- */
.task{
  --task-accent: #3b82f6;

  position: absolute;
  height: calc(var(--lane-h) - 16px);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: default;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  user-select: none;
  touch-action: none;
  z-index: 5;

  background: color-mix(in srgb, var(--task-accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--task-accent) 55%, rgba(15,23,42,0.15));
  box-shadow: 0 10px 20px rgba(15,23,42,0.08);
  backdrop-filter: blur(4px);
}

.task:hover{
  box-shadow: 0 14px 26px rgba(15,23,42,0.10);
}

.task-title{
  font-size: 13px;
  font-weight: 800;
  color: var(--task-text);
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}

/* ★依頼どおり「時間は白」に固定（light/dark どちらでも見える） */
.task-time{
  font-size: 11px;
  color: #fff !important;
  line-height: 1.0;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

/* Ghost (create) */
.ghost{
  position: absolute;
  border: 2px dashed rgba(37,99,235,0.75);
  background: rgba(37,99,235,0.08);
  pointer-events: none;
  border-radius: 12px;
}

/* Move/resize states */
.task.is-dragging-move{ opacity: 0.25; }
.task.is-resizing{
  outline: 2px solid rgba(37,99,235,0.55);
  outline-offset: -2px;
  box-shadow: 0 14px 26px rgba(37,99,235,0.10);
}

/* Resize handles (narrow) */
.resize-handle{
  position:absolute;
  top:0; bottom:0;
  width: 8px;
  z-index: 6;
  opacity: .95;
  user-select: none;
}

.resize-handle.left{
  left:0;
  background: linear-gradient(90deg, var(--task-handle-strong), var(--task-handle-fade));
  border-right: 1px solid var(--task-handle-border);
  cursor: ew-resize !important;
}

.resize-handle.right{
  right:0;
  background: linear-gradient(270deg, var(--task-handle-strong), var(--task-handle-fade));
  border-left: 1px solid var(--task-handle-border);
  cursor: ew-resize !important;
}

/* つまみ感：1本線 */
.resize-handle::after{
  content:"";
  position:absolute;
  top:50%;
  left:50%;
  width: 2px;
  height: 18px;
  transform: translate(-50%,-50%);
  border-radius: 2px;
  background: var(--task-handle-grip);
  opacity: .75;
}

/* Tooltip during resize */
.resize-tooltip{
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: #000;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.resize-tooltip .sub{
  display: block;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
  margin-top: 2px;
  color: rgba(255,255,255,.8);
}

/* Cursor helpers */
.task.cursor-ew{ cursor: ew-resize; }
.task.cursor-grab{ cursor: grab; }

/* Color palette */
.color-palette{
  display: grid;
  grid-template-columns: repeat(10, 28px);
  gap: 10px;
  align-items: center;
}
.color-swatch{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,0.16);
  box-shadow: 0 6px 14px rgba(15,23,42,0.08);
  background: var(--swatch);
  padding: 0;
  cursor: pointer;
  outline: none;
  caret-color: transparent;
}
.color-swatch:focus{ outline: none; }
.color-swatch.selected{
  outline: 3px solid rgba(37,99,235,0.80);
  outline-offset: 2px;
}
.color-swatch.disabled{
  opacity: 0.55;
  pointer-events: none;
  box-shadow: none;
}

/* Prevent caret in non-input areas (scheduler only) */
.scheduler-wrap, .scheduler, .timeline, .group-cell, .task{
  caret-color: transparent;
}

/* Tooltips (Bootstrap): always black */
.tooltip .tooltip-inner{
  background: #000 !important;
  color: #fff !important;
  opacity: 1 !important;
}
.tooltip.bs-tooltip-top .tooltip-arrow::before{ border-top-color:#000 !important; }
.tooltip.bs-tooltip-bottom .tooltip-arrow::before{ border-bottom-color:#000 !important; }
.tooltip.bs-tooltip-start .tooltip-arrow::before{ border-left-color:#000 !important; }
.tooltip.bs-tooltip-end .tooltip-arrow::before{ border-right-color:#000 !important; }

/* 色フィルターで薄くする（JSがclass付与する場合にも対応） */
.task.task-dim,
.task.is-dimmed{
  filter: grayscale(1);
  opacity: .25;
}

/* =========================================================
   Mobile scheduler (vertical list + tabs)
   ========================================================= */

/* まず、スマホ用のDOMに class が無い場合でも効くように両対応 */
.mobile-scheduler{ display: none; }
#mobileScheduler{ display: none; }

/* タブ */
.mobile-group-tabs{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.mobile-group-tabs::-webkit-scrollbar{ height: 6px; }

.mobile-group-tab{
  flex: 0 0 auto;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}
.mobile-group-tab.active{
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .15);
  font-weight: 700;
}

/* リスト */
.mobile-task-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-task{
  position: relative;
  border: 1px solid var(--bs-border-color);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--bs-body-bg);
}
.mobile-task::before{
  content:"";
  position:absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: 14px 0 0 14px;
  background: var(--task-accent, #3b82f6);
}

.mobile-task .row1{
  display:flex;
  align-items:center;
  gap: 10px;
}
.mobile-task .title{
  font-weight: 700;
  margin-bottom: 2px;
}
.mobile-task .time-pill{
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.mobile-task .meta{
  font-size: 12px;
  opacity: .75;
  margin-top: 2px;
}
.mobile-task .note{
  margin-top: 6px;
  font-size: 12px;
  opacity: .9;
  white-space: pre-wrap;
}
.mobile-task .actions{
  margin-left:auto;
  display:flex;
  gap: 6px;
}

/* 色フィルターのグレー化をスマホリストにも適用 */
.mobile-task.is-dimmed{
  filter: grayscale(1);
  opacity: .22;
}
.mobile-task.is-active{
  filter: none;
  opacity: 1;
}

/* 有効時間外は薄く */
.mobile-task.outside-active{
  opacity: .35;
}

/* =========================================================
   Responsive switch (IMPORTANT: keep at bottom)
   ========================================================= */

.scheduler-wrap-desktop { display: block; }
.mobile-scheduler { display: none; }  /* class */
#mobileScheduler { display: none; }   /* id */

@media (max-width: 768px){

  /* 横スクロール元を確実に消す */
  .scheduler-wrap,
  .scheduler-wrap-desktop{
    display: none !important;
  }

  /* スマホ版を確実に出す */
  .mobile-scheduler,
  #mobileScheduler{
    display: block !important;
  }

  /* 画面から横にはみ出す原因の保険 */
  body { overflow-x: hidden; }
  .card, .card-body { overflow-x: hidden; }

  /* フォームの縦幅を一般的な高さに寄せる */
  .form-control, .form-select{
    min-height: 38px;
  }
}
