/* ═══════════════════════════════════════════════════════════════════
   Operation Guide — Web Phone UI
   Design: Clean enterprise SIP phone, inspired by modern softphones
   (Zoiper, 3CX, Teams calling) — calm neutrals, clear hierarchy.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
    /* Brand */
    --ph-accent:        #2563eb;      /* blue-600  */
    --ph-accent-hover:  #1d4ed8;      /* blue-700  */
    --ph-accent-light:  #eff6ff;      /* blue-50   */
    --ph-green:         #16a34a;      /* green-600 */
    --ph-green-bg:      #dcfce7;
    --ph-red:           #dc2626;      /* red-600   */
    --ph-red-bg:        #fee2e2;
    --ph-amber:         #d97706;
    --ph-amber-bg:      #fef3c7;

    /* Neutrals */
    --ph-bg:            #f8fafc;      /* slate-50  */
    --ph-surface:       #ffffff;
    --ph-surface-2:     #f1f5f9;      /* slate-100 */
    --ph-border:        #e2e8f0;      /* slate-200 */
    --ph-border-strong: #cbd5e1;      /* slate-300 */
    --ph-text:          #0f172a;      /* slate-900 */
    --ph-text-2:        #475569;      /* slate-600 */
    --ph-text-3:        #94a3b8;      /* slate-400 */

    /* Widget chrome */
    --ph-header-bg:     #1e293b;      /* slate-800 */
    --ph-header-text:   #f8fafc;
    --ph-screen-bg:     #0f172a;      /* slate-900 */

    /* Spacing */
    --ph-r-sm:  6px;
    --ph-r:     10px;
    --ph-r-lg:  14px;
    --ph-r-xl:  18px;

    /* Shadows */
    --ph-shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --ph-shadow:     0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
    --ph-shadow-lg:  0 16px 40px rgba(0,0,0,.14), 0 6px 16px rgba(0,0,0,.08);
    --ph-shadow-xl:  0 24px 64px rgba(0,0,0,.18);

    /* Motion */
    --ph-ease: cubic-bezier(.4,0,.2,1);
    --ph-dur:  160ms;
    --ph-dur-slow: 240ms;

    /* Z-index layers */
    --z-phone-widget:  1080;
    --z-phone-overlay: 1090;
}

/* ── Dark-theme override (data-phone-theme="dark") ─────────────── */
[data-phone-theme="dark"] {
    --ph-bg:            #0f172a;
    --ph-surface:       #1e293b;
    --ph-surface-2:     #334155;
    --ph-border:        #334155;
    --ph-border-strong: #475569;
    --ph-text:          #f1f5f9;
    --ph-text-2:        #94a3b8;
    --ph-text-3:        #64748b;
    --ph-header-bg:     #0f172a;
    --ph-screen-bg:     #020617;
    --ph-accent-light:  rgba(37,99,235,.15);
}

/* ── Utility ────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   FLOATING BUTTON
   ═══════════════════════════════════════════════════════════════════ */
.webphone-floating-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    background: var(--ph-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: background var(--ph-dur) var(--ph-ease),
                transform var(--ph-dur) var(--ph-ease),
                box-shadow var(--ph-dur) var(--ph-ease);
    box-shadow: 0 4px 16px rgba(37,99,235,.45);
    z-index: var(--z-phone-widget);
    outline: none;
}

.webphone-floating-btn:hover {
    background: var(--ph-accent-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(37,99,235,.55);
}

.webphone-floating-btn:active { transform: translateY(-1px); }

.webphone-floating-btn:focus-visible {
    outline: 3px solid var(--ph-accent);
    outline-offset: 3px;
}

/* Missed-call badge */
.webphone-floating-btn .phone-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 18px; height: 18px;
    background: var(--ph-red);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   WIDGET SHELL
   ═══════════════════════════════════════════════════════════════════ */
.webphone-widget {
    position: fixed;
    top: 56px;          /* adjusted by JS below navbar */
    right: 20px;
    bottom: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: var(--ph-surface);
    border-radius: var(--ph-r-xl);
    border: 1px solid var(--ph-border);
    box-shadow: var(--ph-shadow-xl);
    z-index: var(--z-phone-widget);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ph-slide-in var(--ph-dur-slow) var(--ph-ease);
}

@keyframes ph-slide-in {
    from { opacity: 0; transform: translateX(24px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ── Widget Header ──────────────────────────────────────────────── */
.webphone-widget-header {
    background: var(--ph-header-bg);
    padding: .65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-shrink: 0;
    border-radius: var(--ph-r-xl) var(--ph-r-xl) 0 0;
}

.webphone-widget-header .fw-bold {
    color: var(--ph-header-text);
    font-size: .875rem;
    letter-spacing: .01em;
}

/* header icon buttons */
.widget-header-btn {
    width: 30px; height: 30px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--ph-r-sm);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.8);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem;
    cursor: pointer;
    transition: background var(--ph-dur) var(--ph-ease),
                color var(--ph-dur) var(--ph-ease),
                transform var(--ph-dur) var(--ph-ease);
    outline: none;
}

.widget-header-btn:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
    transform: translateY(-1px);
}

.widget-header-btn:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
}

.widget-close-btn:hover {
    background: rgba(220,38,38,.6);
    border-color: rgba(220,38,38,.8);
    color: #fff;
}

