:root {
    --bg-dark: #1e1e1e;
    --bg-phone: #2c2c2c;
    --primary: #4caf50;
    --danger: #f44336;
    --text: #ffffff;
    --text-muted: #aaaaaa;
    --accent: #2196f3;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    margin: 0;
}

.log-actions {
    display: flex;
    margin: 20px 0;
    justify-content: center;
}

.main-container {
    display: flex;
    margin: 3% 3%;
    justify-content: center;
    gap: 15px;
    align-items: stretch;
}

.softphone,
.log-panel {
    height: 100%;
}

/* --- SOFTPHONE UI --- */
.softphone {
    background-color: var(--bg-phone);
    width: 380px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.screen {
    text-align: center;
    margin-bottom: 10px;
}

.status {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-bottom: 10px;
}

.number-display {
    display: flex;
    align-items: center;
    background: #3a3a3a;
    border-radius: 10px;
    padding: 5px 10px;
}

#num-display {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5em;
    width: 100%;
    text-align: center;
    outline: none;
}

.btn-backspace {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.timer {
    font-size: 1.2em;
    color: var(--primary);
    margin-top: 5px;
    visibility: hidden;
}

/* Grid de Botones Acciones */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
    opacity: 0.5;
    pointer-events: none;
    /* Desactivado si no hay llamada */
}

.actions-grid.active {
    opacity: 1;
    pointer-events: all;
}

