/* ============================================
   BROWSER CALLING STYLES
   ============================================ */

/* Browser Calling Status Bar - Compact */
.browser-calling-bar {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.browser-calling-bar.online {
    background: linear-gradient(135deg, rgba(25, 135, 84, 0.1) 0%, rgba(25, 135, 84, 0.05) 100%);
    border-color: rgba(25, 135, 84, 0.3);
}

.browser-calling-bar.connecting {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 193, 7, 0.05) 100%);
    border-color: rgba(255, 193, 7, 0.3);
}

.browser-calling-bar .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Quick Stats Cards */
.stat-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--bs-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card.active {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.stat-card.active .stat-icon,
.stat-card.active .stat-label {
    color: rgba(255, 255, 255, 0.9) !important;
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    opacity: 0.9;
}

.stat-card .stat-content {
    flex: 1;
    min-width: 0;
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

@media (max-width: 575.98px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem 0.5rem;
        gap: 0.25rem;
    }
    
    .stat-card .stat-icon {
        font-size: 1.25rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.6rem;
    }
}

/* Call List Styles */
.call-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.call-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.call-item:hover {
    border-color: var(--bs-primary);
    background: var(--bs-tertiary-bg);
}

.call-item.active {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.1);
}

.call-item .call-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-tertiary-bg);
    border-radius: 50%;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.call-item .call-details {
    flex: 1;
    min-width: 0;
}

.call-item .call-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-item .call-meta {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

.call-item .call-badges {
    display: flex;
    gap: 0.25rem;
}

.call-item .call-badges .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
}

.call-item .call-action {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.call-item:hover .call-action {
    opacity: 1;
}

.call-item .call-action .btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767.98px) {
    .call-item .call-action {
        opacity: 1;
    }
}

/* Call Details Panel */
.call-details-panel {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 16px;
    padding: 1.5rem;
    position: relative;
}

/* iOS Bottom Sheet Handle - hidden on desktop */
.call-details-handle {
    display: none;
}

.call-details-panel .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