/* ── Status Screen ──────────────────────────────────────────────── */
.webphone-screen {
    background: var(--ph-screen-bg);
    padding: .75rem 1rem .85rem;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.avatar-circle {
    width: 36px; height: 36px;
    background: rgba(37,99,235,.25);
    border: 1.5px solid rgba(37,99,235,.4);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #93c5fd;
    font-size: .95rem;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online  { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.7); }
.status-dot.offline { background: #f87171; }
.status-dot.away    { background: #fbbf24; }
.status-dot.busy    { background: #f97316; }

.webphone-screen .text-white {
    color: #e2e8f0 !important;
    font-size: .875rem;
    font-weight: 500;
}

/*
 * Presence dropdown (widget status strip — sits on dark --ph-screen-bg).
 * Light field + dark label text reads clearly as a control; border matches standalone.
 */
#phone-presence-select {
    appearance: none;
    background-color: #f8fafc;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23334155' d='M4.646 6.646a.5.5 0 0 1 .708 0L8 9.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.2rem center;
    background-size: 0.7rem auto;
    color: #0f172a;
    font-weight: 500;
    border: 1px solid rgba(100, 116, 139, 0.55);
    border-radius: var(--ph-r-sm);
    font-size: .72rem;
    padding: 2px 1.35rem 2px 6px;
    cursor: pointer;
    outline: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
}

#phone-presence-select:focus {
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
}

#phone-presence-select option {
    background: #fff;
    color: #0f172a;
    font-weight: 500;
}

/* Agent status / feature codes (dialer toolbar) — same purple tint as outbound "Via" */
.phone-agent-codes-select {
    appearance: none;
    -webkit-appearance: none;
    font-size: 0.625rem;
    line-height: 1.2;
    font-weight: 500;
    color: #3730a3;
    background-color: color-mix(in srgb, #faf5ff 87%, #667eea 13%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%235b21b6' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.3rem center;
    background-size: 8px 8px;
    border: 1px solid color-mix(in srgb, #e9d5ff 46%, #667eea 54%);
    border-radius: 5px;
    padding: 2px 1.15rem 2px 5px;
    cursor: pointer;
    outline: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.phone-agent-codes-select:focus {
    color: #312e81;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.26);
}

.phone-agent-codes-select option {
    font-size: 0.625rem;
    font-weight: 500;
    color: #1e1b4b;
    background: #faf5ff;
}

[data-phone-theme="dark"] .phone-agent-codes-select {
    background-color: color-mix(in srgb, #1e1b4b 80%, #5b21b6 20%);
    color: #e9d5ff;
    border-color: color-mix(in srgb, #4c1d95 45%, #a78bfa 55%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23c4b5fd' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

[data-phone-theme="dark"] .phone-agent-codes-select:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.3);
}

[data-phone-theme="dark"] .phone-agent-codes-select option {
    background: #312e81;
    color: #e9d5ff;
}

.webphone-display {
    margin-top: .6rem;
}

.display-number {
    font-size: 1.6rem;
    font-weight: 300;
    color: #f1f5f9;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Courier New', monospace;
    min-height: 2rem;
    line-height: 1.1;
}

.display-status {
    font-size: .8rem;
    color: #94a3b8;
    margin-top: 3px;
}

.call-timer {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4ade80;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, monospace;
    letter-spacing: .04em;
    margin-top: 4px;
}

.call-quality-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: .75rem;
    color: #94a3b8;
    margin-top: 6px;
}

.quality-bars {
    display: flex; align-items: flex-end; gap: 2px; height: 14px;
}

.quality-bars .bar {
    width: 3px; background: #334155; border-radius: 2px;
    transition: background .3s var(--ph-ease);
}

.quality-bars .bar:nth-child(1) { height: 4px; }
.quality-bars .bar:nth-child(2) { height: 6px; }
.quality-bars .bar:nth-child(3) { height: 9px; }
.quality-bars .bar:nth-child(4) { height: 11px; }
.quality-bars .bar:nth-child(5) { height: 14px; }

.quality-excellent .bar          { background: #4ade80; }
.quality-good .bar:nth-child(-n+4) { background: #a3e635; }
.quality-fair .bar:nth-child(-n+3) { background: #fbbf24; }
.quality-poor .bar:nth-child(-n+2) { background: #f87171; }

/* speaker button in screen row */
.speaker-btn {
    width: 32px; height: 32px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--ph-r-sm);
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.6);
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
    cursor: pointer;
    transition: background var(--ph-dur) var(--ph-ease),
                color var(--ph-dur) var(--ph-ease);
    outline: none;
    flex-shrink: 0;
}

.speaker-btn:hover:not(:disabled) {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.speaker-btn.active {
    background: rgba(74,222,128,.2);
    border-color: rgba(74,222,128,.4);
    color: #4ade80;
}

.speaker-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Widget Body ────────────────────────────────────────────────── */
.webphone-widget-body {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: .85rem;
    background: var(--ph-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--ph-border) transparent;
}

/* Stub when SIP runs in another tab / dedicated window */
.webphone-widget-stub-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.94);
    color: #f8fafc;
    border-radius: 0 0 var(--ph-r-xl) var(--ph-r-xl);
}
.webphone-widget-stub-overlay.hidden {
    display: none !important;
}
.webphone-stub-hint {
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
    max-width: 280px;
    color: rgba(248, 250, 252, 0.92);
}
.webphone-proxy-controls {
    width: 100%;
    max-width: 300px;
}
.webphone-proxy-screen {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    text-align: left;
}
.webphone-proxy-label {
    font-size: 0.68rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(203, 213, 225, 0.78);
    margin-bottom: 0.35rem;
}
.webphone-proxy-number {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
}
.webphone-proxy-status,
.webphone-proxy-duration {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: rgba(226, 232, 240, 0.9);
}
.webphone-proxy-duration {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-weight: 700;
}
[data-phone-theme="dark"] .webphone-widget-stub-overlay {
    background: rgba(2, 6, 23, 0.96);
}
/* ── Proxy controller redesign ───────────────────────────────────── */
.webphone-proxy-screen {
    background: rgba(15, 23, 42, 0.72);
    border: 0.5px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    padding: 9px 12px 10px;
    text-align: left;
    width: 100%;
  }
  
  .webphone-proxy-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 700;
    color: rgba(148, 163, 184, 0.7);
    margin-bottom: 4px;
  }
  
  .webphone-proxy-number {
    font-size: 16px;
    font-weight: 300;
    color: #f1f5f9;
    font-family: ui-monospace, 'Courier New', monospace;
    letter-spacing: .06em;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .webphone-proxy-status {
    font-size: 10.5px;
    color: rgba(148, 163, 184, 0.85);
  }
  
  .webphone-proxy-duration {
    font-size: 10px;
    font-weight: 700;
    font-family: ui-monospace, 'Courier New', monospace;
    color: #4ade80;
    background: rgba(74, 222, 128, .12);
    border: 1px solid rgba(74, 222, 128, .22);
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.4;
  }
  
  /* number input row */
  .webphone-proxy-controls .input-group {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  
  .webphone-proxy-controls .input-group .form-control {
    flex: 1;
    background: rgba(15, 23, 42, 0.55);
    border: 0.5px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    color: #f1f5f9;
    font-size: 13px;
    font-family: ui-monospace, 'Courier New', monospace;
    letter-spacing: .03em;
    padding: 7px 10px;
    height: auto;
    outline: none;
    transition: border-color .12s, box-shadow .12s;
  }
  
  .webphone-proxy-controls .input-group .form-control::placeholder {
    color: rgba(148, 163, 184, 0.5);
    font-family: var(--bs-font-sans-serif, sans-serif);
    letter-spacing: normal;
    font-size: 12px;
  }
  
  .webphone-proxy-controls .input-group .form-control:focus {
    border-color: rgba(37, 99, 235, 0.6);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
    background: rgba(15, 23, 42, 0.8);
  }
  
  .webphone-proxy-controls .input-group .btn-success {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    background: #16a34a;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background .12s;
  }
  
  .webphone-proxy-controls .input-group .btn-success:hover { background: #15803d; }
  
  /* proxy action buttons */
  .proxy-action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 100%;
  }
  
  .proxy-action-grid--2col {
    grid-template-columns: 1fr 1fr;
  }
  
  .proxy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 6px;
    border: 0.5px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(226, 232, 240, 0.85);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap;
    width: 100%;
  }
  
  .proxy-btn i { font-size: 13px; }
  
  .proxy-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.4);
    color: #fff;
  }
  
  .proxy-btn:disabled {
    opacity: .32;
    cursor: not-allowed;
  }
  
  .proxy-btn.active {
    background: rgba(37, 99, 235, 0.22);
    border-color: rgba(37, 99, 235, 0.5);
    color: #93c5fd;
  }
  
  .proxy-btn--answer {
    background: rgba(22, 163, 74, 0.18);
    border-color: rgba(22, 163, 74, 0.4);
    color: #4ade80;
  }
  
  .proxy-btn--answer:hover:not(:disabled) {
    background: rgba(22, 163, 74, 0.28);
    border-color: rgba(22, 163, 74, 0.6);
  }
  
  .proxy-btn--hangup {
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.35);
    color: #f87171;
    width: 100%;
  }
  
  .proxy-btn--hangup:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.25);
    border-color: rgba(220, 38, 38, 0.55);
  }
  
  /* open window button */
  .proxy-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(37, 99, 235, 0.18);
    border: 0.5px solid rgba(37, 99, 235, 0.4);
    border-radius: 8px;
    color: #93c5fd;
    font-size: 11.5px;
    font-weight: 600;
    padding: 7px 14px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    margin-top: 2px;
  }
  
  .proxy-open-btn:hover {
    background: rgba(37, 99, 235, 0.28);
    border-color: rgba(37, 99, 235, 0.6);
    color: #bfdbfe;
  }
  
  .proxy-open-btn i { font-size: 12px; }
