/* ============================================
   manuel-gahleitner.at - Styles
   ============================================ */

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

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #1f4dd6;
  --accent-hover: #1a40b8;
  --accent-soft: rgba(31, 77, 214, 0.08);
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
               Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.625rem; font-weight: 600; margin-bottom: 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 0.9375rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--text); }

.muted { color: var(--text-muted); font-size: 0.9rem; }
.muted.small { font-size: 0.8125rem; }
.center { text-align: center; }
.pad { padding: 0.75rem 0; }

/* ====== Auth Pages ====== */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
}
.card h1 { margin-bottom: 1.25rem; }
.brand-line {
  font-size: 0.75rem; color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 0.25rem;
}

/* ====== Forms ====== */
form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}
form label input,
form label select,
input[type=text], input[type=email], input[type=password],
input[type=date], textarea, select {
  display: block;
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.625rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  transition: border-color 0.1s, box-shadow 0.1s;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ====== Buttons ====== */
.btn {
  display: inline-block;
  padding: 0.625rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); background: var(--surface); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-link {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font: inherit; font-size: 0.8125rem;
  text-decoration: underline; padding: 0;
}
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 0.375rem 0.5rem; font-size: 1rem;
  color: var(--text-muted); border-radius: 6px; line-height: 1;
}
.btn-icon:hover { background: var(--danger-bg); color: var(--danger); }

form + p { margin-top: 1rem; }

/* ====== Alerts ====== */
.alert {
  padding: 0.875rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  border: 1px solid transparent;
}
.alert.error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alert.success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert code { background: rgba(0,0,0,0.08); padding: 1px 6px; border-radius: 4px; font-size: 0.875rem; }

/* ====== Top Nav ====== */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
}
.brand {
  font-weight: 600; color: var(--text);
  font-size: 0.9375rem; letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--border-strong);
  padding: 0.375rem 0.625rem; border-radius: 6px;
  cursor: pointer; font-size: 1.125rem; line-height: 1;
}
.nav-links {
  display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap;
}
.nav-links a {
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9375rem;
}
.nav-links a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-links .spacer { flex: 1; }
.nav-links .user {
  font-size: 0.8125rem; color: var(--text-muted);
  padding: 0 0.5rem;
}
.nav-links .logout { color: var(--danger); }

/* ====== Content ====== */
.content { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ====== Dashboard Stats ====== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none; color: var(--text);
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
}
.stat-card:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.stat-card.highlight {
  border-color: #fcd34d; background: var(--warning-bg);
}
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }

/* ====== Todo Layout ====== */
.todo-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.lists-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky; top: 72px;
}
.lists-sidebar h2 { margin-bottom: 0.75rem; }
.list-nav { list-style: none; margin-bottom: 1rem; }
.list-nav li { margin-bottom: 0.125rem; }
.list-nav a {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  color: var(--text); font-size: 0.9375rem;
}
.list-nav a:hover { background: var(--bg); text-decoration: none; }
.list-nav a.active { background: var(--accent-soft); color: var(--accent); }
.list-nav .list-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-nav .badge {
  font-size: 0.6875rem; color: var(--text-muted);
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
  white-space: nowrap;
}
.list-nav .count {
  font-size: 0.6875rem; font-weight: 600;
  background: var(--accent); color: #fff;
  padding: 1px 7px; border-radius: 999px;
  min-width: 20px; text-align: center;
}
.new-list-form {
  display: flex; gap: 0.375rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.new-list-form input {
  flex: 1; margin: 0;
  padding: 0.5rem 0.625rem;
  font-size: 0.875rem;
}

.todo-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.list-header {
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.list-header h2 { font-size: 1.25rem; }
.list-meta {
  font-size: 0.8125rem; color: var(--text-muted);
  margin-top: 0.25rem;
}

.new-todo-form { margin-bottom: 1.5rem; }
.new-todo-form .row {
  display: flex; gap: 0.5rem; margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.new-todo-form input[type=text] { flex: 1 1 200px; margin: 0; }
.new-todo-form input[type=date] { flex: 0 0 auto; margin: 0; width: auto; }
.new-todo-form textarea { margin: 0; font-size: 0.9rem; }

.todo-list { list-style: none; }
.todo-item {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--text-muted); }
.todo-item.done .todo-desc { color: var(--text-muted); }

.check-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: #fff;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; font-weight: bold;
  margin-top: 3px; padding: 0; line-height: 1;
}
.check-btn:hover { border-color: var(--accent); }
.todo-item.done .check-btn {
  background: var(--accent); border-color: var(--accent);
}
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-weight: 500; word-wrap: break-word; font-size: 0.9375rem; }
.todo-desc {
  font-size: 0.8125rem; color: var(--text-muted);
  margin-top: 0.25rem; word-wrap: break-word;
}
.todo-meta {
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 0.375rem;
  display: flex; gap: 0.75rem; flex-wrap: wrap;
}
.todo-meta .due { color: var(--warning); font-weight: 500; }

.inline-form { display: inline-block; margin: 0; }

.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 0.5rem; }

.list-actions {
  margin-top: 2rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.list-actions summary {
  cursor: pointer; color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.25rem 0;
}
.list-actions summary:hover { color: var(--text); }
.settings-body { padding-top: 0.75rem; }
.share-form {
  display: flex; gap: 0.5rem; margin-bottom: 1rem;
}
.share-form input { flex: 1; margin: 0; }

.members-list { list-style: none; margin-bottom: 1rem; }
.members-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.375rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.members-list li:last-child { border-bottom: none; }

/* ====== Admin Tables ====== */
.admin-section { margin-bottom: 2.5rem; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  white-space: nowrap;
}
.data-table td:nth-child(2) { white-space: normal; word-break: break-word; }
.data-table thead { background: var(--surface-2); }
.data-table th {
  font-weight: 600; font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .actions {
  display: flex; gap: 0.375rem; flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 4px;
  background: var(--bg); color: var(--text-muted);
  font-size: 0.7rem; font-weight: 500;
  vertical-align: middle;
}
.badge.warning { background: #fcd34d; color: #78350f; }
.badge.admin   { background: var(--accent); color: #fff; }

/* ====== Responsive ====== */
@media (max-width: 820px) {
  .todo-layout {
    grid-template-columns: 1fr;
  }
  .lists-sidebar { position: static; }
}

@media (max-width: 640px) {
  .content { padding: 1rem 0.75rem 2rem; }
  .card { padding: 1.5rem; }
  .todo-main { padding: 1rem; }
  h1 { font-size: 1.375rem; }
  .stat-value { font-size: 1.75rem; }
  .nav-toggle { display: inline-block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.5rem;
    gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a, .nav-links .user {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    text-align: left;
  }
  .nav-links .spacer { display: none; }
  .data-table th, .data-table td {
    padding: 0.5rem 0.625rem; font-size: 0.8125rem;
  }
}
