/* Planmate – Layout & Design-System (lädt nach style.css/theme.css/social.css und überschreibt gezielt).
   Aufbau: Tokens · Grundlagen · App-Rahmen (Seitenleiste, Kopfzeile, Inhalt) · Komponenten · Mobil · Anmeldung */

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --accent: #7C3AED;
  --accent-600: #6D28D9;
  --accent-50: #F5F3FF;
  --accent-100: #EDE9FE;
  --accent-ring: rgba(124, 58, 237, .18);

  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --line: #E7E8EE;
  --line-strong: #D9DBE3;
  --text: #0F172A;
  --text-2: #475569;
  --muted: #64748B;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-pop: 0 12px 32px -8px rgba(16, 24, 40, .22), 0 4px 10px -4px rgba(16, 24, 40, .08);

  --sidebar-width: 252px;
  --topbar-height: 60px;
  --tabbar-height: 64px;

  /* bestehende Variablen auf das neue Farbschema umlenken */
  --primary: var(--accent);
  --primary-hover: var(--accent-600);
  --primary-light: var(--accent-50);
  --page-accent: var(--accent);
  --border-radius: var(--radius);
  --border-radius-lg: var(--radius-lg);
  --gray-100: #F1F2F6;
}

/* ─── Grundlagen ─────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -.015em; }
.card h3 { font-size: 1.05rem; font-weight: 700; }
.text-muted { color: var(--muted) !important; }
::selection { background: var(--accent-100); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { flex-shrink: 0; display: block; }

/* ─── App-Rahmen: Seitenleiste ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px 18px; }
.sb-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); min-width: 0; }
.sb-brand > span { display: flex; flex-direction: column; min-width: 0; }
.sb-name { font-size: 1.12rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.sb-tagline { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.sb-close { display: none; background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.sb-close:hover { background: var(--bg); }

.sb-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; }
.sb-group + .sb-group { margin-top: 14px; }
.sb-label { font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #94A3B8; padding: 0 10px 6px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 1px; border-radius: var(--radius);
  color: var(--text-2); text-decoration: none; font-size: .9rem; font-weight: 500;
  position: relative; transition: background .12s, color .12s;
}
.sb-item .ic { color: #94A3B8; transition: color .12s; }
.sb-item:hover { background: #F4F5F8; color: var(--text); }
.sb-item:hover .ic { color: var(--text-2); }
.sb-item.active { background: var(--accent-50); color: var(--accent-600); font-weight: 600; }
.sb-item.active .ic { color: var(--accent); }
.sb-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }

.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-100); color: var(--accent-600); font-weight: 700; font-size: .8rem; text-transform: uppercase;
}
.sb-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sb-user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-mail { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout { background: none; border: 0; padding: 7px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.sb-logout:hover { background: #FEF2F2; color: #B91C1C; }

/* ─── Kopfzeile + Inhalt ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: rgba(245, 246, 250, .82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  box-shadow: none;
  padding: 0 32px;
}
.topbar-title { font-size: 1.3rem; font-weight: 750; letter-spacing: -.025em; }
.topbar-user { display: none; } /* Nutzer + Abmelden sitzen jetzt unten in der Seitenleiste */
.nav-toggle { display: none; background: none; border: 0; padding: 8px; margin-left: -8px; border-radius: 10px; color: var(--text); cursor: pointer; }
.nav-toggle:hover { background: rgba(15, 23, 42, .06); }

.main-content { max-width: 1180px; margin: 0 auto; padding: 8px 32px 40px; }
.grid { gap: 18px; }