/* Popup / standalone routes hide the turbo-permanent widget via body.phone-bg (see below).
   Do NOT hide #webphone-widget with body.webphone-stub-popup alone — that class is set on the host app
   (e.g. dashboard) so the stub shell knows popup mode; hiding here made openWidget() ineffective (!important). */

/* Embedded follower: only the stub card — hide duplicate chrome */
.webphone-widget.webphone-widget--stub-mode .webphone-widget-header,
.webphone-widget.webphone-widget--stub-mode .webphone-screen {
    display: none !important;
}
.webphone-widget.webphone-widget--stub-mode .webphone-widget-stub-overlay {
    position: relative;
    inset: auto;
    border-radius: 0 0 var(--ph-r-xl) var(--ph-r-xl);
    min-height: 160px;
}

[data-phone-theme="dark"] .webphone-widget-body {
    background: var(--ph-surface);
}

.webphone-widget-body::-webkit-scrollbar { width: 4px; }
.webphone-widget-body::-webkit-scrollbar-thumb {
    background: var(--ph-border);
    border-radius: 4px;
}
.webphone-widget-body::-webkit-scrollbar-track { background: transparent; }
/* ── Force proxy button styles over Bootstrap ─────────────────── */
#webphone-open-popup-btn,
#webphone-open-popup-btn:hover,
#webphone-open-popup-btn:focus {
    all: unset;
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    background: rgba(37, 99, 235, 0.18) !important;
    border: 0.5px solid rgba(37, 99, 235, 0.4) !important;
    border-radius: 8px !important;
    color: #93c5fd !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    padding: 7px 14px !important;
    cursor: pointer !important;
    transition: background .12s, border-color .12s !important;
    margin-top: 6px !important;
    box-sizing: border-box !important;
}

#webphone-open-popup-btn:hover {
    background: rgba(37, 99, 235, 0.28) !important;
    border-color: rgba(37, 99, 235, 0.6) !important;
    color: #bfdbfe !important;
}

.webphone-proxy-controls .proxy-btn {
    all: unset !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    padding: 7px 6px !important;
    border: 0.5px solid rgba(148, 163, 184, 0.22) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    color: rgba(226, 232, 240, 0.85) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    width: 100% !important;
    transition: background .12s !important;
}

.webphone-proxy-controls .proxy-btn--answer {
    background: rgba(22, 163, 74, 0.18) !important;
    border-color: rgba(22, 163, 74, 0.4) !important;
    color: #4ade80 !important;
}

.webphone-proxy-controls .proxy-btn--hangup {
    background: rgba(220, 38, 38, 0.15) !important;
    border-color: rgba(220, 38, 38, 0.35) !important;
    color: #f87171 !important;
}

.webphone-proxy-controls .proxy-btn.active {
    background: rgba(37, 99, 235, 0.22) !important;
    border-color: rgba(37, 99, 235, 0.5) !important;
    color: #93c5fd !important;
}

.webphone-proxy-controls .proxy-btn:disabled {
    opacity: .32 !important;
    cursor: not-allowed !important;
}

