/* --- VARIABLEN & THEME --- */
:root {
  --bg-main: #333333;
  --bg-secondary: #444444;
  --primary-accent: #831b91;
  --blue-accent: #831b91;
  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --table-header-bg: #222222;
  --input-border: #555555;
  --row-even: #3d3d3d;
  --row-odd: #444444;
  --highlight-color: #fff8b3;
}

/* --- GLOBALER RESET --- */
* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
}

/* --- TYPOGRAFIE --- */
h1, h2 {
  margin: 20px;
  color: var(--text-main);
}

/* --- NAVIGATION (NAVBAR) --- */
.navbar {
  background-color: #1a1a1a;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  width: 100%;
}

.nav-link {
  color: white;
  text-decoration: none;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 5px;
  transition: background 0.3s;
}

.nav-link:hover {
  background-color: #444;
}

.admin-link {
  display: none;
}

.admin-link.visible {
  display: inline-block;
  color: #ff5252;
  font-weight: bold;
  text-decoration: none;
  border: 1px solid #ff5252;
  padding: 5px 10px;
  border-radius: 4px;
}

.admin-link.visible:hover {
  background-color: #ff5252;
  color: white;
}

/* --- FORMULARE & EINGABEFELDER --- */
form {
  margin: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 15px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--input-border);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

form label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-main);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"] {
  padding: 8px 12px;
  border-radius: 5px;
  border: 1px solid var(--input-border);
  background-color: #2b2b2b;
  color: white;
  font-size: 16px;
}

input:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 5px rgba(131, 27, 145, 0.5);
}

/* --- STATISTIK DASHBOARD (MINI-BAR) --- */
.stats-mini-bar {
  display: inline-flex;
  flex-direction: column;
  gap: 12px;
  background-color: #222222;
  color: white;
  padding: 15px;
  margin: 15px 20px;
  border-radius: 8px;
  min-width: 250px;
  border: 1px solid #444;
}

.stats-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.counter-section {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.counter-label { font-size: 14px; color: var(--text-muted); }
.counter-value { font-size: 20px; font-weight: bold; color: var(--primary-accent); }

.stats-mini-nav { display: flex; gap: 5px; }

.btn-mini {
  background: #444;
  border: none;
  color: white;
  font-size: 10px;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.mini-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 5px;
  height: 50px;
  width: 100%;
  border-top: 1px solid #444;
  padding-top: 10px;
}

.mini-bar-wrapper {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.mini-bar {
  width: 70%;
  background-color: var(--primary-accent);
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.4s ease-out;
}

.mini-bar-value {
  font-size: 9px;
  font-weight: bold;
  color: var(--primary-accent);
  margin-bottom: 2px;
}

/* --- TABELLEN-STRUKTUR (DESKTOP) --- */
.table-container {
  width: 100%;
  padding: 0 10px;
  margin: 20px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

th {
  background-color: var(--table-header-bg);
  color: var(--primary-accent);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8em;
  letter-spacing: 2px;
  padding: 18px;
}

td {
  padding: 12px 10px;
  border-bottom: 1px solid #333;
  text-align: center;
}

tr:nth-child(even) { background-color: var(--row-even); }
tr:nth-child(odd) { background-color: var(--row-odd); }

/* --- SPEZIELLE ZEILENZUSTÄNDE --- */
tr.highlighted {
  background-color: var(--highlight-color) !important;
  color: #222222 !important;
}

tr.completed {
  opacity: 0.3;
  background-color: #1a1a1a !important;
  text-decoration: line-through;
}

/* --- BUTTONS --- */
button {
  padding: 8px 15px;
  border-radius: 5px;
  border: none;
  background-color: var(--blue-accent);
  color: white;
  cursor: pointer;
  font-weight: bold;
  min-height: 40px;
}

.btn {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #555;
  cursor: pointer;
  background-color: #222;
  color: white;
  font-size: 0.85em;
  min-height: 35px;
}

.btn-tasksH:hover { background-color: var(--highlight-color); color: black; }
.btn-tasksD:hover { background-color: #ff5252; color: white; }
.btn-tasksC:hover { background-color: var(--primary-accent); color: white; }

th:first-child, td:first-child { display: none; }

#users-table th, #users-table td {
  display: table-cell !important;
}

/* --- RESPONSIVE DESIGN (HANDY OPTIMIERT) --- */
@media (max-width: 768px) {
  .navbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .nav-link, .navbar button, .admin-link.visible {
    width: 100%;
    text-align: center;
    font-size: 14px;
    padding: 12px 5px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .admin-link.visible { grid-column: span 2; }

  form {
    flex-direction: column;
    align-items: stretch;
    margin: 10px;
  }

  form input:not([type="checkbox"]), form button {
    width: 100%;
    min-height: 45px;
  }

  /* Checkbox-Fix: Verhindert Strecken auf dem Handy */
  form input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    min-height: unset !important;
    margin: 0;
  }

  form label {
    width: auto;
    justify-content: flex-start;
    padding: 5px 0;
  }

  /* Gleichmäßige Verteilung der Statistik-Buttons */
  .stats-mini-bar {
    display: flex;
    width: calc(100% - 20px);
    margin: 10px auto;
  }

  .stats-mini-nav {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 5px;
  }

  .btn-mini {
    flex: 1; /* Alle Buttons gleich groß */
    text-align: center;
    padding: 10px 0;
  }

  /* Tabellen als Karten */
  table, thead, tbody, th, td, tr { display: block; }
  thead tr { position: absolute; top: -9999px; left: -9999px; }
  tr { border: 1px solid #555; margin-bottom: 15px; border-radius: 8px; padding: 10px; background-color: var(--bg-secondary) !important; }
  
  td {
    border: none;
    border-bottom: 1px solid #333;
    position: relative;
    padding: 12px 10px 12px 45%; /* Platz für Label links */
    text-align: right;
    font-size: 14px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  td:last-child { border-bottom: none; text-align: center; padding-left: 10px; justify-content: center; gap: 5px; }

  /* Violette Labels für Titel und Fällig */
  td:nth-of-type(2):before, 
  td:nth-of-type(3):before {
    position: absolute;
    left: 10px;
    font-weight: bold;
    background-color: #831b91;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
  }

  td:nth-of-type(2):before { content: "Titel"; }
  td:nth-of-type(3):before { content: "Fällig"; }

  .btn {
    width: 32%;
    font-size: 10px;
    padding: 8px 2px;
  }

  h1, h2 { text-align: center; font-size: 1.4em; margin: 15px; }
}