/*
   Mobile-first, fast, clean UI.
   No external frameworks. */

/* ===== Reset-ish ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0f14;
  color: #e8eef6;
  line-height: 1.35;
}

/* ===== Layout ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #0f1620;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-title { font-weight: 750; letter-spacing: 0.2px; }
.brand-subtitle { font-size: 12px; opacity: 0.8; }

.app-root {
  padding: 14px;
  max-width: 980px;
  margin: 0 auto;
}

/* ===== Nav Panel ===== */
.nav-panel {
  position: sticky;
  top: 56px; /* below topbar */
  z-index: 9;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #0b0f14;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nav-left, .nav-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
button {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 12px;
  transition: transform 0.06s ease, opacity 0.18s ease;
}
button:active { transform: translateY(1px); }

.btn-primary {
  background: #2f7cf6;
  color: #08101a;
  font-weight: 700;
}
.btn-secondary {
  background: rgba(255,255,255,0.10);
  color: #e8eef6;
}
.btn-danger {
  background: #ff4a4a;
  color: #120708;
  font-weight: 700;
}

.nav-btn {
  background: rgba(255,255,255,0.08);
  color: #e8eef6;
  padding: 9px 10px;
  border-radius: 12px;
  font-weight: 650;
}
.nav-btn-store {
  background: rgba(47,124,246,0.16);
}

/* ===== Views ===== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 10px 0;
}
.view-title {
  font-size: 18px;
  font-weight: 800;
}
.view-content { margin-top: 10px; }

/* ===== Cards / groups ===== */
.task-group {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  overflow: hidden;
  margin: 12px 0;
}

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.group-title { font-weight: 800; }
.group-meta { font-size: 12px; opacity: 0.85; }

.task-list { display: flex; flex-direction: column; }

.task-row {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
}
.task-row:last-child { border-bottom: none; }

.task-row:hover { background: rgba(255,255,255,0.04); }
.task-row-progress { 
  background: rgba(255,193,7,0.15); 
  border-left: 4px solid rgba(255,193,7,0.6);
}

.task-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-title {
  flex: 1;
  font-weight: 750;
  word-break: break-word;
}
.task-meta {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.85;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.1px;
  background: rgba(255,255,255,0.10);
  color: #e8eef6;
}
.badge-danger { background: rgba(255,74,74,0.22); }
.badge-info { background: rgba(47,124,246,0.22); }
.badge-muted { background: rgba(255,255,255,0.08); }
.badge-warning { background: rgba(255,193,7,0.22); }
.badge-success { background: rgba(46,204,113,0.22); }

/* ===== Forms ===== */
.form-group { margin: 10px 0; }
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.form-group label {
  display: block;
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 6px;
  font-weight: 650;
}
.grow { flex: 1; min-width: 140px; }

.input, .select, input[type="text"], input[type="password"], input[type="datetime-local"], input[type="number"], select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: #e8eef6;
  padding: 10px 12px;
  outline: none;
}
.input, .select, input[type="text"], input[type="password"], input[type="datetime-local"], input[type="number"], select option {
  color: #08101a;
  background: #ffffff;
}
input:focus, select:focus, .input:focus, .select:focus {
  border-color: rgba(47,124,246,0.55);
}

.form-actions { margin-top: 12px; display: flex; gap: 10px; }
.form-error { margin-top: 10px; color: #ff9a9a; font-size: 13px; }

/* ===== Deadline Presets ===== */
.deadline-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.preset-btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #e8eef6;
  border: 1px solid rgba(255,255,255,0.10);
}
.preset-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* ===== User Actions ===== */
.no-permission {
  color: #ff9a9a;
  font-size: 12px;
  font-style: italic;
  opacity: 0.8;
}

.checkbox-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.checkbox-row input[type="checkbox"] { transform: scale(1.2); }

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 12px 0;
}

/* ===== Editor ===== */
.editor-root {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 16px;
  overflow: hidden;
}
.editor-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}
.btn-editor {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #e8eef6;
  font-weight: 750;
}
.editor-area {
  min-height: 130px;
  padding: 10px 12px;
  outline: none;
}
.editor-area p { margin: 0 0 8px 0; }
.editor-area ul, .editor-area ol { margin: 0 0 8px 18px; }

/* ===== Weekday pills ===== */
.weekday-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.weekday-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
.weekday-pill input[type="checkbox"] { transform: scale(1.1); }

/* ===== Modal ===== */
.modal-root {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
}
.modal-root.modal-open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  max-height: 82%;
  overflow: auto;
  background: #0f1620;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-title { font-weight: 850; }
.modal-body { padding: 12px; }

/* ===== Task detail ===== */
.task-detail-title {
  font-size: 18px;
  font-weight: 850;
  margin-bottom: 10px;
}
.task-detail-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.task-detail-assigned, .task-detail-recur {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.task-detail-desc {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.task-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ===== Tables ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
}
.table th, .table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: top;
}
.table th {
  text-align: left;
  font-size: 12px;
  opacity: 0.9;
  background: rgba(255,255,255,0.04);
}
.table tr:last-child td { border-bottom: none; }
.select-compact { padding: 8px 10px; border-radius: 12px; }

/* ===== Toasts ===== */
.toast-root {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15,22,32,0.95);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  max-width: min(420px, calc(100vw - 28px));
}
.toast-info { border-color: rgba(47,124,246,0.45); }
.toast-error { border-color: rgba(255,74,74,0.45); }
.toast-hide { opacity: 0; transform: translateY(4px); transition: opacity 0.2s ease, transform 0.2s ease; }

/* ===== Login page ===== */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-container {
  width: min(420px, 100%);
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}
.login-title { margin: 0; font-size: 24px; font-weight: 900; }
.login-subtitle { margin: 4px 0 14px 0; opacity: 0.85; }

/* ===== Small helpers ===== */
.loading { opacity: 0.85; }
.empty { opacity: 0.85; padding: 12px; }
.error { color: #ff9a9a; }

/* ===== Desktop tweaks ===== */
@media (min-width: 900px) {
  .nav-panel { top: 58px; }
  .task-row { padding: 12px 14px; }
}

/* ===== Task Actions ===== */
.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
}

/* ===== Completion History ===== */
.completion-history {
  max-height: 400px;
  overflow-y: auto;
}

.history-summary {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.summary-text {
  font-weight: 600;
  color: #2f7cf6;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border-left: 3px solid #2f7cf6;
}

.history-date {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.history-user {
  font-weight: 500;
  color: #e8eef6;
}

.history-details {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}