/* ── System-aligned controller palette ────────────────────────────
   Keep this after the Bootstrap override block so it wins. */
.webphone-widget.webphone-widget--stub-mode {
    background: linear-gradient(145deg, rgba(18, 47, 78, 0.96), rgba(14, 28, 52, 0.98)) !important;
    border-color: rgba(147, 197, 253, 0.26) !important;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.04) inset !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-widget-stub-overlay {
    background:
        radial-gradient(circle at 12% 0%, rgba(59, 130, 246, 0.18), transparent 34%),
        linear-gradient(145deg, rgba(24, 54, 88, 0.96), rgba(16, 31, 56, 0.98)) !important;
    color: #eaf2ff !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-stub-hint {
    color: rgba(219, 234, 254, 0.82) !important;
    font-weight: 500;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-screen {
    background: rgba(12, 27, 50, 0.58) !important;
    border-color: rgba(147, 197, 253, 0.20) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-label {
    color: rgba(191, 219, 254, 0.64) !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-number {
    color: #f8fbff !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-status {
    color: rgba(203, 213, 225, 0.86) !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .input-group .form-control {
    background: rgba(15, 34, 61, 0.62) !important;
    border-color: rgba(147, 197, 253, 0.20) !important;
    color: #edf6ff !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .input-group .form-control:focus {
    border-color: rgba(96, 165, 250, 0.72) !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16) !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .input-group .btn-success {
    background: #22a861 !important;
    box-shadow: 0 8px 18px rgba(34, 168, 97, 0.22);
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .input-group .btn-success:hover {
    background: #1f9858 !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .proxy-btn {
    background: rgba(219, 234, 254, 0.075) !important;
    border-color: rgba(147, 197, 253, 0.18) !important;
    color: rgba(226, 238, 255, 0.84) !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .proxy-btn:hover:not(:disabled) {
    background: rgba(96, 165, 250, 0.16) !important;
    border-color: rgba(147, 197, 253, 0.34) !important;
    color: #ffffff !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .proxy-btn--answer {
    background: rgba(34, 168, 97, 0.18) !important;
    border-color: rgba(74, 222, 128, 0.30) !important;
    color: #86efac !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-proxy-controls .proxy-btn--hangup {
    background: rgba(220, 38, 38, 0.12) !important;
    border-color: rgba(248, 113, 113, 0.24) !important;
    color: #fca5a5 !important;
}

.webphone-widget.webphone-widget--stub-mode #webphone-open-popup-btn {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.34), rgba(14, 165, 233, 0.20)) !important;
    border-color: rgba(147, 197, 253, 0.40) !important;
    color: #dbeafe !important;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.20);
}

.webphone-widget.webphone-widget--stub-mode #webphone-open-popup-btn:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.46), rgba(14, 165, 233, 0.28)) !important;
    color: #ffffff !important;
}
/* ── Stub mode: compact auto-height widget ───────────────────── */
.webphone-widget.webphone-widget--stub-mode {
    border: 0.5px solid rgba(148, 163, 184, 0.18) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
    overflow: hidden !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-widget-body {
    padding: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: unset !important;
    max-height: none !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-widget-stub-overlay {
    position: relative !important;
    inset: auto !important;
    min-height: unset !important;
    border-radius: 0 0 14px 14px !important;
    padding: 14px 12px 14px !important;
}

/* Final controller chrome: placed after compact sizing so it wins. */
.webphone-widget.webphone-widget--stub-mode {
    background: linear-gradient(145deg, rgba(18, 47, 78, 0.96), rgba(14, 28, 52, 0.98)) !important;
    border-color: rgba(147, 197, 253, 0.26) !important;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.04) inset !important;
}

.webphone-widget.webphone-widget--stub-mode .webphone-widget-stub-overlay {
    background:
        radial-gradient(circle at 12% 0%, rgba(59, 130, 246, 0.18), transparent 34%),
        linear-gradient(145deg, rgba(24, 54, 88, 0.96), rgba(16, 31, 56, 0.98)) !important;
}
/* ═══════════════════════════════════════════════════════════════════
   LOGIN FORM
   ═══════════════════════════════════════════════════════════════════ */
.login-form {
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-r-lg);
    padding: 1.25rem;
}

[data-phone-theme="dark"] .login-form {
    background: var(--ph-surface-2);
}

.login-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ph-text);
    margin-bottom: .25rem;
}

.login-header p { font-size: .8rem; color: var(--ph-text-2); margin: 0; }

/* floating label overrides inside phone UI only */
.login-form .form-floating label,
.webphone-widget .form-floating label {
    color: var(--ph-text-2);
    font-size: .875rem;
    font-weight: 500;
}

.login-form .form-control,
.webphone-widget .form-control {
    background: var(--ph-surface-2);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-r);
    color: var(--ph-text);
    font-size: .9rem;
    transition: border-color var(--ph-dur), box-shadow var(--ph-dur);
}

.login-form .form-control:focus,
.webphone-widget .form-control:focus {
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    background: var(--ph-surface);
    outline: none;
}

[data-phone-theme="dark"] .login-form .form-control,
[data-phone-theme="dark"] .webphone-widget .form-control {
    background: #0f172a;
    border-color: var(--ph-border);
    color: var(--ph-text);
}

/* ═══════════════════════════════════════════════════════════════════
   DIALER TOOLBAR — outbound “via” + status codes (≈50% / 50%)
   ═══════════════════════════════════════════════════════════════════ */
.og-dialer-toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 4px;
    margin: 0;
    min-width: 0;
    border-top: 1px solid color-mix(in srgb, var(--ph-border, #e2e8f0) 55%, transparent);
}

[data-phone-theme="dark"] .og-dialer-toolbar-row {
    border-top-color: color-mix(in srgb, #334155 50%, transparent);
}

.og-dialer-toolbar-row--no-outbound .og-agent-codes-toolbar-col {
    flex: 1 1 100%;
    max-width: 100%;
}

.og-outbound-toolbar-col {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.og-agent-codes-toolbar-col {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    align-items: center;
}

.og-agent-codes-toolbar-col .phone-agent-codes-select {
    width: 100%;
}

/* Standalone /popup dialer: classic full-width outbound strip (not .og-outbound-toolbar-col) */
body.phone-bg #phone-interface #og-outbound-company-wrap:not(.og-outbound-toolbar-col) {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 4px;
    margin: 0 0 0.5rem 0;
    min-width: 0;
    border-top: 1px solid color-mix(in srgb, var(--ph-border, #e2e8f0) 55%, transparent);
}

[data-phone-theme="dark"] body.phone-bg #phone-interface #og-outbound-company-wrap:not(.og-outbound-toolbar-col) {
    border-top-color: color-mix(in srgb, #334155 50%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════
   NUMBER INPUT
   ═══════════════════════════════════════════════════════════════════ */
.number-input {
    position: relative;
    margin-bottom: .75rem;
}

.number-input .input-group {
    position: relative;
}

/* scope form-control styles to phone UI */
.phone-interface .form-control,
.webphone-widget .phone-interface .form-control {
    background: var(--ph-surface);
    border: 1.5px solid var(--ph-border);
    border-radius: var(--ph-r-lg);
    color: var(--ph-text);
    font-size: 1.25rem;
    font-weight: 300;
    letter-spacing: .06em;
    text-align: center;
    padding: .6rem 2.5rem .6rem 1rem;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Courier New', monospace;
    transition: border-color var(--ph-dur), box-shadow var(--ph-dur);
    height: auto;
}

/* Dial field: allow select / copy / paste like a normal text field */
#phone-number {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.phone-interface .form-control:focus,
.webphone-widget .phone-interface .form-control:focus {
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    outline: none;
    background: var(--ph-surface);
}

[data-phone-theme="dark"] .phone-interface .form-control {
    background: var(--ph-screen-bg);
    border-color: var(--ph-border);
    color: #f1f5f9;
}

.backspace-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border: none;
    border-radius: var(--ph-r-sm);
    background: transparent;
    color: var(--ph-text-3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: .9rem;
    z-index: 2;
    transition: background var(--ph-dur), color var(--ph-dur);
}

.backspace-btn:hover {
    background: var(--ph-red-bg);
    color: var(--ph-red);
}

/* ═══════════════════════════════════════════════════════════════════
   DIALPAD
   ═══════════════════════════════════════════════════════════════════ */
.dialpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: .85rem;
    padding: .5rem 0;
    justify-items: center;
}

.dial-btn {
    width: 64px; height: 64px;
    border: 1.5px solid var(--ph-border);
    border-radius: 50%;
    background: var(--ph-surface);
    color: var(--ph-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--ph-dur) var(--ph-ease),
                border-color var(--ph-dur) var(--ph-ease),
                transform var(--ph-dur) var(--ph-ease),
                box-shadow var(--ph-dur) var(--ph-ease);
    box-shadow: var(--ph-shadow-sm);
    padding: 0;
    position: relative;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    gap: 1px;
}

.dial-btn:hover:not(:disabled) {
    background: var(--ph-accent-light);
    border-color: var(--ph-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37,99,235,.18);
}

.dial-btn:active {
    transform: scale(.93);
    background: var(--ph-accent);
    border-color: var(--ph-accent);
}

.dial-btn:active .dial-digit,
.dial-btn:active .dial-letters { color: #fff; }

.dial-btn:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
}

.dial-digit {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1;
    color: var(--ph-text);
}

.dial-letters {
    font-size: .55rem;
    font-weight: 500;
    letter-spacing: .08em;
    color: var(--ph-text-3);
    text-transform: uppercase;
    line-height: 1;
}

/* dark mode */
[data-phone-theme="dark"] .dial-btn {
    background: var(--ph-surface-2);
    border-color: var(--ph-border);
}

[data-phone-theme="dark"] .dial-btn:hover:not(:disabled) {
    background: rgba(37,99,235,.2);
    border-color: var(--ph-accent);
}

[data-phone-theme="dark"] .dial-digit { color: var(--ph-text); }
[data-phone-theme="dark"] .dial-letters { color: var(--ph-text-3); }

/* widget: slightly smaller pad */
.webphone-widget .dialpad { gap: 7px; padding: .35rem 0; }

.webphone-widget .dial-btn {
    width: 56px; height: 56px;
}

.webphone-widget .dial-digit { font-size: 1.1rem; }
.webphone-widget .dial-letters { font-size: .5rem; }

/* ═══════════════════════════════════════════════════════════════════
   CALL CONTROLS
   ═══════════════════════════════════════════════════════════════════ */
.phone-controls {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    align-items: center;
    padding: .25rem 0 .5rem;
}

.primary-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.secondary-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

/* Call / Hang-up */
.call-btn, .hangup-btn {
    width: 68px; height: 68px;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.35rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform var(--ph-dur) var(--ph-ease),
                box-shadow var(--ph-dur) var(--ph-ease),
                background var(--ph-dur) var(--ph-ease);
    outline: none;
    box-shadow: var(--ph-shadow);
    flex-shrink: 0;
}

.call-btn {
    background: var(--ph-green);
    box-shadow: 0 4px 16px rgba(22,163,74,.4);
}

.call-btn:hover:not(:disabled) {
    background: #15803d;
    box-shadow: 0 6px 20px rgba(22,163,74,.55);
    transform: translateY(-3px);
}

.hangup-btn {
    background: var(--ph-red);
    box-shadow: 0 4px 16px rgba(220,38,38,.4);
}

.hangup-btn:hover:not(:disabled) {
    background: #b91c1c;
    box-shadow: 0 6px 20px rgba(220,38,38,.55);
    transform: translateY(-3px);
}

.call-btn:active, .hangup-btn:active {
    transform: scale(.92);
}

.call-btn:focus-visible, .hangup-btn:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.call-btn:disabled, .hangup-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Smaller in widget */
.webphone-widget .call-btn,
.webphone-widget .hangup-btn {
    width: 58px; height: 58px;
    font-size: 1.2rem;
}

/* Secondary control buttons */
.control-btn {
    width: 44px; height: 44px;
    border: 1.5px solid var(--ph-border);
    border-radius: var(--ph-r);
    background: var(--ph-surface);
    color: var(--ph-text-2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--ph-dur) var(--ph-ease),
                border-color var(--ph-dur) var(--ph-ease),
                color var(--ph-dur) var(--ph-ease),
                transform var(--ph-dur) var(--ph-ease);
    outline: none;
    box-shadow: var(--ph-shadow-sm);
}

.control-btn:hover:not(:disabled) {
    background: var(--ph-accent-light);
    border-color: var(--ph-accent);
    color: var(--ph-accent);
    transform: translateY(-2px);
}

.control-btn.active {
    background: var(--ph-accent);
    border-color: var(--ph-accent);
    color: #fff;
}

.control-btn#conference-btn.active {
    background: var(--ph-green);
    border-color: var(--ph-green);
    color: #fff;
}

.control-btn#mute-btn.active {
    background: var(--ph-red-bg);
    border-color: var(--ph-red);
    color: var(--ph-red);
}

.control-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.control-btn:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
}

[data-phone-theme="dark"] .control-btn {
    background: var(--ph-surface-2);
    border-color: var(--ph-border);
    color: var(--ph-text-2);
}

[data-phone-theme="dark"] .control-btn:hover:not(:disabled) {
    background: rgba(37,99,235,.2);
    border-color: var(--ph-accent);
    color: #93c5fd;
}

/* Widget: smaller secondary buttons */
.webphone-widget .control-btn {
    width: 38px; height: 38px;
    font-size: .9rem;
    border-radius: var(--ph-r-sm);
}

/* ═══════════════════════════════════════════════════════════════════
   STATUS ALERT
   ═══════════════════════════════════════════════════════════════════ */
.status-alert {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .85rem;
    border-radius: var(--ph-r);
    font-size: .8rem;
    font-weight: 500;
    margin-bottom: .75rem;
    border: 1px solid transparent;
    animation: ph-slide-down var(--ph-dur) var(--ph-ease);
}

@keyframes ph-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

.status-alert.success {
    background: var(--ph-green-bg);
    border-color: #86efac;
    color: #166534;
}

.status-alert.error {
    background: var(--ph-red-bg);
    border-color: #fca5a5;
    color: #991b1b;
}

.status-alert.warning {
    background: var(--ph-amber-bg);
    border-color: #fcd34d;
    color: #92400e;
}

.status-alert.info {
    background: var(--ph-accent-light);
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ═══════════════════════════════════════════════════════════════════
   CALL HISTORY
   ═══════════════════════════════════════════════════════════════════ */
.call-history {
    margin-top: .85rem;
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-r-lg);
    overflow: hidden;
}

[data-phone-theme="dark"] .call-history {
    background: var(--ph-surface-2);
}

.history-header {
    width: 100%;
    padding: .65rem .9rem;
    border: none;
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    text-align: left;
    background: var(--ph-surface-2);
    color: var(--ph-text-2);
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: background var(--ph-dur);
    letter-spacing: .02em;
    text-transform: uppercase;
}

[data-phone-theme="dark"] .history-header {
    background: var(--ph-surface);
    color: var(--ph-text-2);
}

.history-header:hover { background: var(--ph-border); }

.history-header i:last-child { margin-left: auto; font-size: .75rem; }

/* search */
.history-search {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--ph-border);
    background: var(--ph-surface);
}

[data-phone-theme="dark"] .history-search {
    background: var(--ph-surface-2);
}

.search-input-wrapper { position: relative; display: flex; align-items: center; }

.search-icon {
    position: absolute;
    left: 8px;
    color: var(--ph-text-3);
    font-size: .75rem;
    z-index: 1;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 5px 28px 5px 26px;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-r-sm);
    background: var(--ph-surface-2);
    color: var(--ph-text);
    font-size: .78rem;
    transition: border-color var(--ph-dur), box-shadow var(--ph-dur);
}

