/* ============================================================
   DME – Digitaler Meldeempfänger  |  Styles v2.0
   ============================================================ */

:root {
    --device-bg:        #1c2833;
    --device-border:    #0d1117;
    --device-accent:    #d32f2f;
    --screen-bg:        #0a0f14;
    --screen-border:    #0d1117;
    --screen-text:      #c8e6c9;
    --screen-dim:       #607d8b;
    --idle-green:       #4caf50;
    --alarm-red:        #f44336;
    --alarm-orange:     #ff9800;
    --ack-green:        #2e7d32;
    --ack-text:         #a5d6a7;
    --btn-bg:           #263238;
    --btn-border:       #0d1117;
    --btn-ack-bg:       #1b5e20;
    --btn-ack-active:   #388e3c;
    --btn-reset-bg:     #37474f;
    --btn-mute-bg:      #4a148c;
    --panel-bg:         #1a1f26;
    --panel-border:     #2c3e50;
    --font-mono:        'Courier New', Courier, monospace;
    --font-ui:          'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    background: #0d1117;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 20px 60px;
    font-family: var(--font-ui);
}

/* ============================================================
   Seiten-Layout
   ============================================================ */
.melder-page {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================================
   Gerät
   ============================================================ */
.melder-device {
    width: 400px; /* Vergrößert von 320px */
    background: var(--device-bg);
    border-radius: 30px;
    border: 5px solid var(--device-border);
    box-shadow:
        0 0 0 2px #2c3e50,
        0 25px 70px rgba(0,0,0,0.8),
        inset 0 1px 0 rgba(255,255,255,0.05);
    padding: 25px 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    transition: box-shadow 0.3s;
}

.melder-device.alarm-active {
    animation: device-shake 0.15s infinite;
    box-shadow:
        0 0 0 3px var(--alarm-red),
        0 0 30px rgba(244, 67, 54, 0.5),
        0 20px 60px rgba(0,0,0,0.8);
}

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

/* Markenleiste */
.device-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
}

.brand-name {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: bold;
    color: #b0bec5;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.brand-model {
    font-size: 9px;
    color: #546e7a;
    letter-spacing: 1px;
}

/* ============================================================
   Bildschirm
   ============================================================ */
.melder-screen {
    background: var(--screen-bg);
    border-radius: 12px;
    border: 4px solid var(--screen-border);
    box-shadow:
        inset 0 3px 10px rgba(0,0,0,0.8),
        0 0 0 1px #1a252f;
    overflow: hidden;
    min-height: 300px; /* Vergrößert von 240px */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Statusleiste */
.screen-statusbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: rgba(0,0,0,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--screen-dim);
}

.statusbar-center {
    font-size: 10px;
    color: #78909c;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.statusbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-icon {
    font-size: 10px;
    color: var(--idle-green);
    transition: color 0.3s;
}

.signal-icon.disconnected { color: #546e7a; }
.signal-icon.alarm        { color: var(--alarm-red); animation: blink-signal 0.4s infinite; }

@keyframes blink-signal {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.battery-icon {
    font-size: 9px;
    color: var(--idle-green);
    letter-spacing: 1px;
}

/* Screen Views */
.screen-view {
    flex: 1;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px 12px;
    font-family: var(--font-mono);
    color: var(--screen-text);
}

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

/* --- Idle --- */
.screen-idle {
    gap: 6px;
    text-align: center;
}

.idle-logo {
    font-size: 36px;
    margin-bottom: 4px;
    filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.4));
}

.idle-status {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 4px;
    color: var(--idle-green);
}

.idle-sub {
    font-size: 11px;
    color: var(--screen-dim);
    letter-spacing: 2px;
}

.idle-wache {
    margin-top: 8px;
    font-size: 12px;
    color: #78909c;
    padding: 3px 10px;
    border: 1px solid #263238;
    border-radius: 4px;
}

/* --- Alarm --- */
.screen-alarm {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
}

.alarm-header-bar {
    background: var(--alarm-red);
    padding: 8px 12px;
    text-align: center;
    animation: alarm-bar-blink 0.5s infinite alternate;
}

@keyframes alarm-bar-blink {
    from { background: #b71c1c; }
    to   { background: #f44336; }
}

.alarm-blink-text {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    letter-spacing: 3px;
}

.alarm-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}

.alarm-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.alarm-id-label {
    font-size: 9px;
    color: var(--screen-dim);
    letter-spacing: 1px;
}

.alarm-id-value {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}

.alarm-prio-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    background: var(--alarm-orange);
    color: #000;
    margin-left: auto;
}

