/**
 * ═══════════════════════════════════════════════════════════════
 *  WebRTC Phone — UI Styles
 *  Status widget, call controls, DTMF pad, settings page
 * ═══════════════════════════════════════════════════════════════
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  /* Background worker — mostly invisible */
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

/* ── Status Widget (bottom-right pill) ──────────────────────── */

.status-widget {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  z-index: 99999;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  user-select: none;
}

.status-disconnected { background: #78909c; }
.status-registering  { background: #ffa726; }
.status-registered   { background: #66bb6a; }
.status-error        { background: #ef5350; }
.status-incall       { background: #42a5f5; animation: pulse 1.5s infinite; }
.status-ringing      { background: #ab47bc; animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ── Call Controls ──────────────────────────────────────────── */

.call-controls {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.call-controls.hidden { display: none; }

.ctrl-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: #fff;
  line-height: 1;
}

.ctrl-btn:hover  { background: rgba(255,255,255,0.4); }
.answer-btn      { background: rgba(76, 175, 80, 0.6); }
.answer-btn:hover{ background: rgba(76, 175, 80, 0.85); }
.hangup-btn      { background: rgba(244, 67, 54, 0.6); }
.hangup-btn:hover{ background: rgba(244, 67, 54, 0.85); }

/* ── DTMF Dialpad ──────────────────────────────────────────── */

.dtmf-pad {
  position: fixed;
  bottom: 60px;
  right: 16px;
  width: 180px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  padding: 12px;
  z-index: 99998;
  user-select: none;
}

.dtmf-pad.hidden { display: none; }

.dtmf-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.dtmf-row:last-child { margin-bottom: 0; }

.dtmf-btn {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #f0f2f5;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.dtmf-btn:hover  { background: #e0e4ea; }
.dtmf-btn:active { background: #1a73e8; color: #fff; }

.dtmf-btn small {
  font-size: 7px;
  font-weight: 400;
  letter-spacing: 1px;
  opacity: 0.5;
  margin-top: 1px;
}

/* ── Microphone Warning Banner ─────────────────────────────── */

.mic-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  background: #fff3e0;
  border-bottom: 2px solid #ff9800;
  color: #e65100;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  z-index: 100001;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* ── Caller Info Bar ─────────────────────────────────────────── */

.caller-info {
  position: fixed;
  bottom: 56px;
  right: 16px;
  padding: 8px 14px;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 10px;
  color: #1565c0;
  font-size: 12px;
  font-weight: 500;
  z-index: 99997;
  max-width: 280px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Autoplay Overlay ──────────────────────────────────────── */

.autoplay-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
}

.autoplay-overlay.hidden { display: none; }

.autoplay-btn {
  padding: 16px 32px;
  font-size: 18px;
  border: none;
  border-radius: 12px;
  background: #1a73e8;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.autoplay-btn:hover { transform: scale(1.05); }

/* ══════════════════════════════════════════════════════════════
   Settings Page Styles
   ══════════════════════════════════════════════════════════════ */

.settings-container {
  max-width: 800px;
  margin: 20px auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.settings-container h1 {
  font-size: 24px;
  color: #1a73e8;
  margin-bottom: 20px;
}

.settings-container h2 {
  font-size: 18px;
  color: #333;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8eaed;
}

.info-box {
  background: #e3f2fd;
  border-left: 4px solid #1a73e8;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  color: #1565c0;
  margin-bottom: 20px;
  line-height: 1.5;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.form-row .field {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.form-row input, .form-row select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-row input:focus, .form-row select:focus {
  border-color: #1a73e8;
}

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover   { opacity: 0.85; }
.btn-primary { background: #1a73e8; color: #fff; }
.btn-danger  { background: #ef5350; color: #fff; }
.btn-sm      { padding: 4px 12px; font-size: 12px; }

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.mapping-table th, .mapping-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}

.mapping-table th {
  background: #f5f7fa;
  font-weight: 600;
  color: #555;
}

.mapping-table tr:hover { background: #fafbfc; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.ok    { background: #e8f5e9; color: #2e7d32; }
.status-badge.error { background: #fce4ec; color: #c62828; }
