/* ============================================
   Tasker - Time Tracker PWA Styles
   ============================================ */

/* --- CSS Custom Properties (Theming) --- */
:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #64748b;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-running: #22c55e;
  --color-paused: #eab308;
  --color-idle: #94a3b8;
  --color-border: #e2e8f0;
  --color-danger: #ef4444;
  --color-toast-bg: #1e293b;
  --color-toast-text: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --nav-height: 64px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-border: #334155;
  --color-toast-bg: #f1f5f9;
  --color-toast-text: #0f172a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

.header__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- Main Content --- */
.main {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
  max-width: 600px;
  margin: 0 auto;
}

.view[hidden] {
  display: none;
}

/* --- Buttons --- */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

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

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

.btn--secondary:hover {
  opacity: 0.8;
}

.btn--small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

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

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

/* --- Theme Toggle --- */
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.icon-moon { display: none; }
.icon-sun { display: block; }

/* --- Add Task --- */
.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn-add:hover {
  border-color: var(--color-primary);
}

.btn-add[hidden] {
  display: none;
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.add-form[hidden] {
  display: none;
}

.input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

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

.input {
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--color-text-secondary);
}

.add-form__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- Task List --- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

/* --- Task Row --- */
.task-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  align-items: center;
  padding: 14px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.task-row--running {
  border-color: var(--color-running);
}

.task-row--paused {
  border-color: var(--color-paused);
}

/* Status dot */
.task-row__dot {
  grid-row: 1 / 3;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-idle);
  flex-shrink: 0;
}

.task-row--running .task-row__dot {
  background: var(--color-running);
  animation: pulse 1.5s ease-in-out infinite;
}

.task-row--paused .task-row__dot {
  background: var(--color-paused);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Task info */
.task-row__info {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-row__name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-row__category {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--color-primary);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Stopwatch */
.task-row__time {
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text);
  line-height: 1.2;
}

.task-row--running .task-row__time {
  color: var(--color-running);
}

.task-row--paused .task-row__time {
  color: var(--color-paused);
}

/* Controls */
.task-row__controls {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.btn-control {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  color: #fff;
}

.btn-control:active {
  transform: scale(0.92);
}

.btn-play {
  background: var(--color-running);
}

.btn-play:hover {
  background: #16a34a;
}

.btn-pause {
  background: var(--color-paused);
}

.btn-pause:hover {
  background: #ca8a04;
}

.btn-stop {
  background: var(--color-idle);
}

.btn-stop:hover {
  background: #64748b;
}

.btn-delete {
  background: none;
  color: var(--color-text-secondary);
  width: 32px;
  height: 32px;
}

.btn-delete:hover {
  color: var(--color-danger);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-secondary);
}

.empty-state p {
  font-size: 16px;
  font-weight: 600;
}

.empty-state__sub {
  font-size: 14px !important;
  font-weight: 400 !important;
  margin-top: 4px;
}

/* --- Date Navigation --- */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.date-nav__date {
  font-size: 16px;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.date-nav__shortcuts {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
  margin-bottom: 16px;
}

/* --- Summary Content --- */
.summary-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-total {
  text-align: center;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.summary-total__label {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-total__value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  margin-top: 4px;
}

/* Category group */
.category-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.category-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--color-border);
}

.category-group__time {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--color-primary);
}

/* Session item */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.session-item:last-child {
  border-bottom: none;
}

.session-item__name {
  font-size: 14px;
  font-weight: 500;
}

.session-item__detail {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.session-item__duration {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Weekly bar chart */
.week-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.week-chart__row {
  display: grid;
  grid-template-columns: 36px 1fr 60px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.week-chart__day {
  font-weight: 600;
  color: var(--color-text-secondary);
}

.week-chart__bar-bg {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.week-chart__bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.week-chart__time {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  color: var(--color-text-secondary);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  background: var(--color-toast-bg);
  color: var(--color-toast-text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  pointer-events: none;
}

.toast[hidden] {
  display: block;
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
}

.toast.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}

.bottom-nav__tab--active {
  color: var(--color-primary);
}

/* --- Confirm Dialog Overlay --- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 24px;
}

.confirm-dialog {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-dialog__message {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-dialog__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
