/* ============================================================
   Ingenieurbüro Bromberger — Design System
   ============================================================ */

:root {
  --primary:      #0e7490;
  --primary-dark: #0a5f73;
  --primary-light:#e0f2fe;
  --accent:       #f97316;
  --accent-dark:  #ea6c05;
  --error:        #b3342b;
  --error-light:  #fef2f2;
  --success:      #147a45;
  --success-light:#f0fdf4;
  --warn:         #b45309;
  --warn-light:   #fffbeb;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-300:     #cbd5e1;
  --gray-400:     #94a3b8;
  --gray-500:     #64748b;
  --gray-600:     #475569;
  --gray-700:     #334155;
  --gray-800:     #1e293b;
  --gray-900:     #0f172a;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 25px rgba(0,0,0,.1);
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-h:     56px;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─────────────────────────────────────────── */

h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); text-transform: uppercase; }
h2 { font-size: 1.25rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1rem; font-weight: 600; color: var(--gray-700); }
p  { color: var(--gray-600); }

/* ─── Header ─────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-md);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.app-header .logo svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sync-status {
  font-size: .75rem;
  padding: .2rem .5rem;
  border-radius: 99px;
  white-space: nowrap;
}
.sync-status.saving { background: rgba(255,255,255,.2); color: white; }
.sync-status.saved  { background: rgba(20,122,69,.3);  color: #bbf7d0; }
.sync-status.error  { background: rgba(179,52,43,.3);  color: #fecaca; }

/* ─── Navigation ─────────────────────────────────────────── */

.nav-bar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .6rem .9rem;
  font-size: .7rem;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { color: var(--primary); }
.nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ─── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

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

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

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #a12b23; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0f6337; }

.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .45rem; border-radius: var(--radius-sm); }

/* ─── Cards ───────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  padding: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

/* ─── Forms ───────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-600);
}

input, select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  font-size: .9rem;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,116,144,.15);
}
textarea { resize: vertical; min-height: 80px; }

.frist-quick-btns {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}
.frist-btn {
  padding: .38rem .7rem;
  font-size: .8rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.frist-btn:hover {
  background: var(--primary-50, #ecfeff);
  border-color: var(--primary);
  color: var(--primary);
}
.frist-btn--custom {
  border-style: dashed;
}
.frist-current-val {
  display: inline-block;
  margin-top: .2rem;
  font-size: .78rem;
  color: var(--gray-600);
  font-weight: 500;
}
.frist-date-input {
  margin-top: .3rem;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 480px) {
  .input-row { grid-template-columns: 1fr; }
}

/* ─── Badges / Pills ──────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .6rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-offen       { background: var(--warn-light);    color: var(--warn); }
.badge-in_bearbeit { background: var(--primary-light); color: var(--primary-dark); }
.badge-erledigt    { background: var(--success-light); color: var(--success); }
.badge-entwurf     { background: var(--gray-100);      color: var(--gray-600); }
.badge-final       { background: var(--primary-light); color: var(--primary-dark); }
.badge-versendet   { background: var(--success-light); color: var(--success); }

/* ─── Lists ───────────────────────────────────────────────── */

.item-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.item-row {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.item-row:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.item-row-meta { flex: 1; min-width: 0; }
.item-row-meta h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row-meta p  { font-size: .8rem; color: var(--gray-500); margin-top: .1rem; }

/* ─── Stats Dashboard ─────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.stat-card .stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: .78rem;
  color: var(--gray-500);
}
.stat-card--sm {
  padding: .6rem .75rem;
  gap: .2rem;
}
.stat-card--sm .stat-num {
  font-size: 1.4rem;
}
.stat-card--sm .stat-label {
  font-size: .72rem;
}

/* Firma-Karten im Dashboard */
.firma-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: box-shadow .15s;
}
.firma-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.firma-card-info { flex: 1; min-width: 0; }
.firma-card-info h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.firma-card-info p  { font-size: .78rem; color: var(--gray-500); margin: 0; }
.firma-card-stats { display: flex; gap: .5rem; flex-shrink: 0; }
.firma-stat { text-align: center; min-width: 44px; }
.firma-stat-num { font-size: 1.1rem; font-weight: 700; color: var(--primary); line-height: 1; }
.firma-stat-label { font-size: .65rem; color: var(--gray-500); }
.firma-stat--warn .firma-stat-num { color: var(--error); }
.firma-stat--ok .firma-stat-num  { color: var(--success); font-size: .9rem; }
.firma-stat--ok .firma-stat-label { color: var(--success); }
.final-check { color: var(--success); font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.btn-archiv { background: none; border: none; cursor: pointer; color: var(--gray-400); padding: .25rem .3rem; border-radius: var(--radius-sm); flex-shrink: 0; }
.btn-archiv:hover { color: var(--gray-600); background: var(--gray-100); }

/* ─── Mängel / Maßnahmen ─────────────────────────────────── */

.mangel-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.mangel-header {
  background: var(--gray-50);
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}
.mangel-body { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }

.massnahme-block {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

/* ─── Foto-Grid ───────────────────────────────────────────── */

.foto-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
}
@media (max-width: 480px) {
  .foto-grid { grid-template-columns: repeat(2, 1fr); }
}

.foto-slot {
  aspect-ratio: 1;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  cursor: pointer;
  font-size: .72rem;
  color: var(--gray-400);
  transition: border-color .15s, background .15s;
  overflow: hidden;
  position: relative;
}
.foto-slot:hover { border-color: var(--primary); background: var(--primary-light); }
.foto-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.foto-slot .foto-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 99px;
  width: 22px;
  height: 22px;
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}
.foto-slot:hover .foto-del { opacity: 1; }

/* ─── Spracheingabe-Button ────────────────────────────────── */

.voice-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: .3rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.voice-btn:hover { color: var(--primary); background: var(--primary-light); }
.voice-btn.recording { color: var(--error); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

.voice-field-wrap {
  display: flex;
  gap: .4rem;
  align-items: flex-start;
}
.voice-field-wrap textarea { flex: 1; }

/* ─── Modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.modal-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* ─── Toast ───────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  background: var(--gray-800);
  color: white;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Empty State ─────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--gray-400);
  text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: .4; }
.empty-state p   { font-size: .9rem; }

/* ─── Seiten-Layout ───────────────────────────────────────── */

.page {
  display: none;
  padding: 1rem;
  max-width: 860px;
  margin: 0 auto;
}
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .5rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: .5rem;
}

/* ─── Druck / PDF ─────────────────────────────────────────── */

@media print {
  .no-print { display: none !important; }
  .app-header, .nav-bar { display: none !important; }
  body { background: white; }
  .page { display: block !important; padding: 0; }
}

/* ─── Scrollbar ───────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── Utility ─────────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: .75rem; }
.gap-lg { gap: 1rem; }
.mt-sm { margin-top: .5rem; }
.mt-md { margin-top: .75rem; }
.mt-lg { margin-top: 1rem; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: .5rem 0;
}