.actions-grid button {
    background: linear-gradient(145deg, #3e3e3e, #333);
    /* Degradado sutil */
    border: 1px solid #444;
    /* Borde fino arriba para luz */
    border-bottom: none;
    /* El borde de abajo lo hace la sombra */
    color: #e0e0e0;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85em;
    cursor: pointer;
    position: relative;

    /* LA MAGIA 3D: Sombra dura abajo + Sombra difusa lejos */
    box-shadow:
        0 5px 0 #1a1a1a,
        /* El "grosor" del botón */
        0 10px 10px rgba(0, 0, 0, 0.3);
    /* La sombra en el piso */

    transition: all 0.1s ease;
    /* Animación rápida y mecánica */
}

.actions-grid button:hover {
    background: linear-gradient(145deg, #4a4a4a, #3e3e3e);
    transform: translateY(-1px);
    /* Se levanta un pelito al pasar el mouse */
}

.actions-grid button:active,
.actions-grid button.active-state {
    /* AL PRESIONAR: Quitamos la sombra dura y bajamos el botón */
    box-shadow:
        0 0 0 #1a1a1a,
        inset 0 3px 5px rgba(0, 0, 0, 0.5);
    /* Sombra interna para hundirse */
    transform: translateY(5px);
    /* Se mueve físicamente hacia abajo */
    border-top: 1px solid transparent;
}

/* Color especial para cuando están activos (Mute/Hold prendidos) */
.actions-grid button.active-state {
    background: linear-gradient(145deg, #2196f3, #1976d2);
    color: white;
    border-color: #1e88e5;
}

.actions-grid button i {
    font-size: 1.2em;
    margin-bottom: 5px;
}


.anonimo-svg{
    width: 16px;
    height: 16px;
}


/* Grid Teclado */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

/* 2. El Teclado Numérico (Círculos Gorditos) */
.keypad-grid button {
    background: linear-gradient(145deg, #3e3e3e, #2e2e2e);
    border: 1px solid #4a4a4a;
    border-bottom-color: #222;
    color: #fff;
    height: 60px;
    /* Un poco más grandes */
    width: 60px;
    /* Aseguramos círculo perfecto */
    margin: 0 auto;
    /* Centrados en su celda */
    border-radius: 50%;
    font-size: 1.4em;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);

    /* EFECTO 3D CIRCULAR */
    box-shadow:
        0 6px 0 #111,
        /* Grosor oscuro */
        0 12px 10px rgba(0, 0, 0, 0.4),
        /* Sombra ambiental */
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    /* Brillo superior */

    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.keypad-grid button:hover {
    background: linear-gradient(145deg, #444, #333);
    color: #fff;
    filter: brightness(1.1);
}

.keypad-grid button:active {
    /* Hundimiento satisfactorio */
    box-shadow:
        0 0 0 #111,
        inset 0 4px 10px rgba(0, 0, 0, 0.6);
    transform: translateY(6px);
    background: #222;
}

/* Botón Llamar */
.main-actions {
    display: flex;
    justify-content: center;
}

/* 3. Botón de Llamar (El Jefe) */
.btn-call {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    font-size: 1.8em;
    color: white;
    cursor: pointer;

    /* Gradiente Verde Moderno */
    background: linear-gradient(145deg, #66bb6a, #43a047);
    border: 1px solid #66bb6a;

    box-shadow:
        0 6px 0 #1b5e20,
        0 15px 20px rgba(76, 175, 80, 0.4),
        

       inset 0 1px 0 rgba(255, 255, 255, 0.3);
        transition: all 0.1s;
    }


   


.btn-call:hover {
    background: linear-gradient(145deg, #81c784, #4caf50);
    transform: translateY(-2px);
  /*  box-shadow: 0 8px 0 #1b5e20, 0 20px 25px rgba(76, 175, 80, 0.5);*/
}
/* 
.btn-call:active {
    box-shadow: 0 0 0 #1b5e20, inset 0 5px 10px rgba(0, 0, 0, 0.4);
    transform: translateY(6px);
}*/

/* Botón Colgar (Rojo) */
.btn-hangup {
    /* ... mismas dimensiones ... */
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    font-size: 1.8em;
    color: white;
    cursor: pointer;

    background: linear-gradient(145deg, #ef5350, #d32f2f);
    box-shadow:
        0 6px 0 #b71c1c,
        0 15px 20px rgba(244, 67, 54, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);

    transition: all 0.1s;
}

.btn-hangup:active {
    box-shadow: 0 0 0 #b71c1c, inset 0 5px 10px rgba(0, 0, 0, 0.4);
    transform: translateY(6px);
}

.btn-call {
    background: var(--primary);
}

.btn-hangup {
    background: var(--danger);
}

/* --- CONSOLA DE LOGS --- */
.log-panel {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    max-width: 600px;
    background: #111;
    border-radius: 12px;
}

.logs {
    margin: 16px;
}

.log-header {
    flex: 0 0 auto;
}

.log-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
}

/* SCROLL FINO (opcional pero recomendado) */
.log-content::-webkit-scrollbar {
    width: 6px;
}

.log-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.log-content::-webkit-scrollbar-track {
    background: transparent;
}

.log-entry {
    margin-bottom: 5px;
    border-bottom: 1px solid #222;
    padding-bottom: 2px;
}

.log-entry.info {
    color: #4caf50;
}

.log-entry.error {
    color: #f44336;
}

.log-entry.sip {
    color: #2196f3;
}

.log-entry.system {
    color: #ffd700;
}

.btn-clear {
    background: #333;
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
}

/* Modal Llamada Entrante */
.incoming-modal {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
}

.incoming-content {
    text-align: center;
}

.incoming-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.btn-answer {
    background: var(--primary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
}

.btn-reject {
    background: var(--danger);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
}


/* El input dentro del modal */
#transfer-target {
    width: 80%;
    /* Aquí está el width que faltaba */
    padding: 15px;
    font-size: 1.2em;
    text-align: center;
    border-radius: 10px;
    border: 2px solid #444;
    background-color: #333;
    color: white;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.3s;
}

#transfer-target:focus {
    border-color: var(--primary);
    /* Se pone verde al escribir */
}

.incoming-modal {
    background: rgba(0, 0, 0, 0.95);
    /* Un poco más oscuro el fondo */
    backdrop-filter: blur(5px);
    /* Efecto borroso elegante */
}


#contacts-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    background: #2c2c2c;
    margin-bottom: 0;
}

/* La lista SCROLLEABLE */
#contacts-list {
    flex: 1;
    /* Ocupa todo el espacio restante abajo */
    overflow-y: auto;
    /* Activa el scroll solo aquí */
    padding: 10px;
}

.contacts-list-container {
    flex: 1;
    overflow-y: auto;
    /* Scroll si hay muchos */
    padding-right: 5px;
}

/* Estilo del Scrollbar para que se vea "pro" */
#contacts-list::-webkit-scrollbar {
    width: 12px;
}

#contacts-list::-webkit-scrollbar-track {
    background: transparent;
}

#contacts-list::-webkit-scrollbar-thumb {
    background-color: #555;
    /* Color gris suave */
    border-radius: 10px;
    /* Redondeado */
    border: 2px solid #2c2c2c;
    /* Margen para que se vea flotando */
}

/* Items más compactos */
.contact-item {
    background: #3a3a3a;
    margin-bottom: 5px;
    /* Menos espacio entre items */
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.contact-item:hover {
    background: #444;
    border-color: #4caf50;
    /* Borde verde al pasar el mouse */
    transform: translateX(2px);
}

.contact-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.95em;
}

.contact-ext {
    font-size: 0.85em;
    color: #4caf50;
    /* Extensión en verde */
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- CONFIGURACIÓN DE AUDIO --- */

.user-actions {
    display: flex;
    gap: 10px;
    /* Espacio entre engranaje y logout */
}

.btn-settings {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1.1em;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
}

.btn-admin {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1.1em;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
}

.btn-admin:hover {
    color: #61d2ff;
    transform: scale(1.1);
}


.btn-settings:hover {
    color: var(--primary);
    /* Se pone verde al pasar el mouse */
    transform: rotate(45deg);
    /* Efecto giratorio */
}

.settings-select {
    width: 100%;
    padding: 10px 35px 10px 15px;
    /* Espacio extra a la derecha para la flecha */
    background-color: #444;
    border: 1px solid #555;
    color: white;
    border-radius: 8px;
    /* Un poco más redondo */
    margin-top: 5px;
    outline: none;
    cursor: pointer;
    font-size: 0.95em;

    /* 1. Eliminamos la flecha fea del sistema */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* 2. Ponemos una flecha blanca SVG */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;

    transition: border-color 0.3s, background-color 0.3s;
}

.settings-select:focus {
    border-color: var(--primary);
}

/* Bolita de estado */
.contact-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: gray;
    /* Offline */
}

.contact-status.online {
    background: #4caf50;
    box-shadow: 0 0 5px #4caf50;
}

.contact-status.busy {
    background: #f44336;
}

/* Barra de Navegación Inferior */
.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    background: transparent;
    padding: 10px 20px;
    margin-top: 15px;
    border: none;
    box-shadow: none;

}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #3e3e3e, #2e2e2e);
    border: 1px solid #444;
    border-radius: 15px;
    color: #888;
    padding: 12px 0;
    cursor: pointer;
    font-size: 0.9em;
    box-shadow:
        0 6px 0 #151515,
        0 10px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-btn i {
    font-size: 1.5em;
    margin-bottom: 5px;
    transition: transform 0.2s;
}