.alarm-prio-badge.prio-hoch    { background: var(--alarm-red);    color: #fff; }
.alarm-prio-badge.prio-mittel  { background: var(--alarm-orange); color: #000; }
.alarm-prio-badge.prio-niedrig { background: #4caf50;             color: #000; }

.alarm-field {
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    padding: 5px 8px;
    border-left: 3px solid var(--alarm-red);
}

.alarm-field-label {
    font-size: 9px;
    color: var(--screen-dim);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.alarm-field-value {
    font-size: 12px;
    color: var(--screen-text);
    word-break: break-word;
    line-height: 1.4;
}

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

.alarm-time-row {
    font-size: 10px;
    color: var(--screen-dim);
    text-align: right;
    margin-top: auto;
}

/* --- Quittiert --- */
.screen-ack {
    gap: 8px;
    text-align: center;
}

.ack-icon {
    font-size: 40px;
    color: var(--ack-text);
    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: var(--ack-text);
    letter-spacing: 3px;
}

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

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

.ack-hint {
    font-size: 10px;
    color: #455a64;
    margin-top: 6px;
    letter-spacing: 1px;
}

/* ============================================================
   Konfigurationszeile
   ============================================================ */
.melder-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-label {
    font-size: 11px;
    color: #78909c;
    white-space: nowrap;
}

.melder-select {
    flex: 1;
    background: #263238;
    color: #cfd8dc;
    border: 1px solid #37474f;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.melder-select:focus {
    border-color: #546e7a;
}

/* ============================================================
   Tasten
   ============================================================ */
.melder-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.melder-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 85px; /* Vergrößert von 70px */
    border-radius: 15px;
    border: none;
    cursor: pointer;
    background: var(--btn-bg);
    color: #b0bec5;
    box-shadow: 0 6px 0 var(--btn-border), 0 8px 15px rgba(0,0,0,0.5);
    transition: transform 0.08s, box-shadow 0.08s, background 0.2s;
    font-family: var(--font-mono);
    user-select: none;
}

.melder-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--btn-border), 0 2px 6px rgba(0,0,0,0.4);
}

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

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

.btn-label {
    font-size: 9px;
    letter-spacing: 1px;
    font-weight: bold;
}

/* OK-Taste */
.btn-ack {
    background: var(--btn-ack-bg);
    color: #a5d6a7;
}

.btn-ack:not(:disabled) {
    animation: ack-btn-pulse 1s infinite;
    color: #fff;
}

@keyframes ack-btn-pulse {
    0%   { box-shadow: 0 5px 0 #1a3320, 0 0 0 0 rgba(76, 175, 80, 0.6); }
    50%  { box-shadow: 0 5px 0 #1a3320, 0 0 0 10px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 5px 0 #1a3320, 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* Reset-Taste */
.btn-reset {
    background: var(--btn-reset-bg);
    color: #cfd8dc;
}

/* Mute-Taste */
.btn-mute {
    background: var(--btn-mute-bg);
    color: #ce93d8;
}

.btn-mute.muted {
    background: #4a148c;
    color: #7b1fa2;
}

/* ============================================================
   Lautsprecher-Gitter
   ============================================================ */
.speaker-grill {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    padding: 4px 8px;
    opacity: 0.25;
}

.speaker-dot {
    width: 4px;
    height: 4px;
    background: #546e7a;
    border-radius: 50%;
}

/* ============================================================
   Alarm-Verlauf Panel
   ============================================================ */
.alarm-history-panel {
    width: 350px; /* Vergrößert von 300px */
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    max-height: 700px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--panel-border);
    font-size: 13px;
    font-weight: bold;
    color: #b0bec5;
}

.history-clear-btn {
    background: none;
    border: none;
    color: #546e7a;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.2s;
}

.history-clear-btn:hover {
    color: #f44336;
}

.alarm-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alarm-history-list::-webkit-scrollbar { width: 4px; }
.alarm-history-list::-webkit-scrollbar-track { background: transparent; }
.alarm-history-list::-webkit-scrollbar-thumb { background: #37474f; border-radius: 2px; }

.history-empty {
    text-align: center;
    color: #455a64;
    font-size: 12px;
    padding: 20px;
    font-family: var(--font-mono);
}

.history-entry {
    background: rgba(255,255,255,0.04);
    border: 1px solid #263238;
    border-left: 3px solid var(--alarm-red);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #90a4ae;
    animation: entry-fade-in 0.3s ease;
}

.history-entry.acked {
    border-left-color: var(--idle-green);
    opacity: 0.75;
}

@keyframes entry-fade-in {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.history-entry-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.history-entry-id {
    color: #fff;
    font-weight: bold;
}

.history-entry-time {
    color: #546e7a;
    font-size: 10px;
}

.history-entry-ort {
    color: #b0bec5;
    margin-bottom: 2px;
}

.history-entry-desc {
    color: #607d8b;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-entry-status {
    margin-top: 4px;
    font-size: 10px;
    font-weight: bold;
}

.history-entry-status.status-alarm   { color: var(--alarm-red); }
.history-entry-status.status-acked   { color: var(--idle-green); }
.history-entry-status.status-ignored { color: #546e7a; }

/* ============================================================
   Verbindungsleiste (unten)
   ============================================================ */
.connection-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(13, 17, 23, 0.95);
    border-top: 1px solid #1c2833;
    padding: 8px 20px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: #546e7a;
    text-align: center;
    z-index: 100;
    transition: color 0.3s, background 0.3s;
}

.connection-bar.alarm {
    background: rgba(183, 28, 28, 0.2);
    color: var(--alarm-red);
    border-top-color: var(--alarm-red);
}

.connection-bar.acked {
    background: rgba(27, 94, 32, 0.2);
    color: var(--ack-text);
    border-top-color: var(--ack-green);
}

/* ============================================================
   Utility
   ============================================================ */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 680px) {
    .melder-page {
        flex-direction: column;
        align-items: center;
    }
    .alarm-history-panel {
        width: 320px;
        max-height: 300px;
    }
}
