/*
 * Couply Webapp Stylesheet
 *
 * Dieses Stylesheet orientiert sich am ursprünglichen Dark‑Mode‑Design der
 * Couply‑App (Smaragdgrün und Babyblau) und bietet darüber hinaus eine
 * helle Variante. Es enthält außerdem Styles für Login‑ und
 * Registrierungsseiten. Die Farbwerte lassen sich zentral über CSS
 * Variablen anpassen.
 */

/* Farbvariablen */
:root {
  /* Light Mode Farben */
  --color-background: #f5f7fb;
  --color-surface: #ffffff;
  --color-primary: #4a90e2;
  --color-primary-dark: #357abd;
  --color-secondary: #7a64e8;
  --color-text: #31374a;
  --color-muted: #7f8fa6;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-danger: #c0392b;
  --sidebar-width: 220px;
  --color-sidebar-bg: var(--color-primary);
  /* Dark Mode Farben (werden über body.dark-mode aktiviert) */
  --color-background-dark: #0f172a;
  --color-surface-dark: #1c2538;
  --color-text-dark: #e6e8ef;
  --color-muted-dark: #94a3b8;
  --color-primary-darkmode: #00b894;
  --color-secondary-darkmode: #74b9ff;
  --color-success-dark: #00b894;
  --color-warning-dark: #f9c74f;
  --color-danger-dark: #e74c3c;
}

/* Generelle Defaults */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--color-background);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background-color: var(--color-sidebar-bg);
  color: #fff;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.logo-image {
  width: 40px;
  height: 40px;
  margin-bottom: 0.25rem;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: bold;
}

.sidebar nav ul {
  list-style: none;
  flex: 1;
}

.sidebar nav ul li {
  cursor: pointer;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.sidebar nav ul li .icon {
  font-size: 1.1rem;
}

.sidebar nav ul li:hover,
.sidebar nav ul li.active {
  background-color: var(--color-primary-dark);
}

/* Dark Mode Überschreibungen */
body.dark-mode {
  --color-background: var(--color-background-dark);
  --color-surface: var(--color-surface-dark);
  --color-text: var(--color-text-dark);
  --color-muted: var(--color-muted-dark);
  --color-primary: var(--color-primary-darkmode);
  --color-primary-dark: var(--color-primary-darkmode);
  --color-secondary: var(--color-secondary-darkmode);
  --color-success: var(--color-success-dark);
  --color-warning: var(--color-warning-dark);
  --color-danger: var(--color-danger-dark);
  --color-sidebar-bg: #1c2538;
}

/* Hauptinhalt */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  flex: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

/* Kartenlayout */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.card {
  background-color: var(--color-surface);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

body.dark-mode .card,
body.dark-mode .item-card,
body.dark-mode .data-table,
body.dark-mode .summary,
body.dark-mode .account-card,
body.dark-mode .profile-card,
body.dark-mode .auth-container {
  background-color: #1e2d44;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

body.dark-mode .data-table th {
  background-color: #243754;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  color: var(--color-primary);
}

.card p,
.card ul {
  font-size: 0.95rem;
  color: var(--color-text);
}

/* Zusatzinfo für Durchschnittswerte im Dashboard */
.average-info {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.3rem;
}

.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.simple-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid #e4e6eb;
}

.simple-list li:last-child {
  border-bottom: none;
}

/*
 * Abschnittsheader und Überschriften
 *
 * Viele Bereiche (Fixkosten, Monat, Verträge, Wohnung) beginnen mit einem
 * Header, der Buttons enthält. Hier definieren wir einen konsistenten
 * Stil: horizontales Layout, kleiner Abstand zwischen den Elementen und
 * Abstand zum nachfolgenden Inhalt. Dadurch wirken die Module wie
 * separate "Karten" und nicht wie endlose Tabellen.
 */
.section-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Spezieller Header für die Monatsauswahl: Pfeile stehen eng zusammen,
   der Zusatzbutton wird nach rechts geschoben. */
.month-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.month-switcher > #add-extra-entry {
  margin-left: auto;
}

/* Buttons innerhalb einer Karte, z. B. Editieren/Löschen */
.item-actions {
  display: flex;
  gap: 0.25rem;
}
/* Kleinerer Button für Item‑Aktionen */
.btn.icon-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Dropdown/PopUp für Item‑Menü (wird per JS ein-/ausgeblendet) */
.item-menu {
  position: absolute;
  right: 0.5rem;
  top: 2.5rem;
  background-color: var(--color-surface);
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  z-index: 1000;
}
.item-menu button {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
}
.item-menu button:hover {
  background-color: var(--color-muted);
  color: #fff;
}

/* Jahr Übersichtsbereich */
.year-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.year-summary .year-item {
  background-color: var(--color-surface);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}
.year-summary .year-item .year-info {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}
.year-summary .year-item .year-values {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}

/* Details in der Jahresübersicht */
.year-summary .year-details {
  width: 100%;
  margin-top: 0.5rem;
}

/* Abstände für Listencontainer oberhalb und unterhalb */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  background-color: var(--color-sidebar-bg);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn:hover {
  background-color: var(--color-primary-dark);
}

.btn.secondary {
  background-color: var(--color-muted);
  color: #fff;
}

.btn.secondary:hover {
  background-color: #6c7a89;
}

/* Listencontainer */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Eintragskarten für Monatsübersicht */
.entry-card {
  display: flex;
  align-items: flex-start;
  background-color: var(--color-surface);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  gap: 0.75rem;
  /* Position relative, damit Menü‑Buttons korrekt absolut platziert werden können */
  position: relative;
}

.entry-card .entry-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.entry-card .entry-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.entry-card .entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.entry-card .entry-header .entry-owner {
  font-weight: 600;
  color: var(--color-primary);
}


/* Datum unter dem Namen in Eintragskarten */
.entry-card .entry-date {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: -0.1rem;
}

.entry-card .entry-title {
  font-size: 1rem;
  color: var(--color-text);
  margin: 0;
}

.entry-card .entry-info {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.entry-card .entry-status {
  align-self: center;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #fff;
  text-transform: capitalize;
  margin-left: 0.75rem;
}

.entry-status.open {
  background-color: var(--color-warning);
}

.entry-status.paid {
  background-color: var(--color-success);
}

.entry-status.debited {
  background-color: var(--color-secondary);
}

/* Buttons innerhalb von Eintragskarten */
.entry-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.item-card {
  background-color: var(--color-surface);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.item-card .item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.item-card h4 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
  color: var(--color-primary);
}

.item-card span {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.item-card .item-actions {
  display: flex;
  gap: 0.5rem;
}

/* Tabelle für Monatsübersicht */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-surface);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  font-size: 0.9rem;
  border-bottom: 1px solid #e4e6eb;
}

.data-table th {
  background-color: #f0f2f5;
  color: var(--color-text);
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Statusbadges */
.status-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: capitalize;
  color: #fff;
}

.status-open {
  background-color: var(--color-warning);
}

.status-paid {
  background-color: var(--color-success);
}

.status-debited {
  background-color: var(--color-secondary);
}

/* Zusammenfassung */
.summary {
  margin-top: 1rem;
  background-color: var(--color-surface);
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 1.5rem;
}

.summary p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text);
}

