/* =========================
   main.css – Basis-Styles
   ========================= */

/* ----------- Design-Token ----------- */
:root {
  --primary: #6549d5;
  --primary-dark: #4a33aa;
  --primary-deep: #301e6f;
  --primary-soft: #ece7fa;
  --accent: #bb9cf7;
  --bg: #f4f2fc;
  --card: #ffffff;
  --text: #2d2a3e;
  --text-muted: #8b86a8;
  --danger: #e3342f;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(83, 51, 181, 0.10);
  --shadow-soft: 0 4px 14px rgba(83, 51, 181, 0.08);
}

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

/* hidden-Attribut muss IMMER gewinnen — sonst hebeln eigene
   display-Regeln (z.B. button { display: inline-block }) es aus */
[hidden] {
  display: none !important;
}

/* --------- Grundlayout --------- */
body {
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background:
    radial-gradient(1200px 500px at 110% -10%, #e6ddff 0%, transparent 60%),
    radial-gradient(900px 420px at -10% 110%, #efe9ff 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

/* Wrapper für Sidebar + Content */
#app {
  display: flex;
  min-height: 100vh;
}

/* --------- Sidebar (links, fixiert) --------- */
.sidebar {
  position: fixed;
  top: 20px;
  left: 20px;
  height: calc(100vh - 40px);
  width: 240px;
  background: linear-gradient(165deg, #6549d5 0%, #4a33aa 55%, #301e6f 100%);
  border-radius: var(--radius);
  padding: 30px 20px;
  box-shadow: 0 14px 36px rgba(72, 45, 160, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 100;
  overflow-y: auto;
}

.sidebar .profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 12px 16px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  width: 100%;
  backdrop-filter: blur(4px);
}

.sidebar .profile-pic {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
  border: 3px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Textcontainer im Profil, linksbündig */
.sidebar .profile-text {
  width: 100%;
  text-align: left;
}

.sidebar .profile-text p {
  margin-bottom: 18px;
  font-size: 1rem;
  line-height: 1.4;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

/* Label fett, eigene Zeile */
.sidebar .profile-text p strong {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
  margin-bottom: 4px;
}

/* kleiner, dezenter Untertext */
.sidebar .profile-text p .small-label {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
  padding-left: 0;
  border: none;
}

/* Wert (z.B. Benutzername, Kartennummer) */
.sidebar .profile-text p span:not(.small-label) {
  display: block;
  font-weight: 700;
  font-size: 1.12rem;
  color: #e9e2ff;
}

/* Ansicht-Umschalter (nur Chef) */
.sidebar .view-as select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.sidebar .view-as select option {
  color: var(--text);
}

/* --------- Hauptbereich mit Navigation oben --------- */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  margin: 20px 20px 20px 290px;
}

/* --------- Horizontale Navigation (oben) --------- */
.tabs-nav {
  position: sticky;
  top: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
}

.tabs-nav .tab-btn {
  background: transparent;
  color: var(--primary-dark);
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 1.02em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.tabs-nav .tab-btn:hover {
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.tabs-nav .tab-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(101, 73, 213, 0.35);
}

#logout-btn {
  margin-left: auto;
  background: #ffe9e9;
  color: #c0392b;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

#logout-btn:hover {
  background: #ff5959;
  color: #fff;
}

/* --------- Content Bereich --------- */
.content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 40px;
  min-height: 70vh;
  overflow-y: auto;
}

/* --------- Standard-Headings --------- */
h1, h2, h3 {
  color: var(--primary);
  font-family: inherit;
  margin-bottom: 1em;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: 2.1em; }
h2 { font-size: 1.4em; }
h3 { font-size: 1.15em; }
p { margin-bottom: 1em; }
a {
  color: var(--primary);
  text-decoration: underline;
  transition: color .18s;
}
a:hover, a:focus {
  color: var(--primary-deep);
}

/* --------- Formulare/Inputs --------- */
input, select, textarea, button {
  font-family: inherit;
  font-size: 1em;
}
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], textarea, select {
  border: 1.3px solid #e2d7fa;
  border-radius: 10px;
  padding: 10px 13px;
  background: #f9f8fe;
  transition: border 0.2s, background 0.2s, box-shadow 0.2s;
  margin-bottom: 1em;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(101, 73, 213, 0.15);
}
button, .btn, .button {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-weight: 700;
  font-size: 1.02em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(101, 73, 213, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
button:hover, .btn:hover, .button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(101, 73, 213, 0.32);
  color: #fff;
}
button:disabled, .button:disabled, .button.locked {
  filter: grayscale(0.4);
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* --------- Utility-Klassen --------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.m-0 { margin: 0 !important; }
.mb-2 { margin-bottom: 0.5em !important; }
.mb-4 { margin-bottom: 2em !important; }
.mt-2 { margin-top: 0.5em !important; }
.mt-4 { margin-top: 2em !important; }
.p-0 { padding: 0 !important; }
.px-2 { padding-left: 1em !important; padding-right: 1em !important; }

/* --------- Fehlermeldungen / Hinweise --------- */
.alert, .message, .error, .success {
  display: block;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: bold;
  margin-bottom: 1em;
  font-size: 1em;
}
.error, .alert-error { background: #ffdfe2; color: #be223a; }
.success, .alert-success { background: #e3ffd7; color: #1b8631; }
.info, .alert-info { background: #e8e8fe; color: var(--primary-dark); }

/* --------- Loader/Spinner --------- */
.loader,
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #ececec;
  border-radius: 50%;
  border-top: 3px solid var(--primary);
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* --------- Cards --------- */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  padding: 2em;
  margin-bottom: 2em;
}

/* --------- Overlay über dem Content beim Scrollen --------- */
.top-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 78px;
  background: var(--bg);
  z-index: 20;
  pointer-events: none;
}
.top-overlay.visible {
  display: block !important;
}

/* --------- Login/Registrierung (ausgeloggt) --------- */
body.logged-out #app .sidebar {
  display: none !important;
}

body.logged-out #app .main-content {
  margin: 0;
  width: 100vw;
  min-height: 100vh;
  box-shadow: none;
  border-radius: 0;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.logged-out .content {
  background: transparent;
  box-shadow: none;
}

/* --------- Responsive --------- */
img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  /* Sidebar wird zur schlanken Kopfleiste: kleines Bild, Infos in einer Zeile —
     das Tab-Menü bleibt damit direkt darunter sichtbar */
  .sidebar {
    position: static;
    height: auto;
    width: calc(100% - 20px);
    margin: 10px 10px 0 10px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    overflow: visible;
  }
  .sidebar .profile {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 4px 6px;
    background: transparent;
    border: none;
    backdrop-filter: none;
  }
  .sidebar .profile-pic {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    border-width: 2px;
    flex-shrink: 0;
  }
  .sidebar .profile-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 22px;
  }
  .sidebar .profile-text p {
    margin: 0;
    border: none;
    padding: 0;
    line-height: 1.25;
  }
  .sidebar .profile-text p strong {
    font-size: 0.66rem;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.75;
  }
  .sidebar .profile-text p .small-label {
    display: none;
  }
  .sidebar .profile-text p span:not(.small-label) {
    font-size: 0.95rem;
  }
  .sidebar .view-as select {
    margin-top: 0;
    padding: 4px 8px;
    width: auto;
    font-size: 0.88rem;
  }
  #app {
    flex-direction: column;
  }
  .main-content {
    margin: 8px 10px 10px 10px;
  }
  .tabs-nav {
    position: static;           /* sticky bringt auf Mobile nichts, klaut nur Platz */
    top: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    flex-wrap: nowrap;          /* Tabs in einer Zeile, horizontal wischbar */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-nav::-webkit-scrollbar { display: none; }
  .tabs-nav .tab-btn,
  #logout-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    font-size: 0.95em;
  }
  .content {
    padding: 20px;
  }

  /* Legacy-Modals (Rewards/Treffen) haben feste 786px → an den Viewport anpassen */
  .modal-content {
    width: calc(100vw - 28px) !important;
    max-width: 786px !important;
    left: 0 !important;
    max-height: 92vh;
    overflow-y: auto;
    padding: 22px 18px 20px 18px !important;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 15px;
  }
  .sidebar {
    width: calc(100% - 16px);
    margin: 8px 8px 0 8px;
    padding: 6px 10px;
  }
  .sidebar .profile-text {
    gap: 2px 14px;
  }
  .sidebar .profile-text p span:not(.small-label) {
    font-size: 0.9rem;
  }
  .main-content {
    margin: 8px 8px 8px 8px;
  }
  .content {
    padding: 14px 12px;
    overflow-x: hidden;
  }
  h1 { font-size: 1.6em; }
  h2 { font-size: 1.25em; }

  /* Treffen-Timeline: feste Spaltenbreiten → prozentual */
  .timeline-left,
  .timeline-right {
    width: 44% !important;
  }
}
