/**
 * AVR Softphone - Modern UI
 * Diseño inspirado en Genesys Cloud / Twilio Flex
 */

:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    
    /* Status Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    /* Neutral Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --bg-hover: #475569;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: #475569;
    --border-light: #334155;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 i {
    color: var(--primary);
}

/* Connection Status */
.status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.813rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status.calling .status-dot {
    background: var(--warning);
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { 
        opacity: 1;
        box-shadow: 0 0 8px var(--warning);
    }
    50% { 
        opacity: 0.6;
        box-shadow: 0 0 15px var(--warning);
    }
}

/* ==================== MAIN CONTAINER ==================== */
.main-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 20px;
}

/* ==================== PANELS ==================== */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ==================== LOGIN PANEL ==================== */
.login-form {
    padding: 32px;
}

.login-form h2 {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 32px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.938rem;
    font-weight: 500;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-call {
    background: var(--success);
    color: white;
    padding: 16px 48px;
    font-size: 1rem;
    border-radius: 12px;
}

.btn-call:hover:not(:disabled) {
    background: #059669;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-hangup {
    background: var(--danger);
    color: white;
    padding: 16px 48px;
    font-size: 1rem;
    border-radius: 12px;
}

.btn-hangup:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.btn-control {
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 1.125rem;
}

.btn-control:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

/* ==================== PHONE PANEL ==================== */
#phone-panel {
    padding: 24px;
}

/* Call Display */
.call-display {
    text-align: center;
    padding: 24px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 24px;
}

.call-state {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.call-timer {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}

.call-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Call Controls */
.call-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
}

/* ==================== DIALPAD ==================== */
.dialpad {
    max-width: 280px;
    margin: 0 auto 28px;
}

.dial-display {
    width: 100%;
    padding: 16px;
    font-size: 1.75rem;
    font-weight: 500;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-family: 'JetBrains Mono', monospace;
}

.dial-display::placeholder {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

.dial-display:focus {
    outline: none;
    border-color: var(--primary);
}

.dial-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.dial-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
    border: none;
    background: var(--bg-card);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.dial-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.dial-btn:active {
    transform: scale(0.95);
    background: var(--primary);
}

.dial-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ==================== CONTACTS & HISTORY ==================== */
.contacts-panel, .history-panel {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.contacts-panel h3, .history-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.contacts-list, .call-history {
    list-style: none;
}

.contact-item, .history-item {
    padding: 12px 16px;
    margin: 0 -16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.contact-item:hover, .history-item:hover {
    background: var(--bg-card);
}

.contact-name {
    font-weight: 500;
    color: var(--text-primary);
}

.contact-number {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.contact-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.contact-status.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

/* ==================== NOTIFICATIONS ==================== */
.notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.3s ease-out;
    max-width: 320px;
    font-size: 0.875rem;
}

.notification.success {
    border-left: 3px solid var(--success);
}

.notification.error {
    border-left: 3px solid var(--danger);
}

.notification.warning {
    border-left: 3px solid var(--warning);
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== CALLING ANIMATION ==================== */
.calling-animation {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.calling-animation span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.calling-animation span:nth-child(1) { animation-delay: -0.32s; }
.calling-animation span:nth-child(2) { animation-delay: -0.16s; }
.calling-animation span:nth-child(3) { animation-delay: 0; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==================== INCOMING CALL OVERLAY ==================== */
.incoming-call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.incoming-call-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.incoming-call-card .caller-avatar {
    width: 80px;
    height: 80px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-secondary);
    margin: 0 auto 20px;
}

.incoming-call-card .caller-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.incoming-call-card .caller-number {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

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

.incoming-call-card .btn-answer {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.incoming-call-card .btn-answer:hover {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
    transform: scale(1.1);
}

.incoming-call-card .btn-reject {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.incoming-call-card .btn-reject:hover {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    transform: scale(1.1);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .header {
        padding: 10px 16px;
    }
    
    .header h1 {
        font-size: 1rem;
    }
    
    .main-container {
        padding: 16px;
    }
    
    .panel {
        border-radius: 12px;
    }
    
    .login-form {
        padding: 24px;
    }
    
    #phone-panel {
        padding: 16px;
    }
    
    .dial-btn {
        font-size: 1.25rem;
    }
    
    .call-timer {
        font-size: 2rem;
    }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
