/* ============================================================================
   BASE.CSS — GPS Tracker v6.0
   Globales Layout, Navigation, Formulare, Flash Messages
   Wird in ALLEN Seiten über layout.html geladen.
   ============================================================================ */

/* Layout */
body {
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', sans-serif;
  transition: background 0.3s, color 0.3s;
}

/* Sidebar / Navbar */
nav {
  width: 240px;
  background-color: #f4f4f4;
  color: #222;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  transition: width 0.25s ease, background 0.3s, color 0.3s;
  overflow: hidden;
  flex-shrink: 0;
}
/* Icon-sidebar: collapses to 54px strip, not 0 */
body.nav-collapsed nav {
  width: 54px;
}

/* Full logo — visible when nav is expanded, click to collapse */
.nav-logo-full {
  display: flex;
  justify-content: center;
  cursor: pointer;
  padding-top: 6px;
}
.nav-logo-full img {
  width: 160px;
  margin: 4px auto 30px;
  transition: opacity 0.15s;
}
.nav-logo-full:hover img { opacity: 0.75; }

/* Icon logo — visible only when nav is collapsed, click to expand */
.nav-logo-icon {
  display: none;
  justify-content: center;
  padding: 14px 0;
  cursor: pointer;
}
.nav-logo-icon img {
  height: 38px;
  width: auto;
  object-fit: contain;
  transition: opacity 0.15s;
}
.nav-logo-icon:hover img { opacity: 0.75; }

body.nav-collapsed .nav-logo-full { display: none; }
body.nav-collapsed .nav-logo-icon { display: flex; }

/* Hide nav links and user section in collapsed state */
body.nav-collapsed nav > a,
body.nav-collapsed .nav-dropdown,
body.nav-collapsed .nav-user-section { display: none; }

nav a {
  padding: 15px 20px;
  color: #444;
  text-decoration: none;
  display: block;
  font-weight: 500;
}

nav a:hover,
nav a.active {
  background-color: #ddd;
  color: #000;
}

/* Hauptinhalt */
.content {
  flex: 1;
  min-width: 0;
  padding: 40px;
  background-color: #f9fbfd;
  color: #111;
  transition: background 0.3s, color 0.3s;
  overflow-y: auto;
}
body.page-map .content {
  overflow: hidden;
  padding: 0;
}

/* Überschrift */
h1 {
  font-size: 2rem;
  margin-bottom: 30px;
}

/* Einstellungen */
.section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid #3498db;
  color: #2c3e50;
  line-height: 1.3;
}

body.dark .section-title {
  color: #d0d8e0;
  border-left-color: #5dade2;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="number"],
select {
  padding: 10px;
  width: 100%;
  max-width: 320px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
  background-color: #fff;
  color: #000;
  margin-bottom: 12px;
}

button {
  padding: 10px 18px;
  font-size: 1rem;
  background-color: #4CAF50;
  border: none;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background-color: #45a049;
}

/* DARK THEME */
body.dark {
  background-color: #1e1e1e;
  color: #f0f0f0;
}

body.dark .content {
  background-color: #2a2a2a;
  color: #f0f0f0;
}

body.dark nav {
  background-color: #111;
  color: #fff;
}

body.dark nav a {
  color: #ccc;
}

body.dark nav a:hover,
body.dark nav a.active {
  background-color: #333;
  color: #fff;
}

body.dark input[type="number"],
body.dark select {
  background-color: #3a3a3a;
  color: #f0f0f0;
  border: 1px solid #666;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.tile {
  background-color: #ffffff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-align: center;
  font-weight: bold;
  transition: background 0.3s, color 0.3s;
}

body.dark .tile {
  background-color: #2d2d2d;
  color: #f0f0f0;
}

input[type="checkbox"] {
  transform: scale(1.3);
  margin: 6px 0 16px 0;
}

hr {
  border: none;
  border-top: 2px solid #ccc;
}

/* --- Shared Form Elements (also used in admin) --- */

textarea,
input[type="text"],
input[type="number"],
input[type="file"],
input[type="email"],
input:not([type]),
select {
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  background: white;
}

body.dark textarea,
body.dark input,
body.dark select {
  background: #3a3a3a;
  color: #f0f0f0;
  border-color: #555;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

button.danger {
  background-color: #e74c3c;
  color: white;
}

button.danger:hover {
  background-color: #c0392b;
}

button.small {
  font-size: 0.8rem;
  padding: 4px 10px;
}

#opacity-control input[type=range] {
  width: 140px;
}

/* ============================================================================
   RESPONSIVE GRID
   ============================================================================ */

@media (max-width: 1200px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .battery-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   NAV: User Info + Logout Button
   ============================================================================ */

.nav-user-section {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(0,0,0,0.12);
}

body.dark .nav-user-section {
  border-top-color: rgba(255,255,255,0.1);
}

.nav-user-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.nav-username {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark .nav-username {
  color: #aaa;
}

.sse-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.sse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  flex-shrink: 0;
  transition: background 0.4s;
}
.sse-status-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: #888;
  white-space: nowrap;
  transition: color 0.4s;
  line-height: 1;
}

.nav-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #888;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.nav-settings-btn:hover {
  background: rgba(0,0,0,0.08);
  color: #333;
}

