/* Okbutton 0.2.0 */
/* OkbuttonUI: стили звонилки. Цвета и размеры настраиваются переменными --okb-* на .okbutton-ui или :root. */
.okbutton-ui {
  --okb-accent: #2a8f3c;
  --okb-accent-fg: #fff;
  --okb-danger: #c23a2b;
  --okb-warn: #d98a00;
  --okb-bg: #fff;
  --okb-fg: #1d2733;
  --okb-muted: #6b7785;
  --okb-border: #d5dbe3;
  --okb-key-bg: #f2f5f8;
  --okb-radius: 12px;
  --okb-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --okb-z: 2147483000;
  font-family: var(--okb-font);
  font-size: 15px;
  line-height: 1.35;
  color: var(--okb-fg);
  box-sizing: border-box;
}
.okbutton-ui *, .okbutton-ui *::before, .okbutton-ui *::after { box-sizing: inherit; }
.okbutton-ui [hidden] { display: none !important; }
.okbutton-ui button { font: inherit; cursor: pointer; }
.okbutton-ui button:focus-visible, .okbutton-ui input:focus-visible { outline: 3px solid rgba(42, 143, 60, .45); outline-offset: 2px; }

/* плавающий режим */
.okbutton-ui.okb-floating { position: fixed; z-index: var(--okb-z); display: flex; flex-direction: column; gap: 10px; }
.okb-pos-bottom-right { right: 20px; bottom: 20px; align-items: flex-end; }
.okb-pos-bottom-left { left: 20px; bottom: 20px; align-items: flex-start; }
.okb-pos-top-right { right: 20px; top: 20px; align-items: flex-end; flex-direction: column-reverse; }
.okb-pos-top-left { left: 20px; top: 20px; align-items: flex-start; flex-direction: column-reverse; }
.okb-floating .okb-fab {
  width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--okb-accent); color: var(--okb-accent-fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3); order: 2;
}
.okb-floating .okb-fab[data-state="talking"] { background: var(--okb-danger); animation: okb-pulse 1.6s infinite; }
.okb-floating .okb-fab[data-state="incoming"] { background: var(--okb-warn); animation: okb-shake .8s infinite; }
.okb-floating .okb-fab[data-state="connecting"], .okb-floating .okb-fab[data-state="ringing"] { background: var(--okb-warn); }
.okb-floating .okb-panel { order: 1; box-shadow: 0 8px 30px rgba(0, 0, 0, .28); }

.okb-panel {
  width: 300px; max-width: calc(100vw - 24px); padding: 14px;
  background: var(--okb-bg); color: var(--okb-fg);
  border: 1px solid var(--okb-border); border-radius: var(--okb-radius);
}
.okb-page .okb-panel { width: 100%; max-width: none; border: 0; border-radius: 0; min-height: 100%; }
.okb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.okb-title { flex: 1; font-weight: 600; }
.okb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--okb-muted); }
[data-state="idle"] .okb-dot { background: var(--okb-accent); }
[data-state="talking"] .okb-dot { background: var(--okb-danger); }
[data-state="connecting"] .okb-dot, [data-state="ringing"] .okb-dot, [data-state="incoming"] .okb-dot { background: var(--okb-warn); }
.okb-close { border: 0; background: transparent; color: var(--okb-muted); font-size: 22px; line-height: 1; padding: 0 4px; }
.okb-status { min-height: 1.35em; color: var(--okb-muted); margin-bottom: 8px; }
.okb-error { background: #fdecea; color: #7a1f14; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.okb-incoming { background: var(--okb-key-bg); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.okb-in-name { font-weight: 600; margin-bottom: 8px; word-break: break-all; }
.okb-number {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 18px; letter-spacing: .5px;
  border: 1px solid var(--okb-border); border-radius: 8px; background: var(--okb-bg); color: var(--okb-fg);
}
.okb-number[readonly] { background: var(--okb-key-bg); }
.okb-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.okb-key { border: 0; border-radius: 8px; padding: 10px 0; font-size: 18px; background: var(--okb-key-bg); color: var(--okb-fg); }
.okb-key:active { filter: brightness(.92); }
.okb-row { display: flex; gap: 8px; }
.okb-actions { margin-top: 4px; }
.okb-extra { margin-top: 8px; }
.okb-btn {
  flex: 1; border: 0; border-radius: 8px; padding: 11px 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--okb-key-bg); color: var(--okb-fg);
}
.okb-btn:disabled { opacity: .5; cursor: default; }
.okb-call, .okb-answer { background: var(--okb-accent); color: var(--okb-accent-fg); }
.okb-hangup, .okb-reject { background: var(--okb-danger); color: #fff; }
.okb-mute[aria-pressed="true"], .okb-hold[aria-pressed="true"] { background: var(--okb-warn); color: #fff; }
.okb-timer { text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 10px; }
.okb-quality { text-align: center; font-size: 13px; margin-top: 4px; color: var(--okb-accent); }
.okb-quality[data-level="ok"] { color: var(--okb-warn); }
.okb-quality[data-level="bad"] { color: var(--okb-danger); }

/* встроенная кнопка */
.okbutton-ui.okb-inline { display: inline-flex; align-items: center; gap: 8px; }
.okb-inline-btn { flex: none; background: var(--okb-accent); color: var(--okb-accent-fg); }
.okb-inline-btn[data-busy="1"] { background: var(--okb-danger); }
.okb-inline-status { color: var(--okb-muted); font-size: 14px; }

/* ссылки, созданные автопоиском телефонов */
a.okbutton-phone { color: inherit; text-decoration: underline dotted; cursor: pointer; white-space: nowrap; }
a.okbutton-phone:hover { text-decoration: underline; }

@keyframes okb-pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 58, 43, .55); } 70% { box-shadow: 0 0 0 14px rgba(194, 58, 43, 0); } 100% { box-shadow: 0 0 0 0 rgba(194, 58, 43, 0); } }
@keyframes okb-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .okbutton-ui .okb-fab { animation: none !important; } }
@media (max-width: 480px) {
  .okbutton-ui.okb-floating { left: 10px !important; right: 10px !important; bottom: 10px !important; align-items: flex-end; }
  .okb-floating .okb-panel { width: 100%; }
}
