/* ============================================================
   mkTankManager – Styles (dark automotive theme)
   ============================================================ */

/* --- CSS Variables ---------------------------------------- */
:root {
  --bg:            #080b12;
  --surface:       #0f1520;
  --surface-2:     #161e2e;
  --surface-3:     #1a2438;
  --border:        #1e2d42;
  --border-soft:   #162034;

  --text:          #e2e8f0;
  --text-muted:    #6b7fa0;
  --text-subtle:   #3d5070;

  --primary:       #f59e0b;
  --primary-dim:   #f59e0b22;
  --primary-glow:  #f59e0b44;

  --diesel:        #f59e0b;
  --e10:           #3b82f6;
  --e5:            #10b981;

  --diesel-dim:    #f59e0b18;
  --e10-dim:       #3b82f618;
  --e5-dim:        #10b98118;

  --nav-bg:        #060810;
  --nav-height:    58px;

  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  --shadow-card:   0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:   0 0 30px rgba(245,158,11,0.15);

  --transition:    0.2s ease;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-top: var(--nav-height);
  overscroll-behavior: none;
}

/* --- Navigation -------------------------------------------- */
.app-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo {
  width: 28px;
  height: 28px;
  color: var(--primary);
  flex-shrink: 0;
}

.nav-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-actions {
  display: flex;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn svg { width: 18px; height: 18px; }

.nav-btn.spinning svg {
  animation: spin 1s linear infinite;
}

/* --- Loading Screen ---------------------------------------- */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--nav-height));
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Home Page -------------------------------------------- */
.home-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0 32px;
}

/* --- Meta Info Bar ---------------------------------------- */
.meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.meta-item svg {
  width: 13px;
  height: 13px;
  opacity: 0.7;
  flex-shrink: 0;
}

.meta-item strong {
  color: var(--text);
  font-weight: 600;
}

.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

/* --- Meta-Bar: editierbare Felder & Popovers -------------- */
.meta-bar {
  position: relative;
}

.meta-editable {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0 1px;
  transition: border-color var(--transition), color var(--transition);
}

.meta-editable:hover {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.gps-loc-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.gps-loc-btn svg {
  width: 13px;
  height: 13px;
}

.gps-loc-btn:hover {
  color: var(--primary);
}

.meta-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 16px;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 240px;
  box-shadow: var(--shadow-card);
}

.meta-popover-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.meta-popover-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.meta-input {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition);
}

.meta-input:focus {
  border-color: var(--primary);
}

.gps-fill-btn {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.gps-fill-btn svg {
  width: 14px;
  height: 14px;
}

.gps-fill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.gps-coords {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 6px;
  min-height: 14px;
}

.meta-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.meta-btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.meta-btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.meta-btn-save {
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: #000;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: opacity var(--transition);
}

.meta-btn-save:hover {
  opacity: 0.85;
}

.distanz-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.distanz-opt {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.distanz-opt:hover,
.distanz-opt.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
  font-weight: 600;
}

/* --- Interval Selector ------------------------------------ */
.interval-bar {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.interval-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.interval-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.interval-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
  font-weight: 700;
}

.interval-btn--raw {
  border-left: 1px solid var(--border-soft);
  margin-left: 4px;
  color: #6b7fa0;
  font-style: italic;
}

.interval-btn--raw.active {
  background: #1e3a5f;
  border-color: #3b82f6;
  color: #93c5fd;
  font-style: italic;
}

/* --- Period Navigator ------------------------------------- */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.period-nav.hidden {
  display: none;
}

.period-arrow {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.period-arrow:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--primary);
}

.period-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.period-label {
  font-size: 0.82rem;
  color: var(--text);
  font-family: var(--font-mono);
  min-width: 150px;
  text-align: center;
  white-space: nowrap;
}

/* --- Chart Container -------------------------------------- */
.chart-section {
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.points-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font);
  padding: 3px 9px;
  cursor: pointer;
  transition: all var(--transition);
}

.points-toggle svg {
  width: 10px;
  height: 10px;
  opacity: 0.5;
}

.points-toggle.active {
  border-color: var(--primary);
  color: var(--primary);
}

.points-toggle.active svg {
  opacity: 1;
}

.chart-container {
  position: relative;
  height: 220px;
  overflow: hidden;
}

.chart-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  flex-direction: column;
  gap: 8px;
}

.chart-no-data svg {
  width: 32px;
  height: 32px;
  opacity: 0.3;
}