body.dark .nav-settings-btn {
  color: #888;
}

body.dark .nav-settings-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #eee;
}

.nav-logout {
  width: 100%;
  padding: 8px 12px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.nav-logout:hover {
  background: #c0392b;
}

/* ============================================================================
   NAV: Admin Dropdown
   ============================================================================ */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.nav-dropdown-menu {
  display: none;
  flex-direction: column;
  background: rgba(0,0,0,0.06);
}

body.dark .nav-dropdown-menu {
  background: rgba(255,255,255,0.05);
}

.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-menu a {
  padding: 10px 20px 10px 36px;
  font-size: 0.88rem;
  font-weight: 400;
  color: #555;
}

body.dark .nav-dropdown-menu a {
  color: #bbb;
}

.nav-dropdown-menu a:hover {
  background: rgba(0,0,0,0.08);
  color: #000;
}

body.dark .nav-dropdown-menu a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* ============================================================================
   Flash Messages
   ============================================================================ */

.flash {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  font-weight: 500;
}
.flash-success { background: rgba(39,174,96,0.12); color: #27ae60; border-left: 3px solid #27ae60; }
.flash-error   { background: rgba(231,76,60,0.12); color: #e74c3c; border-left: 3px solid #e74c3c; }
.flash-info    { background: rgba(52,152,219,0.12); color: #2980b9; border-left: 3px solid #2980b9; }
.flash-warning { background: rgba(243,156,18,0.12); color: #f39c12; border-left: 3px solid #f39c12; }
body.dark .flash-success { background: rgba(39,174,96,0.18); color: #2ecc71; }
body.dark .flash-error   { background: rgba(231,76,60,0.18); color: #e74c3c; }
body.dark .flash-info    { background: rgba(52,152,219,0.18); color: #3498db; }
body.dark .flash-warning { background: rgba(243,156,18,0.18); color: #f1c40f; }

/* ============================================================================
   SETTINGS PAGE LAYOUT
   ============================================================================ */

.settings-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  max-width: 960px;
}

.settings-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px 24px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border: 1px solid rgba(0,0,0,0.06);
}

body.dark .settings-card {
  background: #2a2a2a;
  border-color: rgba(255,255,255,0.07);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.settings-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e8eaed;
  color: #5f6368;
}

body.dark .settings-card-title {
  color: #9aa0a6;
  border-bottom-color: #3c3c3c;
}

.settings-field {
  margin-bottom: 14px;
}
.settings-field:last-child { margin-bottom: 0; }

.settings-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #444;
}

body.dark .settings-field label { color: #bbb; }

.settings-field select,
.settings-field input[type="number"] {
  padding: 7px 10px;
  font-size: 0.85rem;
  width: 100%;
  max-width: none;
  margin-bottom: 0;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  box-sizing: border-box;
}

body.dark .settings-field select,
body.dark .settings-field input[type="number"] {
  background: #3a3a3a;
  color: #f0f0f0;
  border-color: #555;
}

.settings-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.settings-slider-row input[type=range] {
  flex: 1;
  margin-bottom: 0;
  padding: 0;
  width: auto;
  border: none;
  background: none;
}

.settings-slider-val {
  min-width: 26px;
  text-align: right;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: #555;
}

body.dark .settings-slider-val { color: #aaa; }

.settings-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  color: #333;
}

body.dark .settings-check-label { color: #ddd; }

.settings-check-label input[type=checkbox] {
  transform: scale(1.2);
  margin: 0;
  cursor: pointer;
}

.settings-hint {
  font-size: 0.76rem;
  color: #888;
  margin-top: 4px;
  line-height: 1.4;
}

.settings-save-btn {
  margin-top: 14px;
  padding: 7px 18px;
  font-size: 0.85rem;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}
.settings-save-btn:hover { background: #43a047; }
