/* ============================================
   DEEPWORK — AVA-IA.fr
   Dark premium theme
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --border: #1e1e1e;
  --border-light: #2a2a2a;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-glow: rgba(0, 212, 170, 0.3);
  --red: #ff4757;
  --orange: #ffa502;
  --text: #ffffff;
  --text-secondary: #888888;
  --text-muted: #555555;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 220px;
  --font-heading: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

/* ============ LAYOUT ============ */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  margin-bottom: 36px;
}

.brand-icon { color: var(--accent); display: flex; }
.brand-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.nav-item:hover { color: var(--text); background: var(--bg-card); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============ MAIN ============ */

#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#main::-webkit-scrollbar { width: 6px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

.view-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--text);
}

/* ============ FOCUS VIEW ============ */

.focus-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  justify-content: center;
  min-height: calc(100vh - 100px);
}

.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  flex-shrink: 0;
}

/* Timer Ring */

.timer-wrapper {
  position: relative;
  width: 340px;
  height: 340px;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ticks line {
  stroke: var(--border-light);
  stroke-width: 2;
}

.ticks line.tick-major {
  stroke: var(--text-muted);
  stroke-width: 2.5;
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.timer-time {
  font-family: var(--font-heading);
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
}

.timer-mode {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--accent);
  margin-top: 8px;
  text-transform: uppercase;
}

.timer-mode.break { color: var(--orange); }

/* Timer Controls */

.timer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.btn-ctrl {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-ctrl:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-ctrl.btn-primary {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.btn-ctrl.btn-primary:hover {
  background: #00e4b8;
  box-shadow: 0 0 24px var(--accent-glow);
}

/* Session tracker */

.session-tracker {
  text-align: center;
}

#session-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.session-dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: center;
}

.session-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.session-dot.completed { background: var(--accent); }
.session-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ============ QUICK STATS ============ */

.quick-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 320px;
  padding-top: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-today {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-ring-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.stat-ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.stat-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.stat-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.stat-ring-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.stat-info { display: flex; flex-direction: column; gap: 2px; }

.stat-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-goal-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-goal-label strong {
  color: var(--accent);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.stat-header .stat-value { font-size: 20px; }
.stat-header .stat-label { font-size: 12px; }

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.8s ease;
  width: 0%;
}

.stat-goal {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-goal strong { color: var(--text-secondary); }

.stat-streak-card { text-align: center; position: relative; overflow: hidden; }
.stat-streak {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 4px;
}

.streak-fire {
  font-size: 28px;
  position: absolute;
  top: 12px;
  right: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.streak-fire.visible { opacity: 1; }

.stat-week, .stat-month-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-streak { font-size: 48px; }
.stat-streak-card .stat-label { font-size: 13px; }

/* ============ DASHBOARD ============ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

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

.dash-card-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.dash-total {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

/* Weekly chart */

.weekly-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding: 0 8px;
}

.weekly-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.weekly-bar {
  width: 100%;
  max-width: 40px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}

.weekly-bar.today { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.weekly-bar:not(.today) { background: var(--border-light); }

.weekly-bar-value {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.weekly-labels {
  display: flex;
  gap: 12px;
  padding: 8px 8px 0;
}

.weekly-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.weekly-label.today { color: var(--accent); font-weight: 700; }

/* Monthly grid */

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.month-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-secondary);
  position: relative;
  cursor: default;
}

.month-day.empty { visibility: hidden; }
.month-day.today { color: var(--accent); font-weight: 700; }

.month-day .day-heat {
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  z-index: -1;
}

.month-day.h0 .day-heat { background: transparent; }
.month-day.h1 .day-heat { background: rgba(0, 212, 170, 0.1); }
.month-day.h2 .day-heat { background: rgba(0, 212, 170, 0.2); }
.month-day.h3 .day-heat { background: rgba(0, 212, 170, 0.35); }
.month-day.h4 .day-heat { background: rgba(0, 212, 170, 0.55); }

.month-day-header {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

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

.month-nav { display: flex; gap: 4px; }

/* Goal ring */

.dash-goal { text-align: center; }

.goal-ring-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}

.goal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.goal-ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.goal-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.goal-ring-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.goal-current {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.goal-target {
  font-size: 14px;
  color: var(--text-muted);
}

.goal-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 8px;
}

.goal-meta-item { text-align: center; }
.goal-meta-value {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.goal-meta-label { font-size: 12px; color: var(--text-secondary); }

/* Top days */

.top-days-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-day {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.top-day-date { font-size: 13px; color: var(--text-secondary); }
.top-day-hours {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent);
}

.top-day-bar {
  flex: 1;
  margin: 0 16px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.top-day-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ============ HISTORY ============ */

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.select-input option { background: var(--bg-card); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: rgba(255, 71, 87, 0.1); }

.history-summary {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.summary-item {
  font-size: 13px;
  color: var(--text-secondary);
}

.summary-item strong {
  color: var(--accent);
  font-weight: 700;
}

.history-table-wrapper { position: relative; }

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.history-table tr:hover td { background: var(--bg-card); color: var(--text); }

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-badge.focus { background: var(--accent-dim); color: var(--accent); }
.type-badge.break { background: rgba(255, 165, 2, 0.15); color: var(--orange); }

.history-empty {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
  display: none;
}

.history-empty.visible { display: block; }

/* ============ SETTINGS ============ */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.settings-section h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

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

.setting-input-group input[type="number"] {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  text-align: center;
}

.setting-input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-suffix {
  font-size: 12px;
  color: var(--text-muted);
}

/* Toggle switch */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 12px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.file-input {
  font-size: 13px;
  color: var(--text-secondary);
  width: 180px;
}

.file-input::file-selector-button {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  margin-right: 8px;
}

/* ============ TOAST ============ */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

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

/* ============ RESPONSIVE ============ */

@media (max-width: 1100px) {
  .focus-layout { flex-direction: column; align-items: center; }
  .quick-stats { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: center; }
  .quick-stats .stat-card { flex: 1; min-width: 200px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  #sidebar {
    width: 64px;
    min-width: 64px;
  }
  .brand-text, .nav-item span, .footer-label { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-brand { justify-content: center; padding: 0; }
  #main { padding: 20px; }
  .timer-wrapper { width: 280px; height: 280px; }
  .timer-time { font-size: 56px; }
}
