/* ============================================================
   NIR PBX — Softphone Styles
   Uses design tokens from variables.css
   ============================================================ */

/* === Status indicator dots === */
.sp-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background-color 0.3s;
}

.sp-status-dot.disconnected {
    background: var(--color-border);
}

.sp-status-dot.connecting {
    background: var(--color-warning);
    animation: sp-pulse 1s ease-in-out infinite;
}

.sp-status-dot.registered {
    background: var(--color-success);
}

.sp-status-dot.in-call {
    background: var(--color-success);
    animation: sp-pulse 1.5s ease-in-out infinite;
}

.sp-status-dot.ringing {
    background: var(--color-accent);
    animation: sp-pulse 0.5s ease-in-out infinite;
}

.sp-status-dot.error {
    background: var(--color-error);
}

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

/* === Protocol badge === */
.sp-proto {
    font-size: 11px;
    opacity: 0.7;
    padding: 2px 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    font-family: 'SF Mono', Consolas, monospace;
}

/* === Timer display === */
.sp-timer {
    font-size: 28px;
    font-weight: 700;
    font-family: 'SF Mono', Consolas, monospace;
    color: var(--color-link);
    text-align: center;
    padding: var(--space-xs) 0;
    letter-spacing: 2px;
}

/* === Number display flash effect === */
.sp-num-flash {
    color: var(--color-link) !important;
    transition: color 0.15s;
}

