/* =====================================================
 * GastroAudit — Styles
 * Vanilla CSS. Mobile-First. DSGVO-safe (keine externen Fonts).
 * ===================================================== */

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

:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --card-bg: #171717;
  --fg: #f5f5f5;
  --fg-muted: #a1a1aa;
  --muted: #64748b;
  --border: #262626;
  --border-strong: #3f3f46;
  --accent-start: #10b981;
  --accent-end: #059669;
  --accent: #10b981;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --success: #22c55e;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --card-bg: #ffffff;
  --fg: #09090b;
  --fg-muted: #52525b;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.tagline {
  font-size: 13px;
  color: var(--fg-muted);
  display: none;
}

.header-spacer {
  flex: 1;
}

.user-email {
  font-size: 13px;
  color: var(--fg-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Main Layout ---------- */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

main.dashboard {
  max-width: 960px;
}

.auth-intro {
  text-align: center;
  margin-bottom: 24px;
}

.auth-intro h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-intro p {
  font-size: 14px;
  color: var(--fg-muted);
}

/* ---------- Views (DOM-Switch) ---------- */
[data-view] {
  display: none;
}

[data-view].active {
  display: block;
}

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

input::placeholder {
  color: var(--muted);
}

/* ---------- Error box ---------- */
.form-error {
  min-height: 0;
  margin-bottom: 12px;
}

.form-error:empty {
  display: none;
}

.form-error[data-visible="true"] {
  padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.92;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elev);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  padding: 8px 12px;
  min-height: 36px;
  font-size: 13px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--fg);
}

.btn-block {
  width: 100%;
}

/* ---------- Form links ---------- */
.form-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  text-align: center;
}

.form-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.form-links a:hover {
  text-decoration: underline;
}

/* ---------- Dashboard ---------- */
.dashboard-greeting {
  margin-bottom: 24px;
}

.dashboard-greeting h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.dashboard-greeting p {
  color: var(--fg-muted);
  font-size: 14px;
}

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

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.betrieb-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.betrieb-card {
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.betrieb-card-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.betrieb-card-meta {
  font-size: 12px;
  color: var(--fg-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
  background: var(--card-bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

.placeholder-note {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--fg-muted);
  text-align: center;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-backdrop[data-open="true"] {
  display: flex;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 40px auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.modal-close:hover {
  color: var(--fg);
  background: var(--bg-elev);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- Footer / Disclaimer ---------- */
.disclaimer {
  max-width: 960px;
  margin: 40px auto 0;
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.disclaimer a {
  color: var(--muted);
  text-decoration: none;
  margin: 0 4px;
}

.disclaimer a:hover {
  color: var(--fg-muted);
  text-decoration: underline;
}

/* ---------- Desktop breakpoint ---------- */
@media (min-width: 768px) {
  .tagline {
    display: inline;
    padding-left: 12px;
    border-left: 1px solid var(--border);
    margin-left: 4px;
  }

  .auth-intro h1 {
    font-size: 28px;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-row-3 {
    grid-template-columns: 2fr 1fr 1.5fr;
  }

  .betrieb-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  main.dashboard .betrieb-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Optional light mode via system pref ---------- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafafa;
    --bg-elev: #ffffff;
    --card-bg: #ffffff;
    --fg: #09090b;
    --fg-muted: #52525b;
    --muted: #71717a;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