/* --- Current Prices --------------------------------------- */
.prices-section {
  padding: 20px 16px 8px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* --- Price Cards ------------------------------------------ */
.prices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.price-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.price-card[data-sorte="Diesel"]::before    { background: var(--diesel); box-shadow: 0 0 12px var(--diesel-dim); }
.price-card[data-sorte="Super E10"]::before { background: var(--e10); box-shadow: 0 0 12px var(--e10-dim); }
.price-card[data-sorte="Super E5"]::before  { background: var(--e5); box-shadow: 0 0 12px var(--e5-dim); }

.price-card[data-sorte="Super E5"] {
  border-color: var(--e5);
  box-shadow: 0 0 0 1px var(--e5), inset 0 0 20px rgba(16,185,129,0.04);
}

.price-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.fuel-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.fuel-name {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: center;
}

.fuel-price {
  font-size: 1.65rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}

.price-card[data-sorte="Diesel"]    .fuel-price { color: var(--diesel); }
.price-card[data-sorte="Super E10"] .fuel-price { color: var(--e10); }
.price-card[data-sorte="Super E5"]  .fuel-price { color: var(--e5); }

.price-unit {
  font-size: 0.65rem;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Preisänderungs-Badge */
.price-trend {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.price-trend.up   { background: #ff444422; color: #ff6b6b; }
.price-trend.down { background: #10b98122; color: #10b981; }
.price-trend.flat { background: var(--surface-3); color: var(--text-muted); }

.price-minmax {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 6px;
  font-size: 0.72rem;
  font-family: var(--font-mono, monospace);
  color: var(--text-subtle);
}

.price-min { color: #10b981; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.price-max { color: #ff6b6b; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }

.minmax-meta {
  font-size: 0.60rem;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

/* --- Error Banner ----------------------------------------- */
.error-banner {
  margin: 16px;
  padding: 12px 16px;
  background: #ff44441a;
  border: 1px solid #ff444433;
  border-radius: var(--radius-sm);
  color: #ff8888;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Offline Badge ---------------------------------------- */
.offline-badge {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.8rem;
  color: var(--text-muted);
  z-index: 200;
  box-shadow: var(--shadow-card);
}

body.offline .offline-badge { display: block; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 480px) {
  .fuel-price { font-size: 1.35rem; }
  .prices-grid { gap: 8px; }
  .price-card { padding: 12px 8px; }
  .fuel-icon { font-size: 1.1rem; }
  .chart-container { height: 180px; }
}

@media (max-width: 360px) {
  .fuel-price { font-size: 1.15rem; }
  .fuel-name { font-size: 0.62rem; }
}

/* --- Chart.js Tooltip Override ----------------------------- */
.chartjs-tooltip {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
  font-family: var(--font) !important;
  font-size: 12px !important;
}

/* ---- Footer ----------------------------------------------- */

#appFooter {
  text-align: center;
  padding: 24px 0 calc(8px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--text-subtle);
  line-height: 1.9;
  font-family: var(--font-mono, monospace);
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--primary);
}

.footer-legal {
  display: block;
  margin-top: 4px;
}

/* ---- Install Banner --------------------------------------- */

.install-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 13px;
}

.install-banner.visible {
  display: flex;
}

.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.install-banner-text strong {
  color: var(--text);
  font-size: 13px;
}

.install-banner-text span {
  color: var(--text-muted);
  font-size: 11px;
}

.install-btn {
  background: var(--primary);
  color: #080b12;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.install-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ---- About Overlay & Panel -------------------------------- */

.about-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}

.about-overlay.visible {
  display: block;
}

.about-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  overflow-y: auto;
  padding: 24px 20px 40px;
  -webkit-overflow-scrolling: touch;
}

.about-panel.visible {
  display: block;
}

body.overlay-open {
  overflow: hidden;
}

.about-close {
  display: block;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 24px;
}

.about-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.about-logo {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
}

.about-logo span {
  color: var(--primary);
}

.about-version {
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  font-family: var(--font-mono, monospace);
  margin-bottom: 28px;
}

.about-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
}

.about-section:last-of-type {
  border-bottom: none;
}

.about-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.about-section p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.about-privacy {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 24px 0;
}

.about-privacy-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.about-privacy-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.about-privacy-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.about-links {
  text-align: center;
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.about-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.about-links a:hover {
  color: var(--primary);
}
