/* Modern Softphone Dialer CSS */
:root {
    --bg-primary: #0b0f19;
    --bg-card: rgba(18, 24, 38, 0.85);
    --bg-card-border: rgba(255, 255, 255, 0.08);
    --bg-input: #151c2e;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.35);
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.4);
    --btn-key: rgba(255, 255, 255, 0.05);
    --btn-key-hover: rgba(255, 255, 255, 0.1);
    --btn-key-active: rgba(59, 130, 246, 0.3);
    --radius-lg: 24px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --shadow-main: 0 20px 50px -10px rgba(0, 0, 0, 0.7), 0 0 20px rgba(59, 130, 246, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0b0f19 70%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    padding: 16px;
}

.dialer-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 720px;
}

/* Header */
.dialer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--bg-card-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.brand-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.25);
}
.status-badge.error .status-dot {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

.status-badge.busy {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.25);
}
.status-badge.busy .status-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}
.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Tabs */
.tabs-nav {
    display: flex;
    padding: 8px 16px;
    gap: 6px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--bg-card-border);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn svg {
    width: 15px;
    height: 15px;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Tab Views */
.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
}
.tab-content.active {
    display: flex;
}

/* Dialpad View */
.number-input-container {
    padding: 20px 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.country-selector-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--bg-card-border);
    margin-bottom: 12px;
    cursor: pointer;
}

.country-select {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    max-width: 170px;
}
.country-select option {
    background: #111827;
    color: #f3f4f6;
}

.phone-display-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    padding: 0 10px;
}

.phone-display {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: center;
    padding: 8px 36px 8px 10px;
}

.phone-display::placeholder {
    color: var(--text-muted);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: normal;
}

.backspace-btn {
    position: absolute;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    visibility: hidden;
}
.backspace-btn.visible {
    visibility: visible;
}
.backspace-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.backspace-btn svg {
    width: 20px;
    height: 20px;
}

.caller-id-subline {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}

/* Keypad Grid */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 20px;
    padding: 10px 28px 18px;
    justify-items: center;
}

.key-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: var(--btn-key);
    border: 1px solid var(--bg-card-border);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.key-btn:hover {
    background: var(--btn-key-hover);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.15);
}

.key-btn:active {
    background: var(--btn-key-active);
    transform: scale(0.94);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.key-digit {
    font-size: 1.65rem;
    font-weight: 500;
    line-height: 1;
}

.key-sub {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Call Actions Footer */
.dialer-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px 28px;
    margin-top: auto;
}

.call-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px var(--accent-emerald-glow);
    transition: all 0.25s ease;
}

.call-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.55);
}

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

.call-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Active Call Overlay Screen */
.active-call-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(24px);
    z-index: 100;
    display: none;
    flex-direction: column;
    padding: 36px 24px 30px;
    animation: fadeIn 0.3s ease;
}

.active-call-overlay.open {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.active-call-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
}

.caller-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 0 35px rgba(59, 130, 246, 0.4);
    position: relative;
}

.caller-avatar.pulsing::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.5);
    animation: pulseRing 1.8s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

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

.caller-avatar svg {
    width: 42px;
    height: 42px;
    fill: white;
}

.active-caller-number {
    font-size: 1.55rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-align: center;
}

.active-call-status-line {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent-emerald);
    margin-bottom: 4px;
}

.active-call-timer {
    font-size: 1.15rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

/* In-call mid keypad drawer */
.incall-dtmf-container {
    display: none;
    margin: 15px auto;
    width: 100%;
}
.incall-dtmf-container.open {
    display: block;
}

.incall-dtmf-container .keypad-grid {
    padding: 0;
    gap: 8px 12px;
}
.incall-dtmf-container .key-btn {
    width: 52px;
    height: 52px;
}
.incall-dtmf-container .key-digit {
    font-size: 1.25rem;
}
.incall-dtmf-container .key-sub {
    font-size: 0.52rem;
}

/* In-call controls */
.active-call-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: auto;
    padding-bottom: 24px;
    justify-items: center;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--bg-card-border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.control-btn.active {
    background: #fff;
    color: #0b0f19;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.control-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.control-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.end-call-wrap {
    display: flex;
    justify-content: center;
    padding-bottom: 16px;
}

.end-call-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px var(--accent-red-glow);
    transition: all 0.2s ease;
}

.end-call-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.6);
}

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

.end-call-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transform: rotate(135deg);
}

/* Call History Tab */
.history-view {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.history-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: color 0.2s;
}
.clear-btn:hover {
    color: var(--accent-red);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.history-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-icon-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
}

.history-icon-badge.failed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
}
.history-icon-badge.completed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
}

.history-icon-badge svg {
    width: 16px;
    height: 16px;
}

.history-number {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.redial-btn {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.redial-btn:hover {
    background: var(--accent-emerald);
    color: white;
}
.redial-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.empty-history {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* Settings Modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: 200;
    display: none;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
    flex-direction: column;
}

.modal-card {
    background: #111827;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: auto 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
}
.form-input:focus {
    border-color: var(--accent-blue);
}

.btn-primary {
    background: var(--accent-blue);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover {
    background: #2563eb;
}

.setup-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 12px 16px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.78rem;
    color: #fcd34d;
}
.setup-banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: currentColor;
    margin-top: 1px;
}

/* Audio Device Selector */
.audio-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--bg-card-border);
}

.audio-select-wrap select {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.76rem;
    outline: none;
    width: 100%;
}
.audio-select-wrap select option {
    background: #111827;
    color: white;
}
