/* ═══════════════════════════════════════
   CalmFlow - style.css
   Study Dashboard Stylesheet
   ═══════════════════════════════════════ */

/* ── Theme Colors ── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-alt: #232733;
  --border: #2e3346;
  --text: #e4e7f1;
  --text-dim: #8b90a5;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --green: #00b894;
  --orange: #fdcb6e;
  --red: #e17055;
  --blue: #74b9ff;
  --pink: #fd79a8;
  --radius: 12px;
}

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

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

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Header ── */
.header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { font-size: 1.15rem; font-weight: 700; }
.logo-calm { color: var(--blue); }
.logo-flow { color: var(--accent); }

.clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Navigation ── */
.nav {
  display: flex;
  gap: 4px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav-btn {
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--surface-alt); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 10px var(--accent-glow); }

/* ── Layout ── */
.container { padding: 14px 20px; max-width: 1100px; margin: 0 auto; }

.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }

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

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* ── Buttons ── */
.btn {
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px var(--accent-glow); }
.btn-small { padding: 4px 8px; font-size: 0.64rem; }
.btn-tiny { padding: 2px 6px; font-size: 0.56rem; border-radius: 4px; }
.btn-danger { background: var(--red); }
.btn-success { background: var(--green); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); box-shadow: none; }

/* ── Form Inputs ── */
.input {
  padding: 7px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78rem;
  outline: none;
}

.input:focus { border-color: var(--accent); }

.form-label {
  display: block;
  font-size: 0.64rem;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.input-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.input-row input,
.input-row select {
  padding: 5px 7px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.72rem;
  outline: none;
}

.input-row input:focus { border-color: var(--accent); }

/* Color swatch button */
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

/* ── Calendar ── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.calendar-header h3 { font-size: 0.95rem; font-weight: 600; }

.calendar-nav {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s;
}

.calendar-nav:hover { background: var(--accent); color: #fff; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.day-name {
  font-size: 0.58rem;
  padding: 6px;
  text-align: center;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-dim);
}

.day-cell {
  background: var(--surface);
  min-height: 74px;
  padding: 4px 5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.1s;
}

.day-cell:hover { filter: brightness(1.1); }
.day-cell.other-month { background: var(--bg); }
.day-cell.other-month .day-number { color: var(--border); }
.day-cell.today { background: rgba(108, 92, 231, 0.08); }

.day-number {
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  z-index: 3;
  transition: all 0.12s;
}

.day-number:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
.day-cell.today .day-number { background: var(--accent); color: #fff; }

/* Event chips in calendar cells */
.event-chip {
  font-size: 0.5rem;
  padding: 2px 4px;
  border-radius: 3px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  line-height: 1.3;
  cursor: pointer;
  position: relative;
  z-index: 2;
  height: 16px;
}

/* Multi-day event spanning */
.event-chip-start { border-radius: 3px 0 0 3px; margin-right: -5px; padding-right: 8px; }
.event-chip-mid   { border-radius: 0; margin-left: -5px; margin-right: -5px; padding: 2px 8px; }
.event-chip-end   { border-radius: 0 3px 3px 0; margin-left: -5px; padding-left: 8px; }

/* ── Day View ── */
.day-grid { display: grid; grid-template-columns: 1fr 320px; gap: 12px; }

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  margin-bottom: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.back-button:hover { border-color: var(--accent); color: var(--text); }

.day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.day-header h3 { font-size: 0.92rem; font-weight: 600; }

/* Schedule timeline */
.schedule-row {
  display: flex;
  min-height: 34px;
  border-bottom: 1px solid rgba(46, 51, 70, 0.4);
}

.schedule-hour {
  width: 36px;
  font-size: 0.58rem;
  color: var(--text-dim);
  padding: 3px 0;
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  padding-right: 6px;
  flex-shrink: 0;
}

.schedule-content {
  flex: 1;
  border-left: 1px solid rgba(46, 51, 70, 0.4);
  position: relative;
  min-height: 32px;
}

.schedule-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.58rem;
  color: #fff;
  overflow: hidden;
  z-index: 2;
  cursor: pointer;
}

.schedule-arrow {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.58rem;
  color: #fff;
  overflow: hidden;
  z-index: 1;
  opacity: 0.45;
  border: 1px dashed rgba(255, 255, 255, 0.3);
}

.allday-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.allday-item { font-size: 0.58rem; padding: 2px 8px; border-radius: 4px; color: #fff; cursor: pointer; }

/* Event row in day view */
.event-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 6px;
  margin-bottom: 4px;
  background: var(--surface-alt);
  cursor: pointer;
}

.event-row:hover { filter: brightness(1.1); }
.event-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.event-info { flex: 1; font-size: 0.74rem; }
.event-time { font-size: 0.58rem; color: var(--text-dim); }

/* Memo textarea */
.memo-box {
  width: 100%;
  min-height: 80px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78rem;
  padding: 8px;
  outline: none;
  resize: vertical;
}

.memo-box:focus { border-color: var(--accent); }