/* Formulargruppen */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.form-group label {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text);
}

.form-group input,
.form-group select {
  padding: 0.5rem;
  border: 1px solid #d5d8dc;
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--color-text);
  background-color: var(--color-surface);
}

body.dark-mode .form-group input,
body.dark-mode .form-group select {
  background-color: #253b59;
  border-color: #405c7d;
  color: var(--color-text);
}

/* Modal Overlay und Formular */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background-color: var(--color-surface);
  padding: 1.5rem;
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.modal h3 {
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Responsive Anpassungen */
@media (max-width: 768px) {
  .sidebar {
    width: 180px;
  }
  .main-content {
    margin-left: 180px;
    padding: 1rem;
  }
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Auth-Seiten (Login & Registrierung) */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-background);
  color: var(--color-text);
  min-height: 100vh;
  padding: 2rem;
}

.auth-container {
  background-color: var(--color-surface);
  padding: 2rem;
  border-radius: 8px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .auth-container {
  background-color: #1e2d44;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.auth-container h1 {
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.5rem;
  color: var(--color-primary);
}

.auth-form .form-group input {
  width: 100%;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-danger {
  background-color: var(--color-danger);
  color: #fff;
}

.alert-success {
  background-color: var(--color-success);
  color: #fff;
}

.icon-link {
  color: #fff;
  text-decoration: none;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

/* Navigation auf Auth-Seiten ausblenden */
.auth-page .sidebar,
.auth-page .main-content {
  display: none;
}

/* Top Bar für eingeloggte Seiten */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: var(--color-surface);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 998;
}

body.dark-mode .top-bar {
  background-color: #1e2d44;
  border-color: rgba(255, 255, 255, 0.05);
}

.menu-icon {
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  margin-right: 1rem;
}

.top-title {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--color-text);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-name {
  font-size: 0.9rem;
  color: var(--color-text);
}

/* Layout adjustments for top bar */
.sidebar {
  top: 56px; /* leave space for top bar */
  height: calc(100vh - 56px);
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding-top: 56px; /* offset for top bar */
}

/* Collapsed sidebar (used on small screens) */
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
  margin-left: 0;
}

/* =============================================================== */
/* Zusätzliche Styles für überarbeitete Dashboard- und Menü-Elemente */

/* Notiz für Monatsstatus auf der Startseite */
.note {
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* Kompakte Info‑Übersicht im Dashboard */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.info-item {
  background-color: var(--color-surface);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.info-item h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}
.info-item span {
  font-size: 1rem;
  font-weight: 600;
}
.info-item small {
  font-size: 0.75rem;
  color: var(--color-muted);
}

/* Liste der letzten Einträge (wie Monatsübersicht) */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Menü‑Button (drei Punkte) */
.menu-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0;
  /* Vermeide Layoutverschiebungen */
  line-height: 1;
}
.menu-btn:hover {
  color: var(--color-primary);
}

/* Positioniere den Drei‑Punkte‑Button in Eintragskarten oben rechts */
.entry-card .menu-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

/* Popup-Menü für Einträge und Items */
.entry-menu,
.item-menu {
  position: absolute;
  right: 0.5rem;
  /* Menü wird direkt unterhalb des Menübuttons angezeigt */
  top: 1.8rem;
  background-color: var(--color-surface);
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  z-index: 1000;
}
.entry-menu button,
.item-menu button {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  color: var(--color-text);
}
.entry-menu button:hover,
.item-menu button:hover {
  background-color: var(--color-muted);
  color: #fff;
}