/**
 * ThinkHub360 — UI inspiriert vom „Celestial“-Admin-Look:
 * dunkle Sidebar, heller Arbeitsbereich, weiße Karten, blaue Akzente.
 */
:root {
  --ce-sidebar-bg: #1e2139;
  --ce-sidebar-bg-deep: #181b30;
  --ce-sidebar-text: #9ca3c7;
  --ce-sidebar-active: #ffffff;
  --ce-primary: #4d6bff;
  --ce-primary-soft: rgba(77, 107, 255, 0.12);
  --ce-primary-hover: #3d5aee;
  --ce-bg: #f0f2f7;
  --ce-surface: #ffffff;
  --ce-text: #1a1d2e;
  --ce-muted: #6b7288;
  --ce-border: #e8ebf3;
  --ce-pink: #ff5c8d;
  --ce-orange: #ff9f43;
  --ce-green: #00c9a7;
  --ce-shadow: 0 4px 24px rgba(31, 34, 53, 0.07);
  --ce-radius: 12px;
  --ce-radius-sm: 8px;
  --ce-sidebar-w: 260px;
  --ce-topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

body.ce-app-body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  font-size: 15px;
  color: var(--ce-text);
  background: var(--ce-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ce-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ——— App shell ——— */
.ce-app {
  display: flex;
  min-height: 100vh;
}

.ce-sidebar {
  width: var(--ce-sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--ce-sidebar-bg) 0%, var(--ce-sidebar-bg-deep) 100%);
  color: var(--ce-sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.ce-sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ce-sidebar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ce-primary), #7b5cff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
}

.ce-sidebar-brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: 0.02em;
}
.ce-sidebar-brand-text small {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ce-sidebar-text);
  margin-top: 0.15rem;
}

.ce-sidebar-user {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ce-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(77, 107, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.ce-sidebar-user-meta {
  min-width: 0;
}
.ce-sidebar-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ce-sidebar-user-role {
  font-size: 0.75rem;
  color: var(--ce-sidebar-text);
  margin-top: 0.15rem;
}

.ce-sidebar-search {
  padding: 0.75rem 1rem;
}
.ce-sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  border-radius: var(--ce-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  color: #e8eaef;
  font-size: 0.82rem;
}
.ce-sidebar-search input::placeholder {
  color: rgba(156, 163, 199, 0.7);
}
.ce-sidebar-search-wrap {
  position: relative;
}
.ce-sidebar-search-wrap::before {
  content: "";
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  opacity: 0.45;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
}

.ce-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
}

.ce-nav-section-label {
  padding: 0.65rem 1.25rem 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(156, 163, 199, 0.55);
  font-weight: 600;
}

.ce-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem 0.55rem 1.25rem;
  margin: 0.1rem 0.5rem;
  border-radius: var(--ce-radius-sm);
  color: var(--ce-sidebar-text);
  font-size: 0.88rem;
  text-decoration: none !important;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.ce-nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.ce-nav-link.active {
  background: var(--ce-primary-soft);
  color: var(--ce-sidebar-active);
  border-left-color: var(--ce-primary);
}

.ce-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ce-nav-dot.blue { background: var(--ce-primary); }
.ce-nav-dot.pink { background: var(--ce-pink); }
.ce-nav-dot.orange { background: var(--ce-orange); }
.ce-nav-dot.green { background: var(--ce-green); }

.ce-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ce-sidebar-footer a {
  color: var(--ce-sidebar-text);
  font-size: 0.88rem;
}
.ce-sidebar-footer a:hover { color: #fff; }

/* ——— Main column ——— */
.ce-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ce-topbar {
  min-height: var(--ce-topbar-h);
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--ce-surface);
  border-bottom: 1px solid var(--ce-border);
  box-shadow: 0 1px 0 rgba(31, 34, 53, 0.03);
}

.ce-topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ce-topbar-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ce-text);
}

.ce-topbar-tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}
.ce-topbar-tab {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  color: var(--ce-muted);
  border-radius: 6px;
  text-decoration: none !important;
}
.ce-topbar-tab:hover { color: var(--ce-text); background: var(--ce-bg); }
.ce-topbar-tab.active {
  color: var(--ce-primary);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--ce-primary);
  border-radius: 0;
}

.ce-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ce-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  /* Legacy template vars (Karten, Tabellen, Formulare) */
  --th-muted: var(--ce-muted);
  --th-border: var(--ce-border);
  --th-accent: var(--ce-primary);
  --th-text: var(--ce-text);
  --th-panel: var(--ce-surface);
  --th-bg: var(--ce-bg);
  --th-danger: #e5484d;
  --th-success: var(--ce-green);
}

.ce-content .card {
  background: var(--ce-surface);
  border: 1px solid var(--ce-border);
  border-radius: var(--ce-radius);
  box-shadow: var(--ce-shadow);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
  color: var(--ce-text);
}

