/* ============================================================
   DME Pro v3.4 – Digitaler Meldeempfänger
   ============================================================ */

:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --accent: #ff9800;
  --alarm-red: #d32f2f;
  --success-green: #388e3c;
  --bg-dark: #0d1117;
  --bg-card: #1a1f26;
  --bg-screen: #0a0f14;
  --text-primary: #ffffff;
  --text-secondary: #b0bec5;
  --text-muted: #607d8b;
  --border-color: #2c3e50;
}

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

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  padding-bottom: 50px;
}

.melder-container {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
  flex-wrap: wrap;
}

/* ============================================================
   DEVICE
   ============================================================ */

.melder-device {
  width: 420px;
  background: linear-gradient(135deg, #1c2833 0%, #263238 100%);
  border-radius: 32px;
  border: 6px solid #0d1117;
  box-shadow:
    0 0 0 3px #2c3e50,
    0 30px 80px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  transition: all 0.3s ease;
}

.melder-device.alarm-active {
  animation: device-alarm 0.15s infinite;
  box-shadow:
    0 0 0 4px var(--alarm-red),
    0 0 40px rgba(211, 47, 47, 0.6),
    0 30px 80px rgba(0, 0, 0, 0.9);
}

@keyframes device-alarm {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-0.5deg); }
  50% { transform: translate(3px, -2px) rotate(0.5deg); }
  75% { transform: translate(-2px, 3px) rotate(0deg); }
}

/* Header */
.melder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.header-brand h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #b0bec5;
  text-transform: uppercase;
}

.header-brand p {
  font-size: 10px;
  color: #546e7a;
  letter-spacing: 1px;
  margin-top: 2px;
}

.header-status {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.signal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  transition: all 0.3s;
}

.signal-dot.disconnected {
  background: #607d8b;
}

.signal-dot.alarm {
  background: var(--alarm-red);
  animation: blink 0.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Time Display */
.time-display {
  text-align: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 600;
  color: #4caf50;
  letter-spacing: 2px;
}

/* Screen */
.melder-screen {
  background: var(--bg-screen);
  border-radius: 14px;
  border: 4px solid #0d1117;
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.8),
    0 0 0 1px #1a252f;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.screen-view {
  display: none;
  width: 100%;
  height: 100%;
}

.screen-view.active {
  display: flex;
}

/* Screen - Idle State */
#screen-idle {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.idle-icon {
  font-size: 48px;
  filter: drop-shadow(0 0 12px rgba(76, 175, 80, 0.5));
}

.idle-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #4caf50;
  font-family: 'Courier New', monospace;
}

