/* =========================================================
   Kraftwerk Geräte-Check – Stable CSS (Desktop + Mobile)
   ========================================================= */

:root{
  --max: 1200px;

  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;

  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --primary: #2563eb;

  --ok-bg: #ecfdf5;
  --ok-bd: #a7f3d0;
  --ok-tx: #065f46;

  --warn-bg: #fffbeb;
  --warn-bd: #fde68a;
  --warn-tx: #92400e;

  --bad-bg: #fef2f2;
  --bad-bd: #fecaca;
  --bad-tx: #991b1b;

  --shadow: 0 8px 20px rgba(0,0,0,0.06);
  --radius: 18px;
}

/* Hard anti-overflow baseline */
html, body{
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
}

/* Layout */
.container{
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px;
}

a{ color: inherit; }

hr{
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Cards */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  max-width: 100%;
}

.flash{
  border-color: #93c5fd;
  background: #eff6ff;
  margin-bottom: 12px;
}

/* Typography */
.h1{
  font-weight: 900;
  font-size: 18px;
  line-height: 1.2;
}
.small{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

/* Header */
.header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.nav{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons / inputs */
input, select, textarea, button{
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  max-width: 100%;
}

textarea{
  min-height: 90px;
  resize: vertical;
}

button{
  cursor: pointer;
  font-weight: 800;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
}

button.primary{
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Badge */
.badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  max-width: 100%;
  white-space: nowrap;
}

/* Rows */
.row{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.row > *{
  flex: 1 1 240px;
  min-width: 220px;
}

/* Grid: stable, no overflow */
.grid{
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Device card */
.device{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
  overflow: hidden; /* important: avoid any inner overflow */
}

/* Big image, stable */
.device img{
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: contain;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  padding: 12px;
  display: block;
}

/* Top row inside device card */
.device-top{
  display: grid;
  grid-template-columns: 88px 1fr auto; /* image (small), title, pill */
  gap: 12px;
  align-items: center;
  max-width: 100%;
}

.device-top img{
  width: 88px;
  aspect-ratio: 1/1;
  padding: 8px;
}

.device-title{
  min-width: 0; /* allow wrapping, prevents pushing pill */
}

.device-title *{
  overflow-wrap: anywhere;
}

.status-pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 100%;
}

/* Pill colors */
.pill-ok{
  background: var(--ok-bg);
  border-color: var(--ok-bd);
  color: var(--ok-tx);
}
.pill-warn{
  background: var(--warn-bg);
  border-color: var(--warn-bd);
  color: var(--warn-tx);
}

/* Checked state border */
.device-card.checked{ border-color: var(--ok-bd); }
.device-card.unchecked{ border-color: var(--warn-bd); }

/* Open issue border */
.device-card.has-open{ border-color: #f59e0b; }

/* Notices */
.notice{
  border-radius: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
  max-width: 100%;
}
.notice.warn{ background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-tx); }
.notice.info{ background: #eff6ff; border-color: #93c5fd; }

/* Signature */
.signature-wrap{
  border: 1px dashed #c7d2fe;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
}
canvas{
  width: 100%;
  height: 160px;
  display: block;
  touch-action: none;
}

/* Inline buttons */
.inline{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.inline > *{
  flex: 1 1 220px;
  min-width: 200px;
}

/* Mobile: one column, top becomes stacked */
@media (max-width: 720px){
  .container{ padding: 12px; }

  .grid{
    grid-template-columns: 1fr;
  }

  .row > *{
    min-width: 0;
    flex: 1 1 100%;
  }

  .device-top{
    grid-template-columns: 1fr;
    align-items: start;
  }

  .device-top img{
    width: 100%;
    aspect-ratio: 4/3;
    padding: 10px;
  }

  .status-pill{
    justify-content: flex-start;
    white-space: normal;
  }

  .badge{
    white-space: normal;
  }
}

/* =========================
   DESKTOP FIX (Device cards)
   ========================= */

/* Auf Desktop: Header als Flex, damit Titel Platz hat */
@media (min-width: 721px){
  .device-top{
    display: flex;
    align-items: center;
    gap: 12px;
  }

  /* kleines Header-Bild fest */
  .device-top img{
    width: 92px !important;
    height: 92px !important;
    aspect-ratio: 1/1 !important;
    object-fit: contain;
    padding: 8px !important;
    flex: 0 0 auto;
  }

  /* Titel bekommt Platz, darf umbrechen aber nicht buchstabenweise */
  .device-title{
    flex: 1 1 auto;
    min-width: 0;
  }

  .device-title *{
    overflow-wrap: normal;
    word-break: normal;
    hyphens: auto;
  }

  /* Pill immer rechts, nie schrumpfen */
  .status-pill{
    margin-left: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* Optional: Grid auf Desktop etwas breiter, damit Karten nicht zu schmal sind */
@media (min-width: 1024px){
  .grid{
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  }
}

/* =========================
   MOBILE: Name unter Bild
   ========================= */
@media (max-width: 720px){
  .device-top{
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* das kleine Header-Bild soll auf Mobile wieder gross sein */
  .device-top img{
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4/3 !important;
    padding: 10px !important;
  }

  .device-title{
    width: 100% !important;
  }

  .status-pill{
    align-self: flex-start !important;
    white-space: normal !important;
  }
}