.nav-btn:hover {
    background: linear-gradient(145deg, #444, #333);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 
    0 8px 0 #151515,
    0 15px 15px rgba(0, 0, 0, 0.4);
}

.nav-btn.active {
    transform: translateY(6px);
    box-shadow: inset0 0 0 #151515,
    inset 0 3px  5px rgba(0,0,0,0.6);
    background: #222;
    color: #2196f3;
    border-color: #1e88e5;
}

.nav-btn.active i {
    text-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
}

/* Azul activo */


/* Animación de Grabación */
@keyframes pulse-red {
    0% {
        background-color: #3a3a3a;
    }

    50% {
        background-color: #d32f2f;
    }

    100% {
        background-color: #3a3a3a;
    }
}

.recording-active {
    animation: pulse-red 1.5s infinite;
    color: white !important;
    border: 1px solid #ff5252 !important;
}

.recording-active i {
    color: white;
}

.timer {
    font-size: 1.5em;
    color: var(--primary);
    margin-top: 10px;
    font-weight: bold;
    visibility: hidden;
    /* Oculto por defecto */
    font-family: 'Courier New', monospace;
    /* Para que los números no bailen */
}

/* --- BARRA DE USUARIO --- */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #ddd;
    font-weight: 500;
}

.btn-logout {
    background: transparent;
    border: none;
    color: #f44336;
    /* Rojo suave */
    cursor: pointer;
    font-size: 1.1em;
    padding: 5px;
    transition: transform 0.2s, color 0.2s;
}