.idle-subtext {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.idle-wache {
  margin-top: 12px;
  font-size: 13px;
  color: #78909c;
  padding: 6px 12px;
  border: 1px solid #263238;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

/* Screen - Alarm State */
#screen-alarm {
  flex-direction: column;
  gap: 0;
}

.alarm-header {
  background: linear-gradient(90deg, #c62828 0%, #d32f2f 50%, #c62828 100%);
  padding: 10px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 3px;
  color: #fff;
  animation: alarm-pulse 0.6s infinite;
  width: 100%;
}

@keyframes alarm-pulse {
  0%, 100% { background: linear-gradient(90deg, #c62828 0%, #d32f2f 50%, #c62828 100%); }
  50% { background: linear-gradient(90deg, #b71c1c 0%, #c62828 50%, #b71c1c 100%); }
}

.alarm-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}

.alarm-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  border-left: 3px solid var(--alarm-red);
}

.alarm-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-weight: 600;
  min-width: 50px;
}

.alarm-value {
  font-size: 13px;
  color: #fff;
  font-weight: 600;
  flex: 1;
}

.alarm-desc {
  font-size: 11px;
  color: #b0bec5;
  line-height: 1.4;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alarm-time {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.prio-badge {
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.prio-badge.hoch {
  background: var(--alarm-red);
  color: #fff;
}

.prio-badge.mittel {
  background: var(--accent);
  color: #000;
}

.prio-badge.niedrig {
  background: #4caf50;
  color: #000;
}

/* Screen - Acknowledged State */
#screen-ack {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.ack-icon {
  font-size: 40px;
  color: #a5d6a7;
  animation: ack-pulse 2s infinite;
}

@keyframes ack-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ack-title {
  font-size: 18px;
  font-weight: bold;
  color: #a5d6a7;
  letter-spacing: 3px;
}

.ack-id {
  font-size: 14px;
  color: #fff;
}

.ack-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   CONTROLS
   ============================================================ */

.melder-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

.wache-select {
  flex: 1;
  background: #263238;
  color: #cfd8dc;
  border: 2px solid #37474f;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: all 0.2s;
}

.wache-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(25, 118, 210, 0.3);
}

.button-group {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 90px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  transition: all 0.08s;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3), 0 12px 20px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.3);
}

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

.btn-icon {
  font-size: 24px;
  line-height: 1;
}

.btn-label {
  font-size: 10px;
  letter-spacing: 1px;
}

.btn-ack {
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
  color: #a5d6a7;
  box-shadow:
    0 8px 0 #0d3317,
    0 12px 20px rgba(0, 0, 0, 0.5),
    0 0 0 0 rgba(76, 175, 80, 0.6);
}

.btn-ack:not(:disabled) {
  animation: pulse-ack 1.2s infinite;
}

@keyframes pulse-ack {
  0% {
    box-shadow:
      0 8px 0 #0d3317,
      0 12px 20px rgba(0, 0, 0, 0.5),
      0 0 0 0 rgba(76, 175, 80, 0.6);
  }
  50% {
    box-shadow:
      0 8px 0 #0d3317,
      0 12px 20px rgba(0, 0, 0, 0.5),
      0 0 0 12px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow:
      0 8px 0 #0d3317,
      0 12px 20px rgba(0, 0, 0, 0.5),
      0 0 0 0 rgba(76, 175, 80, 0);
  }
}

.btn-reset {
  background: linear-gradient(135deg, #37474f 0%, #455a64 100%);
  color: #cfd8dc;
}

.btn-mute {
  background: linear-gradient(135deg, #4a148c 0%, #6a1b9a 100%);
  color: #ce93d8;
}

.btn-mute.muted {
  background: linear-gradient(135deg, #6a1b9a 0%, #7b1fa2 100%);
  color: #ba68c8;
}

/* Speaker Grill */
.speaker-grill {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 5px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
}

.speaker-dot {
  width: 100%;
  aspect-ratio: 1;
  background: #546e7a;
  border-radius: 50%;
  transition: all 0.2s;
}

.melder-device.alarm-active .speaker-dot {
  background: var(--alarm-red);
  animation: speaker-pulse 0.3s infinite;
}

@keyframes speaker-pulse {
  0%, 100% {
    transform: scale(1);
    background: var(--alarm-red);
  }
  50% {
    transform: scale(1.1);
    background: #ff5252;
  }
}

/* ============================================================
   HISTORY PANEL
   ============================================================ */

.history-panel {
  width: 360px;
  background: var(--bg-card);
  border-radius: 16px;
  border: 2px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 600px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 12px;
}

.history-header h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

.clear-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s;
}

.clear-btn:hover {
  transform: scale(1.2);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 500px;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 12px;
}

.history-entry {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border-left: 4px solid var(--border-color);
  font-size: 11px;
  transition: all 0.2s;
}

.history-entry.status-ack {
  border-left-color: #4caf50;
  background: rgba(76, 175, 80, 0.08);
}

.history-entry.status-ignored {
  border-left-color: #ff9800;
  background: rgba(255, 152, 0, 0.08);
}

.history-entry:hover {
  background: rgba(255, 255, 255, 0.08);
}

.entry-id {
  font-weight: 700;
  color: var(--text-primary);
}

.entry-ort {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-time {
  color: var(--text-muted);
  text-align: right;
  font-family: 'Courier New', monospace;
}

.entry-status {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

.entry-status.status-ack {
  color: #4caf50;
}

.entry-status.status-ignored {
  color: #ff9800;
}

/* ============================================================
   CONNECTION BAR
   ============================================================ */

.connection-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: #1a5e20;
  border-top: 2px solid #2e7d32;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #a5d6a7;
  z-index: 1000;
  transition: all 0.3s;
}

.connection-bar.disconnected {
  background: #b71c1c;
  border-top-color: #d32f2f;
  color: #ffcdd2;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  animation: pulse-dot 1s infinite;
}

.connection-bar.disconnected .connection-dot {
  background: #ff5252;
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

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

@media (max-width: 900px) {
  .melder-container {
    flex-direction: column;
    align-items: center;
  }

  .melder-device {
    width: 100%;
    max-width: 420px;
  }

  .history-panel {
    width: 100%;
    max-width: 420px;
  }
}

@media (max-width: 600px) {
  .melder-device {
    width: 100%;
    padding: 16px;
  }

  .melder-screen {
    min-height: 280px;
  }

  .button-group {
    gap: 6px;
  }

  .btn {
    height: 70px;
  }

  .history-panel {
    width: 100%;
    max-height: 400px;
  }
}