.search-input:focus {
    outline: none;
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
    background: var(--ph-surface);
}

[data-phone-theme="dark"] .search-input {
    background: var(--ph-screen-bg);
    border-color: var(--ph-border);
    color: var(--ph-text);
}

.clear-search-btn {
    position: absolute;
    right: 5px;
    width: 18px; height: 18px;
    border: none;
    background: var(--ph-border);
    color: var(--ph-text-3);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: .65rem;
    transition: background var(--ph-dur), color var(--ph-dur);
    opacity: 0; visibility: hidden;
}

.clear-search-btn:hover { background: var(--ph-border-strong); color: var(--ph-text); }
.search-input:not(:placeholder-shown) ~ .clear-search-btn,
.search-input-wrapper:has(.search-input:not(:placeholder-shown)) .clear-search-btn {
    opacity: 1; visibility: visible;
}

.history-search-hint {
    font-size: .7rem;
    color: var(--ph-text-3);
    margin: 4px 0 0;
}

/* history items */
.history-content { max-height: 240px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ph-border) transparent; }
.history-content::-webkit-scrollbar { width: 4px; }
.history-content::-webkit-scrollbar-thumb { background: var(--ph-border); border-radius: 4px; }

.history-list { max-height: 200px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ph-border) transparent; }
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--ph-border); border-radius: 4px; }

