/* ============================================================
   WebRTC SIP Phone — стили
   ============================================================ */

:root {
  --bg: #0f1226;
  --bg-2: #171a35;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf6;
  --text-dim: #9aa0c7;
  --accent: #6c5ce7;
  --accent-2: #00d2ff;
  --green: #2ecc71;
  --red: #ff4757;
  --amber: #ffa502;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(108, 92, 231, 0.25), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(0, 210, 255, 0.18), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

/* ---------- Топбар ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.logo { font-size: 22px; }
.brand-name {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: .3px;
}
.status {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-dim);
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.25);
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(255,71,87,0.6);
}
.status.connected .dot { background: var(--green); animation: pulse 2s infinite; }
.status.connecting .dot { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(46,204,113,.5); }
  70% { box-shadow: 0 0 0 8px rgba(46,204,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

/* ---------- Сетка ---------- */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  margin-top: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

/* ---------- Аккаунт ---------- */
.account {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 14px;
}
.account-uri {
  font-size: 13px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Поле ввода ---------- */
.input-group { margin-bottom: 14px; }
.target-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 1px;
  color: var(--text);
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.target-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.25);
}
.target-input::placeholder { color: var(--text-dim); }

/* ---------- Дайлпад ---------- */
.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.key {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 58px;
  font-size: 22px; font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .08s, background .2s;
  user-select: none;
}
.key small { font-size: 9px; color: var(--text-dim); letter-spacing: 1.5px; }
.key:hover { background: rgba(255,255,255,0.1); }
.key:active { transform: scale(0.94); background: rgba(108,92,231,0.35); }

/* ---------- Кнопки звонка ---------- */
.call-actions {
  display: flex; align-items: center; gap: 12px;
}
.switch {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-dim); user-select: none;
}
.switch input { display: none; }
.slider {
  position: relative; width: 40px; height: 22px;
  background: rgba(255,255,255,0.15); border-radius: 999px; transition: .2s;
}
.slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.btn {
  border: none; cursor: pointer; font-weight: 600; font-size: 15px;
  border-radius: 12px; padding: 12px 18px; color: #fff;
  transition: transform .08s, opacity .2s, background .2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-ghost {
  background: rgba(255,255,255,0.08); color: var(--text);
  border: 1px solid var(--panel-border);
}
.btn-call {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--green), #27ae60);
}
.btn-call .ic { font-size: 17px; }

/* ---------- Видео ---------- */
.call-panel { display: flex; flex-direction: column; }
.video-stage {
  position: relative;
  flex: 1;
  min-height: 360px;
  border-radius: 14px;
  overflow: hidden;
  background: #05060f;
  border: 1px solid var(--panel-border);
}
.remote-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  background: #05060f;
}
.local-video {
  position: absolute; right: 14px; bottom: 14px;
  width: 150px; height: 100px; object-fit: cover;
  border-radius: 10px; border: 2px solid rgba(255,255,255,0.25);
  background: #11142b; box-shadow: var(--shadow);
  z-index: 3;
}
.call-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background: radial-gradient(600px 400px at 50% 40%, rgba(108,92,231,0.15), transparent 70%);
  transition: opacity .3s;
}
.video-stage.has-remote .call-overlay { opacity: 0; pointer-events: none; }
.avatar {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}
.avatar.big { width: 110px; height: 110px; font-size: 54px; }
.peer-name { font-size: 19px; font-weight: 600; }
.call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 15px; color: var(--text-dim);
  padding: 4px 12px; border-radius: 999px; background: rgba(0,0,0,0.35);
}

/* ---------- Управление в звонке ---------- */
.in-call-controls {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 16px;
}
.ctrl {
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 22px; cursor: pointer; color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--panel-border);
  transition: transform .08s, background .2s, opacity .2s;
}
.ctrl:hover { background: rgba(255,255,255,0.16); }
.ctrl:active { transform: scale(0.92); }
.ctrl.active { background: var(--accent); border-color: transparent; }
.ctrl.muted { background: var(--amber); border-color: transparent; }
.ctrl-hangup { background: linear-gradient(135deg, var(--red), #c0392b); border-color: transparent; }
.ctrl:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Журнал ---------- */
.log-panel {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.log-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 13px; color: var(--text-dim);
  border-bottom: 1px solid var(--panel-border);
}
.log {
  max-height: 180px; overflow-y: auto;
  padding: 10px 16px; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px;
}
.log-line { padding: 3px 0; color: var(--text-dim); border-bottom: 1px dashed rgba(255,255,255,0.04); }
.log-line .t { color: #5b6090; margin-right: 8px; }
.log-line.info .m { color: var(--accent-2); }
.log-line.ok .m { color: var(--green); }
.log-line.warn .m { color: var(--amber); }
.log-line.err .m { color: var(--red); }

/* ---------- Входящий звонок ---------- */
.incoming-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,15,0.7); backdrop-filter: blur(6px);
}
.incoming-modal.hidden { display: none; }
.incoming-card {
  width: 340px; padding: 30px 26px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.incoming-pulse {
  display: flex; justify-content: center; margin-bottom: 16px;
}
.incoming-pulse .avatar { animation: ring 1.4s infinite; }
@keyframes ring {
  0%,100% { box-shadow: 0 0 0 0 rgba(108,92,231,0.5); }
  50% { box-shadow: 0 0 0 16px rgba(108,92,231,0); }
}
.incoming-from { font-size: 20px; font-weight: 700; }
.incoming-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; word-break: break-all; }
.incoming-actions { display: flex; gap: 12px; margin-top: 24px; }
.incoming-actions .btn { flex: 1; }
.btn-answer { background: linear-gradient(135deg, var(--green), #27ae60); }
.btn-decline { background: linear-gradient(135deg, var(--red), #c0392b); }

/* ---------- Адаптив ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .video-stage { min-height: 280px; }
}
