/* ============================================================
   CloudTask — Frontend styles
   Author: Mahyar Zeb
   Pure CSS. No frameworks.
   ============================================================ */

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

:root {
  --orange:      #f97316;
  --orange-dark: #ea580c;
  --blue:        #0ea5e9;
  --green:       #10b981;
  --red:         #ef4444;
  --slate-900:   #0f172a;
  --slate-700:   #334155;
  --slate-500:   #64748b;
  --slate-300:   #cbd5e1;
  --slate-100:   #f1f5f9;
  --bg:          #f5f7fb;
  --card:        #ffffff;
  --radius:      14px;
  --shadow-sm:   0 2px 8px rgba(15, 23, 42, .06);
  --shadow-md:   0 10px 30px rgba(15, 23, 42, .08);
}

html, body {
  min-height: 100%;
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--slate-900);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-bottom: 1px solid #fed7aa;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.25rem; }
.brand-icon { font-size: 1.5rem; }
.brand-name { color: var(--orange-dark); letter-spacing: .02em; }
.api-status {
  font-size: .8rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-500);
}
.api-status.ok      { background: #dcfce7; color: #166534; }
.api-status.error   { background: #fee2e2; color: #991b1b; }

/* ---------- Container ---------- */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  gap: 1.5rem;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border-left: 4px solid var(--slate-300);
}
.stat-total     { border-left-color: var(--blue);   }
.stat-pending   { border-left-color: var(--orange); }
.stat-completed { border-left-color: var(--green);  }
.stat-label { font-size: .8rem; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

/* ---------- Section titles ---------- */
.section-title { font-size: 1.05rem; margin-bottom: .75rem; color: var(--slate-700); }

/* ---------- Add task form ---------- */
.add-task {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.add-task-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: .75rem;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .8rem; color: var(--slate-500); }
.field input {
  padding: .6rem .75rem;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px #fed7aa80;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: .65rem 1rem;
  font-weight: 600;
  transition: transform .05s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
}
.search-input {
  flex: 1 1 240px;
  padding: .6rem .9rem;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.search-input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px #fed7aa80;
}
.filters { display: flex; gap: .4rem; }
.filter-btn {
  border: 1px solid var(--slate-300);
  background: #fff;
  border-radius: 999px;
  padding: .4rem .9rem;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  color: var(--slate-700);
}
.filter-btn:hover { border-color: var(--orange); }
.filter-btn.is-active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

/* ---------- Task list ---------- */
.task-list { display: grid; gap: .75rem; }

.task-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem 1rem;
  border-left: 4px solid var(--orange);
}
.task-card.is-completed { border-left-color: var(--green); opacity: .85; }

.task-main { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.task-title {
  font-weight: 600;
  font-size: 1rem;
  word-break: break-word;
}
.task-card.is-completed .task-title { text-decoration: line-through; color: var(--slate-500); }
.task-description { font-size: .9rem; color: var(--slate-700); word-break: break-word; }
.task-meta { font-size: .75rem; color: var(--slate-500); }

.task-actions { display: flex; gap: .5rem; align-items: center; }
.icon-btn {
  background: var(--slate-100);
  border: none;
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: var(--slate-300); }
.icon-btn.danger:hover { background: #fecaca; }

.status-pill {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
}
.status-pill.completed { background: #dcfce7; color: #166534; }

/* ---------- Empty / loading ---------- */
.empty-state,
.loading {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--slate-500);
  box-shadow: var(--shadow-sm);
}
.empty-icon { font-size: 2rem; margin-bottom: .5rem; }
.empty-title { font-weight: 600; color: var(--slate-700); font-size: 1.05rem; }
.empty-sub { font-size: .9rem; }

.loading { display: flex; align-items: center; justify-content: center; gap: .75rem; }
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 3px solid var(--slate-300);
  border-top-color: var(--orange);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  max-width: 320px;
  padding: .8rem 1rem;
  border-radius: 10px;
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 50;
  animation: toast-in .2s ease-out;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--slate-500);
  font-size: .8rem;
  margin-top: auto;
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .add-task-form { grid-template-columns: 1fr; }
  .add-task-form .btn { justify-self: start; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters { justify-content: center; }
  .task-card { grid-template-columns: 1fr; }
  .task-actions { justify-content: flex-end; }
  .toast { left: 1.25rem; right: 1.25rem; max-width: none; }
}