.history-items { list-style: none; margin: 0; padding: 0; }

.history-item-wrap {
    border-bottom: 1px solid var(--ph-border);
}
.history-item-wrap:last-child { border-bottom: none; }

.history-item {
    width: 100%;
    padding: .55rem .85rem;
    border: none;
    border-radius: 0;
    font: inherit;
    font-size: .82rem;
    text-align: left;
    background: transparent;
    color: var(--ph-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background var(--ph-dur);
    min-height: 42px;
}

.history-item:hover {
    background: var(--ph-accent-light);
}

[data-phone-theme="dark"] .history-item:hover {
    background: rgba(37,99,235,.12);
}

.history-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.history-number {
    font-weight: 600;
    font-size: .83rem;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--ph-text);
}

.history-number .incoming { color: var(--ph-green); }
.history-number .outgoing { color: var(--ph-accent); }

.history-company-label {
    font-weight: 600;
    color: var(--ph-text);
}

.history-number-sep {
    opacity: 0.55;
    padding: 0 0.15rem;
}

.history-company {
    font-size: .74rem;
    color: var(--ph-muted);
    margin-top: .1rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 14rem;
}

.history-time {
    font-size: .72rem;
    color: var(--ph-text-3);
}

.history-status {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: .5rem;
}

.history-duration { font-size: .7rem; color: var(--ph-text-3); }