/* ─── Komponenten ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 18px;
}
.grid > .card { margin-bottom: 0; }

/* Buttons */
.btn {
  border-radius: var(--radius);
  font-weight: 600;
  gap: 6px;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary, .btn-primary:hover { color: #fff; }
.btn-primary { background: var(--accent); box-shadow: 0 1px 2px rgba(76, 29, 149, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-600); }
.btn-secondary { background: var(--surface); color: var(--text-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: #F8F9FB; color: var(--text); border-color: #C9CCD6; }
.btn-outline { background: var(--surface); color: var(--accent-600); border: 1px solid #D8CCFB; }
.btn-outline:hover:not(:disabled) { background: var(--accent-50); color: var(--accent-600); border-color: #C4B5FD; }
/* Löschen-Knöpfe in Listen dezent, damit sie nicht jede Zeile dominieren */
.btn-danger { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; box-shadow: none; }
.btn-danger:hover:not(:disabled) { background: #DC2626; color: #fff; border-color: #DC2626; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* Formulare */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
input[type="tel"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"],
select, textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 9px 12px;
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
}
input[type="time"], input[type="datetime-local"] { width: 100%; min-width: 0; }
/* Platz für den Pfeil (Hintergrundbild aus style.css) */
select { padding-right: 34px; background-position: right 12px center; }
input:hover, select:hover, textarea:hover { border-color: #C9CCD6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); outline: none; }
input::placeholder, textarea::placeholder { color: #9AA3B2; }
label { font-size: .8rem; font-weight: 600; color: var(--text-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
/* Abstand zwischen Formulargruppen (Raster mit eigenem gap ausgenommen; Inline-margin gewinnt ohnehin) */
.form-group { margin-bottom: 14px; }
.form-grid > .form-group, .task-filters .form-group, .tr-options .form-group { margin-bottom: 0; }

/* Badges, Hinweise, Toasts */
.badge { font-weight: 600; letter-spacing: .01em; }
.alert { border-radius: var(--radius); }
.toast-container { top: auto; bottom: 24px; right: 24px; }
.toast { border-radius: 12px; border: 1px solid var(--line); border-left-width: 4px; box-shadow: var(--shadow-pop); font-size: .875rem; color: var(--text); }
.toast-success { border-left-color: #10B981; }
.toast-error { border-left-color: #EF4444; }
.toast-info { border-left-color: var(--accent); }

/* Dialoge */
.modal-backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); z-index: 900; }
.modal-box { border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-pop); padding: 22px; }

/* Listenzeilen etwas luftiger */
.saved-row, .task-item, .tp-row, .post-row { border-bottom-color: #F0F1F5; }

/* Kacheln (Übersicht) */
.tiles { gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }

/* ─── Übersicht ──────────────────────────────────────────────────────────── */
.dash-hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 6px 0 2px; }
.dash-hello h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; margin: 0; }
.dash-hello p { margin: 2px 0 0; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.quick {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.quick:hover { border-color: #D8CCFB; box-shadow: 0 6px 18px -8px rgba(124, 58, 237, .35); transform: translateY(-1px); }
.quick-ic { width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--c-bg, var(--accent-50)); color: var(--c, var(--accent)); }
.quick-title { font-weight: 700; font-size: .92rem; }
.quick-desc { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card-head a { font-size: .82rem; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.capture { background: linear-gradient(135deg, #FAF8FF 0%, #FFFFFF 60%); border-color: #E9E2FD; }
.capture h3 { display: flex; align-items: center; gap: 8px; }
.capture h3 .ic { color: var(--accent); }

.dash-cols > .card, .grid > .capture { margin-bottom: 0; }
.fab { display: none; }

/* ─── Tablet / Mobil ─────────────────────────────────────────────────────── */
.nav-backdrop, .tab-bar { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-pop); width: min(84vw, 300px); }
  body.nav-open .sidebar { transform: translateX(0); }
  .sb-close { display: inline-flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 150; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .main-wrapper { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 20px; gap: 6px; }
  .main-content { padding: 6px 20px 32px; }

  /* Tab-Leiste unten */
  .tab-bar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 140;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; font: inherit; font-size: .68rem; font-weight: 600;
    color: #8A93A5; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .tab-item.active { color: var(--accent); }
  body.has-tab-bar .main-content { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 24px); }
  .toast-container { left: 16px; right: 16px; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 12px); }
  .toast { min-width: 0; max-width: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; height: 56px; }
  .topbar-title { font-size: 1.1rem; }
  .main-content { padding: 4px 12px 24px; }
  .card { padding: 16px; border-radius: 14px; }
  .grid { gap: 12px; }
  /* 16px verhindert das automatische Hineinzoomen von iOS in Eingabefelder */
  input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="tel"],
  input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea { font-size: 16px; }
  /* Formularfelder mit festen Inline-Breiten auf dem Handy volle Breite */
  .main-content .form-group[style], .modal-box .form-group[style] { flex: 1 1 100% !important; max-width: 100% !important; min-width: 0 !important; }
  .task-filters .form-group { flex: 1 1 calc(50% - 6px); max-width: none; }
  /* Dialoge als Bottom-Sheet */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-box { max-width: 100% !important; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .dash-hello h1 { font-size: 1.4rem; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .quick { padding: 13px; }
  .quick-desc { display: none; }
  /* Kalender: KW-Spalte ausblenden, Zellen kompakter */
  .cal-grid.month { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-kw, .cal-kw-head { display: none !important; }
  .cal-cell { min-height: 66px; padding: 3px; }
  /* Schmale Spalten: Einträge einzeilig mit Auslassungspunkten, Projekt-Etikett nur auf größeren Bildschirmen (Tooltip bleibt) */
  .cal-ev { font-size: .62rem; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal-ev .cal-proj { display: none; }
  .cal-dow { padding: 6px 2px; font-size: .65rem; }
  .cal-head { gap: 8px; }
  .sc-day { min-height: 64px; }
  /* Aufgabenzeilen: Text volle Breite, Knöpfe darunter */
  .task-item { flex-wrap: wrap; row-gap: 8px; }
  .task-item > div { flex: 1 1 calc(100% - 40px) !important; }
  .task-item > select { margin-left: 30px; width: auto; }
  /* Aufgaben: Formular auf dem Handy über den „+“-Knopf (Bottom-Sheet) statt oben auf der Seite */
  .new-task-card { display: none; }
  .fab {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; right: 18px; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 16px); z-index: 130;
    width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
    background: var(--accent); color: #fff; box-shadow: 0 10px 24px -6px rgba(124, 58, 237, .55);
  }
  .fab:active { transform: scale(.96); }
  .sb-item.active::before { display: none; }
}

/* ─── Anmeldung / Registrierung ──────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -10%, #A78BFA 0%, transparent 55%), radial-gradient(900px 500px at 110% 110%, #6366F1 0%, transparent 55%), linear-gradient(135deg, #6D28D9 0%, #4338CA 100%);
}
.auth-brand .sb-brand { color: #fff; }
.auth-brand .sb-name { font-size: 1.3rem; }
.auth-brand .app-mark { border-radius: 11px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 8px 20px -6px rgba(0, 0, 0, .35); }
.auth-brand .sb-tagline { color: rgba(255, 255, 255, .75); }
.auth-claim { font-size: 2.1rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; margin: 0 0 18px; color: #fff; max-width: 460px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 440px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; font-size: .95rem; color: rgba(255, 255, 255, .92); }
.auth-points .ic { margin-top: 1px; padding: 6px; box-sizing: content-box; border-radius: 9px; background: rgba(255, 255, 255, .16); }
.auth-foot { font-size: .78rem; color: rgba(255, 255, 255, .6); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px; }
.auth-card .form-group { margin-bottom: 14px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 11px 16px; font-size: .95rem; }
.auth-switch { text-align: center; margin-top: 18px; font-size: .88rem; color: var(--muted); }
.auth-mobile-brand { display: none; margin-bottom: 28px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-main { align-items: flex-start; padding-top: 56px; }
}
