/* *astTECS WebRTC Widget */
:root {
    --brand-primary: #800080;
    --brand-secondary: #9333ea;
    --brand-light: #f3e8ff;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 16px;
    --shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    --transition: 0.25s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body.webrtc-widget-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(145deg, #faf5ff 0%, #f3e8ff 100%);
    color: var(--text-primary);
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

.webrtc-widget {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.webrtc-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.webrtc-header {
    background: var(--brand-primary);
    padding: 0.875rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.webrtc-header img {
    width: 100%;
    max-width: 280px;
    height: auto;
    max-height: 56px;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
}

.webrtc-body {
    padding: 1.75rem 1.5rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.webrtc-status {
    width: 100%;
    margin-bottom: 1.5rem;
}

.webrtc-status-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-light);
    color: var(--brand-primary);
    font-size: 2rem;
    position: relative;
}

.webrtc-status-icon.connecting::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid var(--brand-secondary);
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.webrtc-status-icon.connected {
    background: #dcfce7;
    color: var(--success);
}

.webrtc-status-icon.ended {
    background: #f1f5f9;
    color: var(--text-secondary);
}

.webrtc-status-icon.error {
    background: #fee2e2;
    color: var(--danger);
}

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

.webrtc-status-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.35rem;
    line-height: 1.4;
}

.webrtc-status-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

#txtCallStatus {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.webrtc-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: auto;
    padding-top: 1rem;
}

.webrtc-btn {
    border: none;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
}

.webrtc-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(128, 0, 128, 0.35);
}

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

.webrtc-btn-call {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
    color: #fff;
    font-size: 1.75rem;
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.35);
}

.webrtc-btn-call .webrtc-btn-call-icon {
    font-size: 1.625rem;
    line-height: 1;
    display: block;
    transform: rotate(90deg);
    transform-origin: center center;
    margin-left: 2px;
}

.webrtc-btn-call:hover {
    box-shadow: 0 12px 28px rgba(22, 163, 74, 0.45);
}

.webrtc-btn-hangup {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.35);
}

.webrtc-btn-secondary {
    width: 48px;
    height: 48px;
    background: var(--surface-muted);
    color: var(--text-primary);
    border: 1px solid #e2e8f0;
    font-size: 1.125rem;
}

.webrtc-btn-secondary:hover {
    background: #f1f5f9;
}

.webrtc-btn-secondary.active {
    background: #fef3c7;
    color: var(--warning);
    border-color: #fcd34d;
}

.webrtc-btn.is-hidden {
    display: none !important;
}

.webrtc-footer {
    padding: 1rem 1.5rem 1.25rem;
    text-align: center;
    border-top: 1px solid #f1f5f9;
    background: var(--surface-muted);
}

.webrtc-footer p {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.webrtc-footer a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.webrtc-footer a:hover {
    color: #6b21a8;
    text-decoration: underline;
}

.webrtc-powered {
    font-size: 0.75rem;
    color: #94a3b8;
}

.webrtc-powered a {
    color: var(--brand-primary);
    font-weight: 600;
}

.glass-panel {
    z-index: 99;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.glass-panel.is-visible {
    opacity: 1;
    visibility: visible;
}

.div-keypad {
    z-index: 100;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 260px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition), transform var(--transition);
}

.div-keypad.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.div-keypad table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 8px;
}

.div-keypad td {
    padding: 0;
}

.div-keypad .btn {
    width: 100%;
    height: 48px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: var(--surface-muted);
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s ease;
}

.div-keypad .btn:hover {
    background: #f1f5f9;
}

.div-keypad .btn:active {
    transform: scale(0.96);
}

.div-keypad .btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    margin-top: 0.25rem;
}

.div-keypad .btn-danger:hover {
    background: #b91c1c;
}

.sip-hidden-fields {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.previewvideo,
.tab-video,
.div-video {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

@media (max-width: 480px) {
    .webrtc-widget {
        max-width: 100%;
    }

    .webrtc-card {
        border-radius: 0;
        min-height: 100vh;
    }

    .webrtc-body {
        padding: 1.5rem 1.25rem 1rem;
    }
}