.ce-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.ce-content th,
.ce-content td {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--ce-border);
  text-align: left;
}
.ce-content th {
  color: var(--ce-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ce-content tbody tr:hover {
  background: rgba(77, 107, 255, 0.03);
}

.ce-content input,
.ce-content select,
.ce-content textarea {
  max-width: 520px;
  padding: 0.5rem 0.65rem;
  border-radius: var(--ce-radius-sm);
  border: 1px solid var(--ce-border);
  background: #fafbfe;
  color: var(--ce-text);
}
.ce-content input:focus,
.ce-content select:focus,
.ce-content textarea:focus {
  outline: none;
  border-color: var(--ce-primary);
  box-shadow: 0 0 0 3px var(--ce-primary-soft);
}

.ce-content label {
  color: var(--ce-muted);
}

/* Buttons & Badges (global, hell) */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--ce-radius-sm);
  border: 1px solid var(--ce-border);
  background: var(--ce-surface);
  color: var(--ce-text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none !important;
  box-shadow: 0 1px 2px rgba(31, 34, 53, 0.04);
}
.btn:hover {
  background: var(--ce-bg);
  border-color: #d8dce8;
}

.btn-primary {
  background: var(--ce-primary);
  border-color: transparent;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(77, 107, 255, 0.35);
}
.btn-primary:hover {
  background: var(--ce-primary-hover);
  text-decoration: none !important;
}

.btn-danger {
  border-color: rgba(229, 72, 77, 0.35);
  color: #c62a2f !important;
  background: #fff5f5;
}
.btn-danger:hover {
  background: #ffe8e8;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--ce-primary-soft);
  color: var(--ce-primary);
}

/* Stat-Kacheln Dashboard */
.ce-grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

.ce-metric-card {
  background: var(--ce-surface);
  border-radius: var(--ce-radius);
  box-shadow: var(--ce-shadow);
  border: 1px solid var(--ce-border);
  padding: 1.15rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.ce-metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--ce-radius) var(--ce-radius) 0 0;
}
.ce-metric-card.t-blue::before { background: var(--ce-primary); }
.ce-metric-card.t-pink::before { background: var(--ce-pink); }
.ce-metric-card.t-orange::before { background: var(--ce-orange); }
.ce-metric-card.t-green::before { background: var(--ce-green); }

.ce-metric-label {
  font-size: 0.8rem;
  color: var(--ce-muted);
  margin-bottom: 0.35rem;
}
.ce-metric-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--ce-text);
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ce-primary);
}

/* ——— Auth pages (Login / Registrierung) ——— */
body.ce-auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: linear-gradient(145deg, #e8ecf6 0%, var(--ce-bg) 45%, #e4e8f5 100%);
  color: var(--ce-text);
  -webkit-font-smoothing: antialiased;
}

.ce-auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ce-auth-top {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ce-auth-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: var(--ce-text);
  text-decoration: none !important;
}
.ce-auth-brand:hover { text-decoration: none !important; }

.ce-auth-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--ce-primary), #9b7dff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.ce-auth-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}
.ce-auth-nav a {
  color: var(--ce-muted);
  text-decoration: none !important;
}
.ce-auth-nav a:hover { color: var(--ce-primary); }

.ce-auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

.ce-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--ce-surface);
  border-radius: var(--ce-radius);
  box-shadow: var(--ce-shadow), 0 24px 48px rgba(31, 34, 53, 0.08);
  border: 1px solid var(--ce-border);
  padding: 2rem 2rem 1.75rem;
}

.ce-auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
}
.ce-auth-card .ce-auth-sub {
  margin: 0 0 1.35rem;
  font-size: 0.88rem;
  color: var(--ce-muted);
}

.ce-auth-card label {
  display: block;
  margin: 0.65rem 0 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ce-muted);
}

.ce-auth-card input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--ce-radius-sm);
  border: 1px solid var(--ce-border);
  background: #fafbfe;
  font-size: 0.95rem;
}
.ce-auth-card input:focus {
  outline: none;
  border-color: var(--ce-primary);
  box-shadow: 0 0 0 3px var(--ce-primary-soft);
}

.ce-auth-card button[type="submit"] {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--ce-radius-sm);
  background: var(--ce-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(77, 107, 255, 0.35);
}
.ce-auth-card button[type="submit"]:hover {
  background: var(--ce-primary-hover);
}

.ce-auth-card .err,
.ce-auth-card .msg-err {
  color: #c62a2f;
  font-size: 0.88rem;
  margin-bottom: 0.85rem;
}
.ce-auth-card .msg-ok {
  color: #0a9b7c;
  font-size: 0.88rem;
  margin-bottom: 0.85rem;
}

.ce-auth-foot {
  margin-top: 1.1rem;
  font-size: 0.88rem;
  color: var(--ce-muted);
  text-align: center;
}

/* Portal: eingeloggt = gleiche App-Shell wie Admin */
.ce-portal-body.ce-app-body .ce-sidebar-brand-text small {
  color: var(--ce-sidebar-text);
}

@media (max-width: 960px) {
  .ce-app {
    flex-direction: column;
  }
  .ce-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .ce-nav {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    max-height: none;
  }
  .ce-nav-section-label { width: 100%; }
  .ce-nav-link { margin: 0.15rem; }
}
