/* ══════════════════════════════════════════
   Notruf-Übungs-App – Styles
   ══════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --red: #e53935;
  --green: #43a047;
  --yellow: #f9a825;
  --blue: #1565c0;
  --bg-dark: #1a1a2e;
  --bg-phone: #16213e;
  --bg-screen: #0f3460;
  --text-primary: #ffffff;
  --text-secondary: #a0b4c8;
  --key-active: #e53935;
  --key-disabled: #2d3748;
  --key-text-active: #ffffff;
  --key-text-disabled: #4a5568;
  --border-radius: 16px;
  --phone-max-width: 400px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

/* ══════ SCREENS ══════ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ══════ STARTSEITE ══════ */
.start-container {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 440px;
  width: 100%;
}

.app-logo {
  font-size: 5rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 20px rgba(229, 57, 53, 0.5));
}

.app-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.3rem;
}

.app-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2.5rem;
}

.role-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
}

.role-btn:active {
  transform: scale(0.97);
}

.kind-btn {
  background: linear-gradient(135deg, #e53935, #b71c1c);
  color: #fff;
  box-shadow: 0 4px 20px rgba(229, 57, 53, 0.4);
}

.leitstelle-btn {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  box-shadow: 0 4px 20px rgba(21, 101, 192, 0.4);
}

.role-icon { font-size: 2.5rem; }
.role-label { font-size: 1.2rem; font-weight: 700; }
.role-desc { font-size: 0.85rem; opacity: 0.8; }

/* ══════ SETUP SCREENS ══════ */
.setup-container {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
}

.back-btn {
  display: block;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 1.5rem;
  text-align: left;
  padding: 0.25rem 0;
}

.back-btn:hover { color: #fff; }

.back-btn-small {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.back-btn-small:hover { color: #fff; }

.setup-icon { font-size: 4rem; margin-bottom: 1rem; }

.setup-container h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.setup-hint {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.setup-hint.small { font-size: 0.85rem; margin-top: 0.5rem; }

.code-input-wrapper {
  margin-bottom: 0.75rem;
}

.code-input {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 0.75rem;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
}

.code-input::placeholder { color: rgba(255,255,255,0.2); letter-spacing: 0.2em; }
.code-input:focus { border-color: var(--red); }

.room-code-display {
  background: rgba(255,255,255,0.1);
  border: 3px solid var(--red);
  border-radius: 16px;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.4em;
  padding: 1rem 1.5rem;
  color: #fff;
  margin: 1rem auto;
  max-width: 280px;
  text-shadow: 0 0 20px rgba(229,57,53,0.5);
}

.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
}

.status-dot.waiting {
  background: var(--yellow);
  animation: pulse 1.5s infinite;
}

.status-dot.connected {
  background: var(--green);
  animation: none;
}

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

.error-msg {
  background: rgba(229, 57, 53, 0.2);
  border: 1px solid var(--red);
  border-radius: 8px;
  color: #ff8a80;
  padding: 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.action-btn {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  margin-top: 0.5rem;
}

.connect-btn {
  background: linear-gradient(135deg, #e53935, #b71c1c);
  color: #fff;
  box-shadow: 0 4px 15px rgba(229,57,53,0.4);
}

.action-btn.secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
}

.action-btn:active { transform: scale(0.97); }

/* ══════ TELEFON CONTAINER ══════ */
.phone-container {
  width: 100%;
  max-width: var(--phone-max-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
}

.phone-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.25rem;
}

.phone-status-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.connection-indicator {
  font-size: 0.7rem;
}

/* ══════ KIND DISPLAY ══════ */
.phone-display {
  background: var(--bg-phone);
  border-radius: var(--border-radius);
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.phone-display-number {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: #fff;
  min-height: 3.5rem;
  line-height: 1;
}

.phone-display-hint {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}

/* ══════ KEYPAD ══════ */
.phone-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.key {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  font-size: 1.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.key-active {
  background: var(--key-active);
  color: var(--key-text-active);
  box-shadow: 0 4px 15px rgba(229,57,53,0.4);
}

.key-active:active {
  transform: scale(0.9);
  background: #c62828;
}

.key-disabled {
  background: var(--key-disabled);
  color: var(--key-text-disabled);
  cursor: not-allowed;
}

.key-delete {
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  font-size: 1.4rem;
}

.key-delete:active {
  transform: scale(0.9);
  background: rgba(255,255,255,0.2);
}

/* ══════ CALL BUTTONS ══════ */
.phone-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  flex: 1;
  justify-content: flex-end;
  padding-bottom: 1.5rem;
}

.call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1.1rem;
  border: none;
  border-radius: 100px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.call-btn:active { transform: scale(0.96); }

.call-btn-green {
  background: linear-gradient(135deg, #43a047, #2e7d32);
  color: #fff;
  box-shadow: 0 4px 20px rgba(67,160,71,0.5);
  animation: glow-green 1.5s infinite alternate;
}

.call-btn-red {
  background: linear-gradient(135deg, #e53935, #b71c1c);
  color: #fff;
  box-shadow: 0 4px 20px rgba(229,57,53,0.4);
}

.call-btn-yellow {
  background: linear-gradient(135deg, #f9a825, #e65100);
  color: #fff;
}

@keyframes glow-green {
  from { box-shadow: 0 4px 20px rgba(67,160,71,0.4); }
  to   { box-shadow: 0 4px 35px rgba(67,160,71,0.8); }
}

.call-icon { font-size: 1.4rem; }

.calling-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.calling-anim {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ══════ LEITSTELLE DISPLAY ══════ */
.leitstelle-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 2rem 1rem;
}

.leitstelle-icon { font-size: 5rem; margin-bottom: 0.75rem; }
.leitstelle-label { font-size: 1.5rem; font-weight: 800; }
.leitstelle-sublabel {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* Eingehender Anruf Animation */
.incoming-call-anim {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring-circle {
  position: absolute;
  border: 3px solid rgba(67,160,71,0.6);
  border-radius: 50%;
  width: 120px;
  height: 120px;
  animation: ring-out 1.5s ease-out infinite;
}

.ring-circle.delay-1 { animation-delay: 0.5s; }
.ring-circle.delay-2 { animation-delay: 1s; }

@keyframes ring-out {
  0%   { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

.room-code-small {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding-bottom: 0.5rem;
}

.room-code-small span {
  font-weight: 700;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.5);
}

/* ══════ MODALS ══════ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-box {
  background: #1e2d40;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.modal-box h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.modal-box p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 1.25rem; }

/* ══════ UTIL ══════ */
.hidden { display: none !important; }

/* ══════ RESPONSIV ══════ */
@media (max-height: 650px) {
  .phone-display { padding: 1rem; }
  .phone-display-number { font-size: 2.2rem; }
  .key { font-size: 1.4rem; }
  .leitstelle-icon { font-size: 3.5rem; }
}

@media (min-width: 500px) {
  .phone-container {
    margin: auto;
    min-height: auto;
    max-height: 90vh;
    border-radius: 30px;
    background: var(--bg-phone);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
  }
  .screen { background: linear-gradient(135deg, #0a0a1a, #0d1b2a); }
}
