/* Elegant CSS Stylesheet for VOIP Phone System Simulation */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(30, 41, 59, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #10b981; /* WhatsApp Emerald */
    --primary-glow: rgba(16, 185, 129, 0.25);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --ios-blue: #007aff;
    
    --phone-width: 360px;
    --phone-height: 740px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg-dark) 60%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

header {
    margin-top: 2rem;
    margin-bottom: 1rem;
    text-align: center;
    z-index: 10;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.workspace {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3.5rem;
    padding: 1.5rem;
    width: 100%;
    max-width: 1200px;
    align-items: center;
}

/* Smartphone Mockup Container */
.phone-container {
    perspective: 1000px;
    position: relative;
}

/* Vibrating effect during incoming call */
.phone-device.vibrate-active {
    animation: phone-vibrate 0.15s linear infinite;
}

.phone-device {
    width: var(--phone-width);
    height: var(--phone-height);
    background: #0f172a;
    border-radius: 50px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 0 12px #1e293b, /* Bezel outer */
        0 0 0 13px #334155, /* Bezel inner border */
        0 0 30px rgba(16, 185, 129, 0.1);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.phone-device:hover {
    box-shadow: 
        0 25px 60px -10px rgba(0, 0, 0, 0.8),
        0 0 0 12px #1e293b,
        0 0 0 13px #334155,
        0 0 40px rgba(16, 185, 129, 0.2);
}

/* Dynamic Island / Notch */
.phone-notch {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    height: 28px;
    background: #000;
    border-radius: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 12px;
    box-shadow: inset 0 0 4px rgba(255,255,255,0.1);
}

.notch-camera {
    width: 10px;
    height: 10px;
    background: #1e293b;
    border-radius: 50%;
    box-shadow: inset 0 0 3px #000;
}

.notch-speaker {
    width: 40px;
    height: 4px;
    background: #334155;
    border-radius: 4px;
}

/* Screen Contents */
.phone-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-top: 45px;
    padding-bottom: 25px;
    background: #090d16;
}

/* Status Bar */
.phone-status-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 45px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 30px 0 30px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    z-index: 90;
    pointer-events: none;
}

.status-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-bar-icon {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

/* Phone App Navigation */
.app-tabs {
    display: flex;
    justify-content: space-around;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid var(--glass-border);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    align-items: center;
    z-index: 80;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    flex: 1;
    gap: 4px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
}

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

/* Views (Dialer, Contacts, Call History) */
.view {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: none;
    margin-bottom: 40px;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar */
.view::-webkit-scrollbar {
    width: 4px;
}
.view::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* Header Inside Phone Screens */
.phone-header {
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.phone-header h2 {
    font-size: 1.6rem;
    font-weight: 600;
}

.phone-id-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-weight: 600;
}

/* Keypad / Dialer Grid */
.dialer-screen {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 400;
    min-height: 60px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-all;
    letter-spacing: 1px;
    padding: 0 10px;
    color: var(--text-primary);
}

.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 1.2rem;
    justify-items: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.key-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.15s, transform 0.1s;
}

.key-btn:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.92);
}

.key-sub {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: -2px;
}

.call-action-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 0.5rem;
}

.btn-call {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 24px var(--primary-glow);
    transition: transform 0.2s, background-color 0.2s;
}

.btn-call:hover {
    background: #059669;
}

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

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

.btn-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.btn-delete:hover {
    color: var(--text-primary);
}

.btn-delete svg {
    width: 24px;
    height: 24px;
}

/* Contacts View */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.contact-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, background-color 0.2s;
}

.contact-card:hover {
    background: rgba(30, 41, 59, 0.65);
    border-color: rgba(16, 185, 129, 0.3);
}

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

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 1.1rem;
}

.contact-details h4 {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.contact-details p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.contact-call-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: background 0.2s, transform 0.2s;
}

.contact-call-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* Call Log View */
.log-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.log-item {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.log-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
}

.log-indicator.missed { color: var(--danger); }
.log-indicator.incoming { color: var(--primary); }
.log-indicator.outgoing { color: var(--ios-blue); }

.log-text h4 {
    font-weight: 500;
    font-size: 0.95rem;
}

.log-text p {
    color: var(--text-secondary);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.log-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: right;
}

/* Call Overlay (WhatsApp Style Calling Screen) */
.call-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #0f1e29 0%, #06090e 100%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 70px 30px 50px 30px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.call-top-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.call-status-label {
    color: var(--primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    margin-bottom: 8px;
    animation: pulse-text 1.5s infinite;
}

.call-peer-name {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.call-peer-number {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Pulse Animation for Avatar during Ringing */
.call-avatar-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 2rem 0;
}

.call-avatar-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--primary-glow);
    animation: ring-pulse 1.8s infinite;
    z-index: 1;
}

.call-avatar-pulse-2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--primary-glow);
    animation: ring-pulse 1.8s infinite 0.9s;
    z-index: 1;
}

.call-avatar {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669 0%, #1d4ed8 100%);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 3px solid rgba(255,255,255,0.1);
}

/* Audio Visualizer Canvas */
.visualizer-container {
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
}

.visualizer-canvas {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    pointer-events: none;
}

/* Calling Controls */
.call-controls-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 2rem;
}

.call-features-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 240px;
}

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

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

.feature-btn.active {
    background: white;
    color: black;
}

.action-buttons-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    width: 100%;
}

.action-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:active {
    transform: scale(0.9);
}

.btn-decline {
    background: var(--danger);
    box-shadow: 0 8px 24px var(--danger-glow);
}

.btn-decline:hover {
    background: #dc2626;
}

.btn-accept {
    background: var(--primary);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-accept:hover {
    background: #059669;
}

.btn-accept svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.btn-decline svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Home / Device Locks overlay */
.home-indicator-bar {
    width: 130px;
    height: 5px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 110;
}

/* Extra controls under the phones */
.dashboard-controls {
    text-align: center;
    margin-top: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-mic-init {
    background: var(--primary);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--primary-glow);
    transition: background 0.2s, transform 0.1s;
}

.btn-mic-init:hover {
    background: #059669;
}

.btn-mic-init:active {
    transform: scale(0.97);
}

/* Animations */
@keyframes ring-pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.65;
    }
    100% {
        transform: scale(1.55);
        opacity: 0;
    }
}

@keyframes phone-vibrate {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(0px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(2px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(2px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Standalone selector menu */
.mode-selector-wrapper {
    margin-top: 1rem;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.mode-selector-wrapper select {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mode-selector-wrapper select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Standalone UI View hiding rules */
body.view-mode-phone-a #phone-b {
    display: none !important;
}

body.view-mode-phone-b #phone-a {
    display: none !important;
}

body.view-mode-phone-a .phone-device,
body.view-mode-phone-b .phone-device {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 0 12px #1e293b,
        0 0 0 13px #334155,
        0 0 40px rgba(16, 185, 129, 0.3);
}

/* Responsive styles */
@media (max-width: 850px) {
    .workspace {
        gap: 2rem;
    }
    .phone-device {
        --phone-width: 320px;
        --phone-height: 660px;
    }
    header h1 {
        font-size: 1.8rem;
    }
}
