/* ============================================================
   TaskApp – Custom Styles · Mobile First
   ============================================================ */

/* ── Color Tokens ── */
:root {
  --primary:       #4f46e5;
  --primary-dark:  #3730a3;
  --nav-height:    64px;
  --safe-bottom:   env(safe-area-inset-bottom, 0px);

  /* Light mode defaults */
  --bg:            #f3f4f6;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --border:        #e5e7eb;
  --border-input:  #d1d5db;
  --text:          #111827;
  --text-2:        #374151;
  --text-muted:    #6b7280;
  --text-faint:    #9ca3af;
  --bubble-own:    #ede9fe;
  --badge-bg:      #ede9fe;
  --badge-color:   #5b21b6;
  --filter-tab-bg: #f3f4f6;
}

/* Auto dark – only when not manually forced to light */
@media (prefers-color-scheme: dark) {
  html:not([data-bs-theme="light"]) {
    --bg:            #0f172a;
    --surface:       #1e293b;
    --surface-2:     #273447;
    --border:        #334155;
    --border-input:  #475569;
    --text:          #f1f5f9;
    --text-2:        #cbd5e1;
    --text-muted:    #94a3b8;
    --text-faint:    #64748b;
    --bubble-own:    #312e81;
    --badge-bg:      #312e81;
    --badge-color:   #a78bfa;
    --filter-tab-bg: #273447;
  }
}

/* Manual dark mode */
html[data-bs-theme="dark"] {
  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface-2:     #273447;
  --border:        #334155;
  --border-input:  #475569;
  --text:          #f1f5f9;
  --text-2:        #cbd5e1;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;
  --bubble-own:    #312e81;
  --badge-bg:      #312e81;
  --badge-color:   #a78bfa;
  --filter-tab-bg: #273447;
}

/* ── Base ── */
body {
  background: var(--bg);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Bar ── */
.app-topbar {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.app-topbar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.3px;
}

.app-topbar .topbar-action {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 1.2rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}

.app-topbar .topbar-action:hover,
.app-topbar .topbar-action:active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ── Filter Tabs ── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
  position: sticky;
  top: 52px;
  z-index: 90;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-bar .filter-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 8px 12px;
}

.filter-tabs .filter-tab {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--filter-tab-bg);
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}

.filter-tabs .filter-tab:hover {
  background: var(--border);
  color: var(--text-2);
}

.filter-tabs .filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Task Cards ── */
.task-card {
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow .15s, transform .1s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.task-card:hover,
.task-card:active {
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}

.task-card-body {
  display: flex;
  align-items: stretch;
}

.task-status-bar {
  width: 5px;
  flex-shrink: 0;
  border-radius: 0;
}

.task-content {
  flex: 1;
  padding: 12px 14px;
}

.task-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.task-title.erledigt {
  text-decoration: line-through;
  color: var(--text-faint);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 6px;
}

.task-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.task-meta .overdue {
  color: #ef4444;
  font-weight: 600;
}

.task-actions {
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 4px;
}

/* ── Avatars ── */
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--surface);
}

.avatar:nth-child(2) { background: #0891b2; }

.avatar-group {
  display: flex;
}
.avatar-group .avatar:not(:first-child) {
  margin-left: -8px;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 200;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-faint);
  font-size: .65rem;
  font-weight: 500;
  gap: 3px;
  padding: 6px 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav .nav-item i {
  font-size: 1.3rem;
  line-height: 1;
}

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

.bottom-nav .nav-item:hover {
  color: var(--primary);
}

.bottom-nav .nav-new {
  color: var(--primary);
}

.nav-new-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(79,70,229,.4);
  transition: transform .15s, box-shadow .15s;
  margin-top: -10px;
}

.nav-new-btn:hover,
.nav-new-btn:active {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(79,70,229,.5);
}

.bottom-nav .nav-new span {
  color: var(--text-faint);
  margin-top: -4px;
}

/* ── Forms ── */
.form-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

.form-label {
  font-weight: 500;
  font-size: .9rem;
  color: var(--text-2);
  margin-bottom: .25rem;
}

.form-control,
.form-select {
  border-radius: 10px;
  border: 1.5px solid var(--border-input);
  padding: .6rem .85rem;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

textarea.form-control { resize: vertical; min-height: 100px; }

.btn-primary-app {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: .75rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  width: 100%;
  transition: background .15s, transform .1s;
}

.btn-primary-app:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary-app:active {
  transform: translateY(0);
}

/* ── Comments ── */
.comment-bubble {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.comment-bubble.own {
  background: var(--bubble-own);
}

.comment-meta {
  font-size: .72rem;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.comment-text {
  font-size: .9rem;
  color: var(--text-2);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Status Selector ── */
.status-selector {
  display: flex;
  gap: 8px;
}

.status-option input[type="radio"] { display: none; }

.status-option label {
  display: block;
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
}

.status-option input:checked + label {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* ── Assignment Toggle ── */
.assign-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.assign-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all .15s;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-2);
  flex: 1;
  min-width: 130px;
}

.assign-user input { display: none; }

.assign-user.checked {
  border-color: var(--primary);
  background: var(--bubble-own);
  color: var(--primary);
}

/* ── Login ── */
.login-wrapper {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin-bottom: .75rem;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-faint);
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: .5;
}

.empty-state p {
  font-size: .95rem;
  margin: 0;
}

/* ── Section Header ── */
.section-header {
  padding: .75rem 1rem .35rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}

/* ── Detail Page ── */
.task-detail-header {
  background: var(--surface);
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.task-detail-meta {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem;
}

.task-detail-meta .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}

.task-detail-meta .meta-row:last-child { border-bottom: none; }
.task-detail-meta .meta-label { color: var(--text-muted); font-weight: 500; }
.task-detail-meta .meta-value { color: var(--text); font-weight: 500; }

/* ── Quick Status Bar ── */
.quick-status {
  display: flex;
  gap: 6px;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.quick-status .qs-btn {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  transition: all .15s;
  color: var(--text-muted);
}

.quick-status .qs-btn.active-offen           { border-color: #6c757d; background: #6c757d; color: #fff; }
.quick-status .qs-btn.active-in_bearbeitung  { border-color: #ffc107; background: #ffc107; color: #000; }
.quick-status .qs-btn.active-erledigt        { border-color: #198754; background: #198754; color: #fff; }

/* ── Utility ── */
.page-content { padding: .75rem 1rem; }
.card-section  { margin-bottom: 1rem; }

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s;
}

.btn-icon.danger  { background: #fef2f2; color: #ef4444; }
.btn-icon.muted   { background: var(--surface-2); color: var(--text-muted); }
.btn-icon:hover   { filter: brightness(.92); }

.badge-kategorie {
  background: var(--badge-bg);
  color: var(--badge-color);
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.toast-container { z-index: 9999; }

/* ── Offline Bar ── */
#offline-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  z-index: 190;
  background: #b45309;
  color: #fff;
  text-align: center;
  padding: 6px 1rem;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .01em;
}

@media (min-width: 576px) {
  .task-card { border-radius: 14px; }
}