.call-type-badge {
    padding: 2px 7px;
    border-radius: 20px;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}

.call-type-badge.answered, .call-type-badge.completed,
.call-type-badge.agent_ended, .call-type-badge.remote_ended {
    background: var(--ph-green-bg);
    color: #166534;
}
.call-type-badge.missed, .call-type-badge.rejected,
.call-type-badge.failed, .call-type-badge.cancelled, .call-type-badge.busy,
.call-type-badge.no_answer, .call-type-badge.unavailable {
    background: var(--ph-red-bg);
    color: #991b1b;
}
.call-type-badge.unknown, .call-type-badge.default {
    background: var(--ph-surface-2);
    color: var(--ph-text-3);
}

/* history states */
.history-loading, .history-empty, .no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--ph-text-3);
    font-size: .83rem;
}

.history-loading { display: flex; align-items: center; justify-content: center; gap: 8px; }

.history-loading-spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--ph-border);
    border-top-color: var(--ph-accent);
    border-radius: 50%;
    animation: ph-spin .6s linear infinite;
}

@keyframes ph-spin { to { transform: rotate(360deg); } }

.history-empty-icon { font-size: 1.5rem; margin-bottom: 6px; color: var(--ph-border-strong); }
.history-empty-title { font-weight: 600; color: var(--ph-text-2); margin: 0 0 4px; font-size: .85rem; }
.history-empty-hint  { font-size: .78rem; color: var(--ph-text-3); margin: 0; }

.history-error { padding: 1rem; text-align: center; }
.history-error-title { color: var(--ph-red); font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.history-error-detail { font-size: .78rem; color: var(--ph-text-3); margin-bottom: .75rem; word-break: break-word; }

.history-retry-btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--ph-r);
    background: var(--ph-accent);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--ph-dur);
}
.history-retry-btn:hover { background: var(--ph-accent-hover); }

/** Caps long lists — inline link styled like history hints */
.history-cap-hint {
    font-size: .78rem;
    color: var(--ph-text-3);
    margin: .5rem .35rem .35rem;
    text-align: center;
    line-height: 1.45;
}

.history-show-all-btn {
    display: inline;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: inherit;
    font-weight: 600;
    color: var(--ph-accent);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    vertical-align: baseline;
}

.history-show-all-btn:hover,
.history-show-all-btn:focus-visible {
    color: var(--ph-accent-hover);
}

.history-show-all-btn:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

[data-phone-theme="dark"] .history-cap-hint {
    color: var(--ph-text-3);
}

/* ═══════════════════════════════════════════════════════════════════
   INCOMING CALL OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
.incoming-call {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-phone-overlay);
    animation: ph-fade-in var(--ph-dur) var(--ph-ease);
}

@keyframes ph-fade-in { from { opacity: 0; } to { opacity: 1; } }

.incoming-call-card {
    background: var(--ph-surface);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: var(--ph-shadow-xl);
    border: 1px solid var(--ph-border);
    max-width: 320px;
    width: 90%;
    animation: ph-pop-in var(--ph-dur-slow) var(--ph-ease);
}

@keyframes ph-pop-in {
    from { opacity: 0; transform: scale(.85) translateY(20px); }
    to   { opacity: 1; transform: none; }
}

.caller-avatar {
    width: 80px; height: 80px;
    background: var(--ph-accent-light);
    border: 3px solid var(--ph-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    color: var(--ph-accent);
    margin: 0 auto 1rem;
    animation: ph-ring-pulse 1.4s ease-in-out infinite;
}

@keyframes ph-ring-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.3); }
    50% { box-shadow: 0 0 0 12px rgba(37,99,235,.0); }
}

.caller-info h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ph-text);
    margin-bottom: .35rem;
}

.caller-info p {
    font-size: 1rem;
    color: var(--ph-text-2);
    margin-bottom: 1.5rem;
}

.call-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
}

.answer-btn {
    background: var(--ph-green) !important;
    box-shadow: 0 4px 16px rgba(22,163,74,.4) !important;
}

.answer-btn:hover:not(:disabled) {
    background: #15803d !important;
    box-shadow: 0 6px 20px rgba(22,163,74,.55) !important;
}

.reject-btn {
    background: var(--ph-red) !important;
    box-shadow: 0 4px 16px rgba(220,38,38,.4) !important;
}

.reject-btn:hover:not(:disabled) {
    background: #b91c1c !important;
    box-shadow: 0 6px 20px rgba(220,38,38,.55) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   STANDALONE FULL PHONE PAGE  (body.phone-bg)
   ═══════════════════════════════════════════════════════════════════ */
body.phone-bg {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* hide the widget FAB and shell on the standalone page */
body.phone-bg .webphone-floating-btn,
body.phone-bg #webphone-widget {
    display: none !important;
}

.phone-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem 1rem;
}

.phone-container {
    background: var(--ph-surface);
    border-radius: 24px;
    border: 1px solid var(--ph-border);
    box-shadow: var(--ph-shadow-xl);
    padding: 2rem;
    width: 100%;
    max-width: 440px;
    position: relative;
}

/* standalone header */
.phone-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--ph-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 44px; height: 44px;
    background: var(--ph-accent-light);
    border: 2px solid var(--ph-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--ph-accent);
    font-size: 1.1rem;
}

.user-details h6 {
    margin: 0;
    font-weight: 600;
    font-size: .9rem;
    color: var(--ph-text);
}

.user-details small { font-size: .75rem; color: var(--ph-text-3); }

.status-indicator {
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid var(--ph-surface);
    flex-shrink: 0;
}