/* Contact Header */
.contact-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.contact-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0056b3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.contact-number {
    color: var(--bs-secondary-color);
    margin: 0.25rem 0 0 0;
    font-size: 0.95rem;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.action-btn i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.action-btn span {
    font-size: 0.7rem;
    font-weight: 500;
}

.action-btn.call {
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.action-btn.call:hover {
    background: #198754;
    color: white;
}

.action-btn.message {
    background: rgba(13, 110, 253, 0.15);
    color: #0d6efd;
}

.action-btn.message:hover {
    background: #0d6efd;
    color: white;
}

.action-btn.lead,
.action-btn.customer {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

.action-btn.lead:hover,
.action-btn.customer:hover {
    background: #6c757d;
    color: white;
}

.action-btn.add {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    border: 2px dashed rgba(255, 193, 7, 0.5);
}

.action-btn.add:hover {
    background: #ffc107;
    color: #000;
    border-style: solid;
}

.action-btn.block {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.action-btn.block:hover {
    background: #dc3545;
    color: #fff;
}

.action-btn.unblock {
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.action-btn.unblock:hover {
    background: #198754;
    color: #fff;
}

.action-btn.quote {
    background: rgba(13, 202, 240, 0.15);
    color: #0dcaf0;
}

.action-btn.quote:hover {
    background: #0dcaf0;
    color: #000;
}

/* Details Sections */
.details-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.details-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bs-secondary-color);
    margin-bottom: 1rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 500;
}

/* Audio Player */
.audio-player audio {
    border-radius: 8px;
}

/* Transcription */
.transcription {
    background: var(--bs-tertiary-bg);
    padding: 1rem;
    border-radius: 10px;
    border-left: 3px solid var(--bs-info);
}

/* Notes Input */
.notes-input textarea {
    border-radius: 10px;
    resize: none;
}

/* Follow-up Controls */
.follow-up-controls .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
}

/* Browser Calling Toggle Card (legacy - keep for fallback) */
.browser-calling-card {
    background: linear-gradient(135deg, var(--bs-success) 0%, #198754 100%);
    border: none;
    border-radius: 12px;
    color: white;
    transition: all 0.3s ease;
}

.browser-calling-card.disconnected {
    background: linear-gradient(135deg, var(--bs-secondary) 0%, #495057 100%);
}

.browser-calling-card .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.browser-calling-card .form-check-input:checked {
    background-color: #fff;
    border-color: #fff;
}

.browser-calling-card .form-check-input:checked::before {
    background-color: var(--bs-success);
}

/* Connection Status Indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.connection-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.connection-status .status-dot.connected {
    background-color: #00ff88;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

.connection-status .status-dot.connecting {
    background-color: #ffc107;
    animation: blink 1s infinite;
}

.connection-status .status-dot.disconnected {
    background-color: #dc3545;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Active Call Panel */
.active-call-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 1rem;
    z-index: 1050;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.active-call-panel.show {
    transform: translateY(0);
}

/* iOS Safe Area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .active-call-panel {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

.active-call-panel .call-info {
    text-align: center;
    margin-bottom: 1rem;
}

.active-call-panel .caller-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.active-call-panel .caller-number {
    font-size: 0.875rem;
    opacity: 0.8;
}

.active-call-panel .call-status {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #00ff88;
    margin-top: 0.5rem;
}

.active-call-panel .call-status.connecting {
    color: #ffc107;
}

.active-call-panel .call-status.ringing {
    color: #17a2b8;
}

.active-call-panel .call-timer {
    font-size: 1.5rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
}

/* Call Controls */
.call-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.call-control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.call-control-btn:hover {
    transform: scale(1.1);
}

.call-control-btn:active {
    transform: scale(0.95);
}

.call-control-btn.mute {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.call-control-btn.mute.active {
    background: #dc3545;
    color: white;
}

.call-control-btn.keypad {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.call-control-btn.keypad.active {
    background: var(--bs-primary);
    color: white;
}

.call-control-btn.hangup {
    background: #dc3545;
    color: white;
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

.call-control-btn.hangup:hover {
    background: #c82333;
}

.call-control-btn.answer {
    background: #28a745;
    color: white;
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

.call-control-btn.answer:hover {
    background: #218838;
}

/* In-Call Keypad */
.in-call-keypad {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.in-call-keypad.show {
    display: block;
}

.in-call-keypad .keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 240px;
    margin: 0 auto;
}

.in-call-keypad .keypad-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 auto;
}

.in-call-keypad .keypad-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.in-call-keypad .keypad-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.in-call-keypad .keypad-btn .letters {
    font-size: 0.5rem;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-top: 2px;
}

/* Incoming Call Modal */
.incoming-call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.incoming-call-overlay .caller-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0056b3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    margin-bottom: 1.5rem;
    animation: ring 1.5s infinite;
}

@keyframes ring {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(0, 123, 255, 0); }
}

.incoming-call-overlay .caller-info {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.incoming-call-overlay .caller-name {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.incoming-call-overlay .caller-number {
    font-size: 1rem;
    opacity: 0.8;
}

.incoming-call-overlay .call-type {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-top: 0.5rem;
}

.incoming-call-actions {
    display: flex;
    gap: 3rem;
}

.incoming-call-actions .call-action-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.incoming-call-actions .call-action-btn span {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: white;
}

.incoming-call-actions .decline-btn {
    background: #dc3545;
    color: white;
}

.incoming-call-actions .decline-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.incoming-call-actions .answer-btn {
    background: #28a745;
    color: white;
}

.incoming-call-actions .answer-btn:hover {
    background: #218838;
    transform: scale(1.1);
}

/* Dialer Modal Improvements */
.dialer-modal .dialpad .btn {
    min-height: 60px;
    font-size: 1.5rem;
    font-weight: 500;
    border-radius: 50%;
    width: 60px;
    margin: 0 auto;
}

.dialer-modal .dial-input {
    font-size: 1.75rem;
    text-align: center;
    letter-spacing: 2px;
    border: none;
    border-bottom: 2px solid var(--bs-primary);
    border-radius: 0;
    background: transparent;
}

.dialer-modal .dial-input:focus {
    box-shadow: none;
    border-color: var(--bs-primary);
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .browser-calling-card {
    background: linear-gradient(135deg, #198754 0%, #0d5c36 100%);
}

[data-bs-theme="dark"] .browser-calling-card.disconnected {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
}

/* Mobile optimizations */
@media (max-width: 575.98px) {
    .active-call-panel {
        padding: 0.75rem;
    }

    .call-controls {
        gap: 0.75rem;
    }

    .call-control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }

    .call-control-btn.hangup,
    .call-control-btn.answer {
        width: 58px;
        height: 58px;
        font-size: 1.3rem;
    }

    .in-call-keypad .keypad-btn {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    .incoming-call-actions {
        gap: 2rem;
    }

    .incoming-call-actions .call-action-btn {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }
}

/* Ensure panel is above mobile nav */
@media (max-width: 991.98px) {
    .active-call-panel {
        bottom: 60px; /* Account for mobile nav */
    }
    
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .active-call-panel {
            bottom: calc(60px + env(safe-area-inset-bottom));
            padding-bottom: 1rem;
        }
    }
    
    /* ============================================
       CALL DETAILS PANEL - iOS BOTTOM SHEET STYLE
       ============================================
       - Slides up from bottom like native iOS sheets
       - Properly handles keyboard appearance
       - Has drag handle and proper safe areas
       - Scrollable content area
    */
    .call-details-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        /* Height: full screen minus status bar area */
        top: env(safe-area-inset-top, 0px);
        z-index: 1040;
        background: var(--bs-body-bg);
        border-radius: 20px 20px 0 0;
        border: none;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        animation: slideUpSheet 0.3s ease-out;
    }
    
    @keyframes slideUpSheet {
        from {
            transform: translateY(100%);
            opacity: 0.8;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* iOS Bottom Sheet Drag Handle */
    .call-details-handle {
        display: block;
        width: 36px;
        height: 5px;
        background: var(--bs-secondary-bg, #dee2e6);
        border-radius: 3px;
        margin: 10px auto 6px;
        flex-shrink: 0;
    }
    
    /* Close button - top right, always visible */
    .call-details-panel .close-btn {
        position: absolute;
        top: 8px;
        right: 12px;
        z-index: 10;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bs-tertiary-bg);
    }
    
    /* The panel itself scrolls */
    .call-details-panel {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Padding for content */
        padding: 0 1rem 1rem 1rem;
        padding-top: 0;
        /* Bottom padding: safe area + bottom nav space */
        padding-bottom: calc(16px + 60px + env(safe-area-inset-bottom, 0px));
    }
    
    /* When keyboard is open, reduce bottom padding */
    .call-details-panel.keyboard-open {
        padding-bottom: 16px;
    }
    
    /* Keyboard open - detected via body attribute from ios-mobile-core.js */
    body[data-keyboard-open="true"] .call-details-panel {
        /* Reduce bottom padding when keyboard is visible */
        padding-bottom: 16px;
        /* Adjust max-height based on visual viewport */
        max-height: 100vh;
        max-height: calc(var(--messages-visual-viewport-height, 100vh));
    }
    
    /* Contact header adjustments */
    .call-details-panel .contact-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        padding-top: 0.5rem;
        padding-bottom: 1rem;
        margin-top: 0;
    }
    
    .call-details-panel .contact-avatar {
        width: 72px;
        height: 72px;
        font-size: 1.75rem;
    }
    
    .call-details-panel .contact-name {
        font-size: 1.35rem;
    }
    
    /* Quick actions - horizontal scroll on very small screens */
    .call-details-panel .quick-actions {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .call-details-panel .action-btn {
        width: 60px;
        height: 60px;
        border-radius: 14px;
    }
    
    .call-details-panel .action-btn i {
        font-size: 1.1rem;
    }
    
    .call-details-panel .action-btn span {
        font-size: 0.65rem;
    }
    
    /* Details grid - single column on mobile */
    .call-details-panel .details-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Sections - tighter spacing */
    .call-details-panel .details-section {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
    
    .call-details-panel .section-title {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
    
    /* Notes textarea - proper sizing and iOS keyboard handling */
    .call-details-panel .notes-input textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 80px;
        border-radius: 12px;
    }
    
    /* Ensure textarea is visible when focused (keyboard open) */
    .call-details-panel .notes-input textarea:focus {
        /* iOS will scroll this into view automatically */
    }
    
    /* Audio player */
    .call-details-panel .audio-player-container audio {
        height: 44px;
        border-radius: 10px;
    }
}

/* Dark mode adjustments for new components */
[data-bs-theme="dark"] .stat-card {
    background: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .stat-card.active {
    background: var(--bs-primary);
}

[data-bs-theme="dark"] .call-item {
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .call-details-panel {
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .contact-avatar {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0a58ca 100%);
}

[data-bs-theme="dark"] .transcription {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================
   GLOBAL INCOMING CALL OVERLAY
   ============================================ */

.global-incoming-call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.incoming-call-card {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 24px;
    padding: 2rem;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.incoming-call-card .caller-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0056b3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 600;
    color: white;
    margin: 0 auto 1.5rem;
    position: relative;
}

.incoming-call-card .caller-avatar.pulse-ring::before,
.incoming-call-card .caller-avatar.pulse-ring::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px solid var(--bs-primary);
    animation: pulseRing 1.5s ease-out infinite;
}

.incoming-call-card .caller-avatar.pulse-ring::after {
    animation-delay: 0.5s;
}

/* Pulse ring for incoming call overlay (index page) */
.incoming-call-overlay .caller-avatar.pulse-ring {
    position: relative;
}

.incoming-call-overlay .caller-avatar.pulse-ring::before,
.incoming-call-overlay .caller-avatar.pulse-ring::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px solid var(--bs-primary);
    animation: pulseRing 1.5s ease-out infinite;
}

.incoming-call-overlay .caller-avatar.pulse-ring::after {
    animation-delay: 0.5s;
}

@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.incoming-call-card .caller-info {
    color: white;
    margin-bottom: 2rem;
}

.incoming-call-card .call-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.incoming-call-card .caller-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.incoming-call-card .caller-number {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.incoming-call-card .call-actions {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.incoming-call-card .call-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.incoming-call-card .call-btn:hover {
    transform: scale(1.1);
}

.incoming-call-card .call-btn:active {
    transform: scale(0.95);
}

.incoming-call-card .call-btn i {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.incoming-call-card .call-btn.decline i {
    background: linear-gradient(145deg, #dc3545 0%, #c82333 100%);
}

.incoming-call-card .call-btn.answer i {
    background: linear-gradient(145deg, #28a745 0%, #218838 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.incoming-call-card .call-btn span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Global Active Call Bar */
.global-active-call-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 1100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
    height: var(--active-call-bar-height, 50px);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* iOS Safe Area for active call bar */
@supports (padding-top: env(safe-area-inset-top)) {
    .global-active-call-bar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
        height: calc(var(--active-call-bar-height, 50px) + env(safe-area-inset-top));
    }
}

/* ============================================
   GLOBAL BODY SPACING WHEN CALL IS ACTIVE
   ============================================ */

/* Define the bar height as a CSS variable */
:root {
    --active-call-bar-height: 50px;
}

/* When there's an active call, push all content down */
body.has-active-call {
    padding-top: var(--active-call-bar-height) !important;
}

/* iOS Safe Area support for body spacing */
@supports (padding-top: env(safe-area-inset-top)) {
    body.has-active-call {
        padding-top: calc(var(--active-call-bar-height) + env(safe-area-inset-top)) !important;
    }
}

/* Also adjust the main layout wrapper if present */
body.has-active-call .page,
body.has-active-call .main-content,
body.has-active-call .layout-content,
body.has-active-call main {
    /* Content should render below the bar naturally due to body padding */
}

/* Ensure fixed elements account for the bar */
body.has-active-call .sticky-top,
body.has-active-call [style*="position: fixed"][style*="top: 0"],
body.has-active-call [style*="position:fixed"][style*="top:0"] {
    top: var(--active-call-bar-height) !important;
}

@supports (top: env(safe-area-inset-top)) {
    body.has-active-call .sticky-top,
    body.has-active-call [style*="position: fixed"][style*="top: 0"],
    body.has-active-call [style*="position:fixed"][style*="top:0"] {
        top: calc(var(--active-call-bar-height) + env(safe-area-inset-top)) !important;
    }
}

.call-info-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.call-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    animation: pulse 1.5s ease-in-out infinite;
}

.call-status-indicator.connecting {
    background: #ffc107;
    animation: blink 1s infinite;
}

.call-status-indicator.ringing {
    background: #17a2b8;
}

.caller-info-compact {
    display: flex;
    flex-direction: column;
}

.caller-name-compact {
    font-weight: 600;
    font-size: 0.9rem;
}

.call-duration {
    font-size: 0.75rem;
    opacity: 0.9;
    font-variant-numeric: tabular-nums;
}

.call-controls-compact {
    display: flex;
    gap: 0.5rem;
}

.call-controls-compact .control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.call-controls-compact .control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.call-controls-compact .control-btn.active {
    background: #dc3545;
}

.call-controls-compact .control-btn.hangup {
    background: #dc3545;
}

.call-controls-compact .control-btn.hangup:hover {
    background: #c82333;
}

.call-controls-compact .control-btn.expand {
    background: rgba(255, 255, 255, 0.15);
}

/* Adjust main content when active call bar is showing */
/* NOTE: body.has-active-call already has padding-top, so .page should NOT add additional padding.
   This was causing double-padding (body padding + page padding = 218px instead of 109px).
   The body padding alone is sufficient to push content below the call bar. */
/* REMOVED: body.has-active-call .page { padding-top: ... } */

/* Ensure the expanded call panel appears above everything when shown */
.active-call-panel {
    z-index: 1090; /* Below incoming call overlay but above most content */
}