/* ── Todo List ── */
.todo-list { list-style: none; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.todo-item:hover { background: var(--surface-alt); }

.todo-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.55rem;
  color: transparent;
  transition: all 0.15s;
}

.todo-item.done .todo-checkbox { background: var(--green); border-color: var(--green); color: #fff; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text-dim); }

.todo-text { flex: 1; font-size: 0.8rem; }
.todo-meta { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

.todo-deadline {
  font-size: 0.58rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.deadline-ok { background: rgba(0, 184, 148, 0.12); color: var(--green); }
.deadline-soon { background: rgba(253, 203, 110, 0.15); color: var(--orange); }
.deadline-overdue { background: rgba(225, 112, 85, 0.15); color: var(--red); }

.priority-badge {
  font-size: 0.54rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 24px;
  text-align: center;
}

.priority-high { background: rgba(225, 112, 85, 0.15); color: var(--red); }
.priority-mid { background: rgba(253, 203, 110, 0.15); color: var(--orange); }
.priority-low { background: rgba(0, 184, 148, 0.15); color: var(--green); }

.todo-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.todo-item:hover .todo-delete { opacity: 1; }

.section-divider {
  font-size: 0.62rem;
  padding: 10px 0 5px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  font-weight: 600;
  color: var(--text-dim);
}

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 0.72rem;
  padding: 0 4px;
  flex-shrink: 0;
}

.drag-handle:hover { color: var(--accent); }
.todo-item[draggable=true] { transition: opacity 0.2s; }

/* Day view todo */
.day-todo-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.78rem;
}

.day-todo-item:hover { background: var(--surface-alt); }

.day-todo-check {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.5rem;
  color: transparent;
}

.day-todo-item.done .day-todo-check { background: var(--green); border-color: var(--green); color: #fff; }
.day-todo-item.done > span { text-decoration: line-through; color: var(--text-dim); }

/* ── Timer ── */
.timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 4rem;
  font-weight: 600;
  text-align: center;
  padding: 20px 0 10px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.timer-subject { font-size: 0.85rem; text-align: center; margin-top: 3px; }
.timer-label { font-size: 0.7rem; color: var(--text-dim); text-align: center; margin-top: 2px; }
.timer-controls { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

.timer-presets {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all 0.12s;
}

.preset-btn:hover { border-color: var(--accent); color: var(--text); }
.preset-btn.active { border-color: var(--accent); color: var(--accent); }

.stopwatch-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 3rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
  padding: 16px 0 8px;
}

/* Timer tabs */
.timer-tabs { display: flex; gap: 4px; margin-bottom: 12px; }

.timer-tab {
  padding: 6px 14px;
  border: none;
  background: var(--surface-alt);
  color: var(--text-dim);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.74rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}

.timer-tab.active { background: var(--accent); color: #fff; }

/* Subject picker */
.subject-picker { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }

.subject-btn {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.72rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-dim);
  font-family: 'Noto Sans JP', sans-serif;
  transition: all 0.12s;
}

.subject-btn.active { color: #fff; border-color: transparent; }

.subject-add-btn {
  padding: 5px 8px;
  border-radius: 14px;
  font-size: 0.72rem;
  cursor: pointer;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: 'Noto Sans JP', sans-serif;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-card {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 0.52rem;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Goal progress */
.goal-bar-container {
  background: var(--surface-alt);
  border-radius: 6px;
  height: 18px;
  overflow: hidden;
  position: relative;
  margin-top: 5px;
}

.goal-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.4s;
}

.goal-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.goal-row {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 5px;
}

.goal-row input {
  width: 55px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  outline: none;
  text-align: center;
}

.goal-row span { font-size: 0.7rem; color: var(--text-dim); }

/* Subject stats */
.subject-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  margin-bottom: 3px;
}

.subject-row:hover { background: var(--surface-alt); }
.subject-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.subject-name { flex: 1; font-size: 0.75rem; }
.subject-bar-track { width: 50px; height: 5px; background: var(--surface-alt); border-radius: 3px; overflow: hidden; }
.subject-bar-fill { height: 100%; border-radius: 3px; }
.subject-time { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--accent); }

/* Log items */
.log-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
  font-size: 0.72rem;
  background: var(--surface-alt);
}

.log-item:hover { filter: brightness(1.1); }

/* ── Blocker ── */
.block-list { list-style: none; }

.block-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--surface-alt);
}

.block-status {
  font-size: 0.58rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.status-blocked { background: rgba(225, 112, 85, 0.15); color: var(--red); }
.status-allowed { background: rgba(0, 184, 148, 0.15); color: var(--green); }

.focus-banner {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(108, 92, 231, 0.06);
}

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.show { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-box h3 { font-size: 0.9rem; margin-bottom: 12px; }

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .day-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .timer-display { font-size: 3rem; }
}

@media (max-width: 480px) {
  .header, .nav, .container { padding-left: 10px; padding-right: 10px; }
  .day-cell { min-height: 50px; }
}