.status-indicator.online  { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.6); }
.status-indicator.offline { background: #f87171; }

.header-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    /* Do not let a 100%-width .form-select shrink the row — keep one horizontal strip */
    min-width: min-content;
}

/* Standalone header: symmetric grid — presence | actions | status codes */
.phone-header .header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.65rem;
    row-gap: 0.35rem;
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

.phone-header .header-actions-center {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    justify-self: center;
}

/*
 * Standalone header presence: Bootstrap `.form-select.form-select-sm` wins over a
 * single class — use a chained selector. Light theme used nearly matching
 * border/surface greys; use --ph-border-strong so the field reads as a dropdown.
 * Bootstrap sets .form-select { width: 100% } — override so theme/settings stay inline.
 */
.phone-header .form-select.form-select-sm.phone-standalone-presence {
    width: 100%;
    max-width: 11.5rem;
    min-height: 36px;
    justify-self: start;
    font-size: 0.72rem;
    padding: 0.28rem 1.75rem 0.28rem 0.45rem;
    line-height: 1.2;
    border-radius: var(--ph-r);
    border: 1px solid var(--ph-border-strong);
    background-color: var(--ph-surface-2);
    /* Darker than default body / Bootstrap grey so the value reads crisply */
    color: #020617;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

[data-phone-theme="dark"] .phone-header .form-select.form-select-sm.phone-standalone-presence {
    color: var(--ph-text);
    font-weight: 500;
}

.phone-header .form-select.form-select-sm.phone-standalone-presence:focus {
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
    outline: none;
}

/* Standalone header — status codes column mirrors presence (symmetrical) */
.phone-header .phone-agent-codes-select.form-select.form-select-sm {
    width: 100%;
    max-width: 11.5rem;
    min-height: 36px;
    justify-self: end;
    font-size: 0.72rem;
    line-height: 1.2;
    font-weight: 500;
    padding: 0.28rem 1.35rem 0.28rem 0.45rem;
    border-radius: var(--ph-r);
    color: #3730a3;
    background-color: color-mix(in srgb, #faf5ff 87%, #667eea 13%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%235b21b6' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.35rem center;
    background-size: 9px 9px;
    border: 1px solid color-mix(in srgb, #e9d5ff 46%, #667eea 54%);
    appearance: none;
    -webkit-appearance: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

[data-phone-theme="dark"] .phone-header .phone-agent-codes-select.form-select.form-select-sm {
    color: #e9d5ff;
    background-color: color-mix(in srgb, #1e1b4b 80%, #5b21b6 20%);
    border-color: color-mix(in srgb, #4c1d95 45%, #a78bfa 55%);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23c4b5fd' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

.phone-header .phone-agent-codes-select.form-select.form-select-sm:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.26);
    outline: none;
}

[data-phone-theme="dark"] .phone-header .phone-agent-codes-select.form-select.form-select-sm:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.3);
}

.phone-header .phone-agent-codes-select.form-select.form-select-sm option {
    font-size: 0.72rem;
    font-weight: 500;
}

.phone-header .header-actions .action-btn {
    flex: 0 0 36px;
}

.action-btn {
    width: 36px; height: 36px;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-r);
    background: var(--ph-surface-2);
    color: var(--ph-text-2);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem;
    cursor: pointer;
    transition: background var(--ph-dur), color var(--ph-dur), border-color var(--ph-dur);
    outline: none;
}

.action-btn:hover {
    background: var(--ph-accent-light);
    border-color: var(--ph-accent);
    color: var(--ph-accent);
}

.action-btn:focus-visible { outline: 2px solid var(--ph-accent); outline-offset: 2px; }

/* standalone display screen */
.display-screen {
    background: var(--ph-screen-bg);
    border-radius: var(--ph-r-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,.06);
}

.display-screen .display-number {
    font-size: 2rem;
    font-weight: 300;
    color: #f1f5f9;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Courier New', monospace;
    min-height: 2.4rem;
}

.display-screen .display-status { font-size: .85rem; color: #94a3b8; margin-top: 4px; }

.display-screen .call-timer {
    font-size: 1.25rem;
    font-weight: 600;
    color: #4ade80;
    margin-top: 4px;
    font-family: ui-monospace, monospace;
}

/* standalone dialpad */
.phone-container .dialpad {
    gap: 10px;
}

.phone-container .dial-btn {
    width: 72px; height: 72px;
}

.phone-container .dial-digit { font-size: 1.3rem; }

/* standalone call buttons */
.phone-container .call-btn,
.phone-container .hangup-btn {
    width: 72px; height: 72px;
    font-size: 1.45rem;
}

.phone-container .control-btn {
    width: 48px; height: 48px;
    font-size: 1.05rem;
}

/* standalone history */
.phone-container .call-history { margin-top: 1rem; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .webphone-widget {
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%; max-width: 100%;
        border-radius: 0;
    }

    .phone-wrapper { padding: 1rem .5rem; }

    .phone-container {
        border-radius: var(--ph-r-xl);
        padding: 1.25rem;
    }

    .webphone-floating-btn {
        bottom: 20px; right: 16px;
        width: 52px; height: 52px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .dial-btn { width: 60px; height: 60px; }
    .call-btn, .hangup-btn { width: 62px; height: 62px; font-size: 1.25rem; }
    .phone-container .dial-btn { width: 64px; height: 64px; }
}

/* ═══════════════════════════════════════════════════════════════════
   FOCUS / ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════ */
.dial-btn:focus-visible,
.control-btn:focus-visible,
.call-btn:focus-visible,
.hangup-btn:focus-visible,
.action-btn:focus-visible,
.widget-header-btn:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
}

/* Click-to-dial links (roadside experts, call logs, etc.) */
a.webphone-call-link {
    cursor: pointer;
    white-space: nowrap;
}
a.webphone-call-link:hover .og-phone-digits {
    text-decoration: underline;
}
a.webphone-call-link .og-outbound-code {
    font-weight: 600;
    opacity: 0.85;
}
a.webphone-call-link .og-outbound-sep {
    margin: 0 0.2em;
    opacity: 0.55;
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════ */
@media print {
    .webphone-floating-btn, .webphone-widget { display: none !important; }
}