.btn-logout:hover {
    color: #ff7961;
    transform: scale(1.1);
}

/* Chrome, Edge, Safari */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
    /* estándar */
}

.softphone {
    display: none;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
}

.softphone.active {
    display: flex;
}


@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        padding: 10px;
    }

    .softphone,
    .log-panel {
        width: 100%;
        max-width: 420px;
    }

    .log-panel {
        height: 40vh;
    }
}

.log-entry.error {
    color: #ff6b6b;
    background: rgba(255, 0, 0, 0.1);
    border-left: 3px solid #ff6b6b;
}

.log-entry.sip {
    color: #4ecdc4;
}

.log-entry.success {
    color: #96ceb4;
}


/* Estilos para el Teclado DTMF en llamada */
.dtmf-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
    border: 1px solid #e0e0e0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dtmf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.dtmf-grid button {
    padding: 12px;
    font-size: 1.2rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
    font-weight: bold;
}

.dtmf-grid button:active {
    background: #007bff;
    color: white;
    transform: scale(0.95);
}

.dtmf-close {
    text-align: center;
    margin-top: 10px;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px;
}

.dtmf-close:hover {
    color: #333;
    text-decoration: underline;
}

/* Estado activo para el botón principal */
#btn-dtmf.active-state {
    background: #e3f2fd;
    color: #007bff;
    border-color: #007bff;
}


/* Estilos para el Buscador de Contactos */
.header-contacts {
    flex-shrink: 0;
    /* No permitimos que se aplaste */
    padding: 10px 15px;
    background: #2c2c2c;
    border-bottom: 1px solid #444;
}

.header-contacts h3 {
    margin: 0 0 8px 0;
    color: #fff;
    font-size: 1rem;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    /* Espacio a la izq para el icono */
    border-radius: 20px;
    border: 1px solid #ddd;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 0.9rem;
}

/* --- ESTILOS PARA LOS AVATARES (FOTOS) --- */

/* 1. Avatar de TU PERFIL (Barra superior) */
.avatar-circle {
    width: 35px !important;
    /* Forzamos el tamaño pequeño */
    height: 35px !important;
    border-radius: 50%;
    /* Redondo */
    object-fit: cover;
    /* Recorta si no es cuadrada */
    border: 2px solid #555;
    margin-right: 10px;
    flex-shrink: 0;
    /* Evita que se aplaste */
}

/* 2. Avatar de la LISTA DE CONTACTOS */
.contact-avatar-small {
    width: 40px !important;
    /* Un poco más grande en la lista */
    height: 40px !important;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    border: 2px solid #4caf50;
    /* Borde verde */
    flex-shrink: 0;
    /* Evita que se aplaste */
}

/* 3. Icono por defecto (cuando no hay foto) en Contactos */
.contact-icon-default {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #444;
    border-radius: 50%;
    margin-right: 12px;
    color: #aaa;
    font-size: 1.2em;
    flex-shrink: 0;
}

/* Ocultar las trazas en la pantalla para no molestar al usuario */
.log-entry.sip-trace {
    display: none;
}


@media (max-width: 768px) {
    .softphone {
        height: auto;
        /* que crezca según el contenido */
        max-height: none;
        /* elimina cualquier límite */
        min-height: 100vh;
        /* al menos toda la pantalla */
        overflow: visible;
        /* que no corte contenido */
    }
}