/* === Backspace button === */
.sp-backspace {
    min-height: var(--button-height);
    width: 56px;
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sp-backspace:hover {
    background: var(--color-border);
}

.sp-backspace:active {
    background: var(--color-error);
    color: #fff;
}

/* === Disabled call button === */
.sp-call:disabled {
    background: var(--color-border) !important;
    color: var(--color-text-secondary) !important;
    cursor: not-allowed;
}

/* === Reconnect button variant === */
.sp-reconnect {
    background: var(--color-warning) !important;
    color: var(--color-text) !important;
}

.sp-reconnect:hover {
    background: var(--color-accent-hover) !important;
}

/* === Incoming call overlay === */
.sp-incoming {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-md);
    background: linear-gradient(135deg, #E6EFFF 0%, #fff 100%);
    border-bottom: 1px solid var(--color-border);
    animation: sp-incoming-pulse 1.5s ease-in-out infinite;
}

@keyframes sp-incoming-pulse {
    0%, 100% { background-color: #E6EFFF; }
    50% { background-color: #d0e0ff; }
}

.sp-incoming-icon {
    font-size: var(--font-size-small);
    font-weight: 700;
    color: var(--color-link);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sp-incoming-caller {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    text-align: center;
    word-break: break-all;
}

.sp-incoming-actions {
    display: flex;
    gap: var(--space-sm);
    width: 100%;
}

.sp-answer-btn {
    flex: 1;
    min-height: var(--button-height);
    background: var(--color-success);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sp-answer-btn:hover {
    background: #006d49;
}

.sp-answer-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.sp-reject-btn {
    flex: 1;
    min-height: var(--button-height);
    background: var(--color-error);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sp-reject-btn:hover {
    background: #cc0000;
}

.sp-reject-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* === In-call action buttons === */
.sp-actions-call {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-sm) 12px 12px;
    flex-wrap: wrap;
}

.sp-action-btn {
    flex: 1;
    min-width: 56px;
    min-height: 44px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--color-text);
    transition: all 0.15s;
    font-family: var(--font-family);
}

.sp-action-btn:hover {
    background: var(--color-border);
}

.sp-action-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.sp-action-btn.active {
    background: var(--color-link);
    color: #fff;
    border-color: var(--color-link);
}

.sp-action-icon {
    font-size: 18px;
    line-height: 1;
}

.sp-hangup-btn {
    width: 100%;
    min-height: var(--button-height);
    margin-top: var(--space-xs);
    background: var(--color-error);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
    font-family: var(--font-family);
}

.sp-hangup-btn:hover {
    background: #cc0000;
}

.sp-hangup-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* === Dialpad adjustments for in-call DTMF mode === */
.sp-actions-call ~ .sp-dialpad,
.sp-dialpad.sp-dtmf-mode {
    border-top: 1px solid var(--color-border);
}

/* === Hide button in header === */
.sp-hide-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.sp-hide-btn:hover { color: #fff; }

/* === Collapse indicator on header === */
.sp-header {
    cursor: pointer;
    user-select: none;
}

.sp-header:hover {
    filter: brightness(1.1);
}

/* === Drag handle hint === */
.sp-header::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 3px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

/* === Header trunk selector (compact, mobile-first) === */
.sp-trunk-hdr {
    display: none; /* hidden on desktop, shown via mobile media query */
}
/* === Display row with inline backspace === */
.sp-display-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.sp-backspace-inline {
    display: none; /* hidden on desktop, shown on mobile */
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-text-secondary, #888);
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}
.sp-backspace-inline:hover {
    color: var(--color-text, #333);
}

/* === Tab bar (hidden on desktop, shown on mobile) === */
.sp-tab-bar {
    display: none;
}
/* === Tab views === */
.sp-tab-view {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sp-fav-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-secondary, #888);
    font-size: 14px;
}
.sp-fav-list, .sp-contacts-list {
    display: flex;
    flex-direction: column;
}
.sp-fav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border, #e5e5e5);
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.sp-fav-item:active {
    background: var(--color-bg-secondary, #f5f5f5);
}
.sp-fav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.sp-fav-info {
    flex: 1;
    min-width: 0;
}
.sp-fav-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text, #222);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-fav-ext {
    font-size: 12px;
    color: var(--color-text-secondary, #888);
}
.sp-fav-call {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--color-success, #27ae60);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}
.sp-fav-star {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-border, #ccc);
    cursor: pointer;
    flex-shrink: 0;
}
.sp-fav-star.active {
    color: #f5a623;
}
.sp-contacts-search {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid var(--color-border, #e5e5e5);
    font-size: 15px;
    outline: none;
    background: var(--color-bg-secondary, #f8f8f8);
}
.sp-contacts-filter {
    display: flex;
    padding: 6px 12px;
    gap: 0;
    background: var(--color-bg-secondary, #f2f2f7);
    border-bottom: 0.5px solid var(--color-border, #e5e5e5);
}
.sp-filter-btn {
    flex: 1;
    padding: 6px 0;
    border: 1px solid var(--color-border, #c6c6c8);
    background: #fff;
    color: var(--color-text-secondary, #666);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.sp-filter-btn:first-child {
    border-radius: 6px 0 0 6px;
}
.sp-filter-btn:last-child {
    border-radius: 0 6px 6px 0;
}
.sp-filter-btn:not(:first-child) {
    border-left: none;
}
.sp-filter-btn.active {
    background: var(--color-link, #007aff);
    color: #fff;
    border-color: var(--color-link, #007aff);
}

/* === Ring group styles === */
.sp-contact-wrap {
    border-bottom: 1px solid var(--color-border, #e5e5e5);
}
.sp-contact-wrap .sp-fav-item {
    border-bottom: none;
}
.sp-group-badge {
    font-size: 10px;
    color: #5856d6;
    background: #ede7f6;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}
.sp-expand-group {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: var(--color-text-secondary, #999);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}
.sp-group-members {
    background: var(--color-bg-secondary, #f8f8f8);
    padding: 0 0 0 36px;
}
.sp-group-member {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 12px;
    border-top: 0.5px solid var(--color-border, #eee);
    cursor: pointer;
    font-size: 14px;
}
.sp-group-member:active {
    background: #e8e8ed;
}
.sp-grp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success, #34c759);
    flex-shrink: 0;
}
.sp-grp-name {
    flex: 1;
    color: var(--color-text, #333);
}
.sp-grp-ext {
    color: var(--color-text-secondary, #999);
    font-size: 12px;
    font-family: var(--font-mono, monospace);
}
.sp-grp-call {
    width: 28px !important;
    height: 28px !important;
    font-size: 16px !important;
}

/* === Add contact form === */
.sp-contacts-header {
    display: flex;
    gap: 6px;
    align-items: center;
}
.sp-contacts-header .sp-contacts-search {
    flex: 1;
}
.sp-add-contact-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-link, #007aff);
    color: #fff;
    border: none;
    font-size: 22px;
    font-weight: 300;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}
.sp-add-contact-form {
    padding: 12px 16px;
    background: var(--color-bg-secondary, #f8f8f8);
    border-bottom: 1px solid var(--color-border, #e5e5e5);
}
.sp-add-input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--color-border, #e5e5e5);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}
.sp-add-input:focus {
    border-color: var(--color-link, #007aff);
}
.sp-add-btns {
    display: flex;
    gap: 8px;
}
.sp-add-save {
    flex: 1;
    padding: 10px;
    background: var(--color-success, #34c759);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.sp-add-cancel {
    flex: 1;
    padding: 10px;
    background: var(--color-bg-secondary, #e5e5e5);
    color: var(--color-text, #333);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}
.sp-personal-badge {
    font-size: 10px;
    color: #78909c;
    background: #eceff1;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}
.sp-del-contact {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: var(--color-error, #ff3b30);
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.5;
}
.sp-del-contact:hover {
    opacity: 1;
}

/* === Mobile — iPhone-style fullscreen softphone === */
@media (max-width: 768px) {
    /* --- Container: fullscreen grid --- */
    .softphone {
        width: 100% !important;
        right: 0 !important;
        bottom: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        overflow: hidden;
        display: grid !important;
        grid-template-rows: auto 1fr auto;
        background: #f2f2f7;
    }
    .softphone.sp-hidden {
        transform: translateY(100%);
    }

    /* --- Header: compact gradient --- */
    .softphone .sp-header {
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
        padding: 12px 16px;
    }
    .softphone .sp-proto { display: none; }
    .softphone .sp-trunk-hdr {
        display: inline-block;
        background: rgba(255,255,255,0.15);
        color: #fff;
        border: 1px solid rgba(255,255,255,0.25);
        border-radius: 6px;
        padding: 3px 8px;
        font-size: 12px;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
    }
    .softphone .sp-trunk-hdr option {
        color: #333;
        background: #fff;
    }

    /* --- Body: flex column fills space --- */
    .softphone #sp-body {
        display: flex !important;
        flex-direction: column;
        overflow: hidden !important;
        min-height: 0;
        max-height: none !important;
        opacity: 1 !important;
        background: #f2f2f7;
    }

    /* --- Number display: large light font like iOS --- */
    .softphone .sp-display {
        padding: 12px 20px 4px;
        background: #fff;
        border-bottom: none;
        flex-shrink: 0;
    }
    .softphone .sp-number {
        font-size: 32px;
        font-weight: 300;
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
        letter-spacing: -0.5px;
        min-height: 40px;
    }
    .softphone .sp-display-row {
        justify-content: center;
    }
    .softphone .sp-backspace-inline {
        display: block;
        font-size: 22px;
        color: #999;
        padding: 4px 12px;
    }
    .softphone .sp-label {
        font-size: 13px;
        color: #8e8e93;
    }

    /* --- Search: compact --- */
    .softphone .sp-search-wrap {
        padding: 4px 12px;
        background: #fff;
        flex-shrink: 0;
    }
    .softphone .sp-search {
        padding: 8px 12px;
        font-size: 14px;
        background: #f2f2f7;
        border: none;
        border-radius: 10px;
    }

    /* --- Dialpad: circular keys like iOS --- */
    .softphone .sp-dialpad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 8px 28px;
        background: #f2f2f7;
        flex: 1;
        align-content: center;
        justify-items: center;
    }
    .softphone .sp-key {
        width: 72px;
        height: 72px;
        aspect-ratio: 1;
        border-radius: 50%;
        background: #fff;
        margin: 0;
        font-size: 28px;
        font-weight: 400;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        transition: background 0.1s;
    }
    .softphone .sp-key:hover {
        background: #e8e8ed;
    }
    .softphone .sp-key:active {
        background: #d1d1d6;
        color: var(--color-text);
        transform: none;
    }
    .softphone .sp-key .sub {
        font-size: 9px;
        letter-spacing: 1.5px;
        font-weight: 600;
        color: #8e8e93;
        margin-top: -2px;
    }

    /* --- Call button: green circle --- */
    .softphone .sp-actions {
        display: flex !important;
        justify-content: center;
        padding: 8px 0;
        background: #f2f2f7;
        flex-shrink: 0;
    }
    .softphone .sp-actions .sp-call {
        width: 64px;
        height: 64px;
        min-height: unset;
        border-radius: 50%;
        flex: unset;
        font-size: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #34c759;
        box-shadow: 0 4px 12px rgba(52,199,89,0.3);
    }
    .softphone .sp-actions .sp-call::before {
        content: '';
        display: block;
        width: 28px;
        height: 28px;
        background: #fff;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.62 10.79a15.05 15.05 0 006.59 6.59l2.2-2.2a1 1 0 011.01-.24 11.72 11.72 0 003.66.59 1 1 0 011 1V20a1 1 0 01-1 1A17 17 0 013 4a1 1 0 011-1h3.5a1 1 0 011 1 11.72 11.72 0 00.58 3.66 1 1 0 01-.24 1.01l-2.22 2.12z'/%3E%3C/svg%3E") center/contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.62 10.79a15.05 15.05 0 006.59 6.59l2.2-2.2a1 1 0 011.01-.24 11.72 11.72 0 003.66.59 1 1 0 011 1V20a1 1 0 01-1 1A17 17 0 013 4a1 1 0 011-1h3.5a1 1 0 011 1 11.72 11.72 0 00.58 3.66 1 1 0 01-.24 1.01l-2.22 2.12z'/%3E%3C/svg%3E") center/contain no-repeat;
    }
    .softphone .sp-actions .sp-call:active {
        transform: scale(0.92);
    }
    /* Hide desktop-only buttons on mobile */
    .softphone .sp-actions .sp-history-toggle { display: none; }
    .softphone #sp-actions-idle .sp-backspace { display: none; }

    /* --- In-call actions --- */
    .softphone .sp-actions-call {
        flex-shrink: 0;
        padding: 8px 12px;
        background: #f2f2f7;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    /* --- Trunk row: hidden on mobile (in header) --- */
    .softphone .sp-trunk-select { display: none !important; }

    /* --- Speed dial: hidden on mobile --- */
    .softphone .sp-speed-dial { display: none; }

    /* --- History: fills space --- */
    .softphone .sp-history {
        max-height: none;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        background: #fff;
    }
    .softphone .sp-history-back {
        background: #f2f2f7;
        color: #007aff;
    }

    /* --- Tab views: fill space --- */
    .softphone .sp-tab-view {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        background: #fff;
    }

    /* --- Tab bar: iOS-style bottom tabs --- */
    .softphone .sp-tab-bar {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        border-top: 0.5px solid #c6c6c8;
        background: rgba(249,249,249,0.94);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-shrink: 0;
        padding: 2px 0 0;
        padding-bottom: max(2px, env(safe-area-inset-bottom));
    }
    .sp-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        padding: 4px 0 2px;
        background: none;
        border: none;
        cursor: pointer;
        color: #8e8e93;
        font-size: 10px;
        font-weight: 500;
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .sp-tab.active {
        color: #007aff;
    }
    .sp-tab-icon {
        font-size: 24px;
        line-height: 1;
    }

    /* --- Contacts search in tab --- */
    .softphone .sp-contacts-search {
        background: #f2f2f7;
        border: none;
        border-bottom: 0.5px solid #c6c6c8;
        padding: 10px 16px;
        font-size: 15px;
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    }

    /* --- Favorite/contact items --- */
    .softphone .sp-fav-item {
        border-bottom-color: #e5e5ea;
        padding: 10px 16px;
    }
    .softphone .sp-fav-name {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    }
    .softphone .sp-fav-call {
        color: #34c759;
    }

    /* --- Touch optimization --- */
    .softphone button,
    .softphone select,
    .softphone input {
        touch-action: manipulation;
    }

    /* Hide call button when not on keypad tab */
    .softphone:not(.sp-tab-keypad) #sp-actions-idle {
        display: none !important;
    }

    /* --- FAB position --- */
    #sp-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* === Test plan page — dock to bottom-left so it doesn't cover test buttons === */
/* Loaded AFTER main.css so this is the canonical rule. Uses !important to
   beat the @media mobile rule above when on small screens. */
body.softphone-dock-left .softphone {
    right: auto !important;
    left: 20px !important;
}
body.softphone-dock-left #sp-fab {
    right: auto !important;
    left: 24px !important;
}

/* === Trunk Selector === */
.sp-trunk-select {
    padding: 4px 12px;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
}
.sp-trunk-select select {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    background: var(--color-bg-primary, #fff);
    cursor: pointer;
}

/* === Call History === */
.sp-history {
    max-height: 260px;
    overflow-y: auto;
    border-top: 1px solid var(--color-border, #e0e0e0);
}
.sp-history-back {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-secondary, #f5f5f5);
    border: none;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
    text-align: left;
    font-size: 14px;
    color: var(--color-link, #1a73e8);
    cursor: pointer;
}
.sp-history-back:hover {
    background: var(--color-bg-hover, #eee);
}
.sp-history-list {
    display: flex;
    flex-direction: column;
}
.sp-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border, #f0f0f0);
    transition: background 0.15s;
}
.sp-history-item:hover {
    background: var(--color-hover, #f5f5f5);
}
.sp-history-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.sp-history-info {
    flex: 1;
    min-width: 0;
}
.sp-history-number {
    font-size: 14px;
    font-weight: 600;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-history-meta {
    font-size: 11px;
    color: var(--color-muted, #888);
}
.sp-history-call {
    background: none;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.sp-history-call:hover {
    background: var(--color-success, #43a047);
    color: #fff;
    border-color: var(--color-success, #43a047);
}
.sp-history-toggle {
    background: none;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s;
}
.sp-history-toggle.active {
    background: var(--color-link, #1e88e5);
    color: #fff;
    border-color: var(--color-link, #1e88e5);
}

/* === Contact Search === */
.sp-search-wrap {
    position: relative;
    padding: 4px 12px;
}
.sp-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border, rgba(255,255,255,0.2));
    border-radius: var(--border-radius, 6px);
    background: var(--color-bg-secondary, #f5f5f5);
    font-size: 13px;
    font-family: var(--font-family, inherit);
    color: var(--color-text, #333);
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.sp-search:focus {
    border-color: var(--color-link, #1e88e5);
}
.sp-search::placeholder {
    color: var(--color-muted, #999);
}
.sp-search-results {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    top: 100%;
    background: var(--color-bg-primary, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 0 0 var(--border-radius, 6px) var(--border-radius, 6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}
.sp-contact-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text, #333);
    border-bottom: 1px solid var(--color-border, #f0f0f0);
    transition: background 0.15s;
}
.sp-contact-item:last-child {
    border-bottom: none;
}
.sp-contact-item:hover {
    background: var(--color-hover, #e8f0fe);
}

/* === Speed Dial === */
.sp-speed-dial {
    display: none;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
    scrollbar-width: thin;
}
.sp-speed-dial::-webkit-scrollbar {
    height: 3px;
}
.sp-speed-item {
    text-align: center;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: transform 0.1s;
}
.sp-speed-item:hover {
    transform: scale(1.1);
}
.sp-speed-item:active {
    transform: scale(0.95);
}
.sp-speed-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-link, #1e88e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    position: relative;
    line-height: 1;
}
.sp-speed-label {
    font-size: 10px;
    color: var(--color-muted, #888);
    font-family: monospace;
}

/* Speed dial presence dots */
.sp-speed-presence {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-bg-primary, #fff);
}
.sp-presence-available { background: var(--color-success, #43a047); }
.sp-presence-busy { background: var(--color-error, #e53935); }
.sp-presence-dnd { background: var(--color-error, #e53935); }
.sp-presence-away { background: var(--color-warning, #fb8c00); }
.sp-presence-lunch { background: var(--color-warning, #fb8c00); }
.sp-presence-business_trip { background: var(--color-warning, #fb8c00); }

/* === Missed Call Badge on FAB === */
.sp-missed-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-error, #e53935);
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
}
/* FAB position handled by main.css — do not override */

/* === Volume Control === */
.sp-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-top: 1px solid var(--color-border, #e0e0e0);
}
.sp-vol-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.sp-volume input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-border, #ccc);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.sp-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-link, #1e88e5);
    cursor: pointer;
    border: none;
}
.sp-volume input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-link, #1e88e5);
    cursor: pointer;
    border: none;
}
