/* ============================================================
   WebPhone · Centralita Empresarial — Hoja de estilos
   Paleta Servitux: oro #EFB634 · azul #1E73BE · blanco corporativo
   ============================================================ */

:root {
    --bg-primary: #F5F6F8;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-chip: #EDF0F3;
    --accent: #EFB634;
    --accent-hover: #D4A01E;
    --accent-dim: #F5E6C8;
    --accent-blue: #1E73BE;
    --accent-blue-hover: #165E9A;
    --danger: #DC3545;
    --danger-hover: #C82333;
    --warning: #EFB634;
    --info: #1E73BE;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #888888;
    --border: #E1E4E8;
    --border-light: #D1D5DB;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.18);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    background:
        radial-gradient(circle at 15% 15%, rgba(0, 168, 132, 0.12), transparent 35%),
        radial-gradient(circle at 80% 10%, rgba(52, 152, 219, 0.12), transparent 36%),
        var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.phone-app {
    display: flex;
    width: 1120px;
    max-width: 98vw;
    height: 720px;
    max-height: 98vh;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow), 0 0 0 1px var(--border);
    overflow: hidden;
}

.phone-panel {
    flex: 1 1 62%;
    display: flex;
    flex-direction: column;
    padding: 26px 28px;
    gap: 14px;
    background: linear-gradient(180deg, #FFFFFF 0%, #FAFBFD 100%);
    border-right: 1px solid var(--border);
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* El contenedor era un cuadrado de 48x48 con degradado dorado, pensado para
   el emoji 📞. Con un logo apaisado (1930x380, ratio 5:1) la imagen se salia
   del cuadro y pisaba el texto. Ahora el ancho se adapta al contenido y el
   fondo solo se pinta si NO hay imagen dentro. */
.brand-logo {
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

/* Sin <img>: se mantiene el cuadrado dorado del diseño original. */
.brand-logo:not(:has(img)) {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #EFB634 0%, #D4A01E 100%);
    box-shadow: 0 3px 10px rgba(239, 182, 52, 0.35);
}

/* Con logo: la imagen manda el ancho, limitada para no comerse la cabecera.
   object-fit: contain evita cualquier deformacion sea cual sea el ratio. */
.brand-logo img {
    height: 100%;
    width: auto;
    max-width: 190px;
    object-fit: contain;
    display: block;
}

.brand-info { flex: 1; }

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #333;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.3px;
}

.brand-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

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

.brand-status .dot.connected {
    background: #22C55E;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.display-area {
    background: #F8FAFD;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 88px;
}

.display-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 2px;
    font-weight: 600;
}

.display-number {
    font-size: 27px;
    font-weight: 400;
    letter-spacing: 2px;
    min-height: 36px;
    word-break: break-all;
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: #222;
}

.display-status {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition);
}

.display-status.active { color: #22C55E; font-weight: 600; }

.display-status.ringing { color: #EFB634; animation: pulse 1.2s infinite; font-weight: 600; }

.display-status.ended { color: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Aviso de que, en llamada, el teclado envia tonos DTMF en vez de marcar.
   Oculto por defecto; lo muestra la UI con la clase .en-llamada. */
.dtmf-hint {
    display: none;
    margin-bottom: 8px;
    padding: 5px 10px;
    border-radius: 12px;
    background: #EEF4FB;
    border: 1px solid #C5D9EC;
    color: #1A5F9E;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-align: center;
}

.dial-pad-wrapper.en-llamada .dtmf-hint { display: block; }

.dial-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}

.dial-key {
    aspect-ratio: 2.15 / 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FAFBFD;
    color: #444;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.dial-key:hover {
    background: #F0F3F7;
    border-color: #C5CAD3;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.dial-key:active {
    background: #F5E6C8;
    border-color: #EFB634;
    transform: scale(0.97);
}

.dial-key .digit {
    font-size: 18px;
    font-weight: 600;
}

.dial-key .letters {
    font-size: 8px;
    color: var(--text-muted);
    letter-spacing: 1.4px;
}

.action-bar {
    display: grid;
    /* 6 columnas: la sexta es DND, movido aqui desde .feature-bar. */
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FAFBFD;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.action-btn:hover {
    background: #F0F3F7;
    border-color: #C5CAD3;
    color: var(--text-primary);
}

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

.action-btn .btn-icon {
    font-size: 19px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 20px;
}

/* Iconos SVG: fill currentColor para que hereden el color del boton, incluido
   el gris del estado :disabled. Los emojis no lo hacian (se quedaban a todo
   color) y ademas se dibujan distinto en cada sistema operativo. */
.action-btn .btn-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

/* Pares de iconos que alternan segun el estado del boton. Se controlan por
   clase (.held / .muted) en vez de reescribir el contenido desde JS. */
.action-btn .btn-icon svg.ico-play,
.action-btn .btn-icon svg.ico-mic-off { display: none; }
.action-btn.btn-hold.held .btn-icon svg.ico-pause { display: none; }
.action-btn.btn-hold.held .btn-icon svg.ico-play { display: block; }
.action-btn.btn-mute.muted .btn-icon svg.ico-mic { display: none; }
.action-btn.btn-mute.muted .btn-icon svg.ico-mic-off { display: block; }

.action-btn.btn-call { color: #15803D; }

.action-btn.btn-call:hover { background: #E8F8EE; border-color: #22C55E; }

.action-btn.btn-transfer { color: var(--accent-blue); }

.action-btn.btn-transfer:hover { background: #E8F2FA; border-color: var(--accent-blue); }

.action-btn.btn-hold { color: #A16207; }

.action-btn.btn-hold:hover { background: #FEF9EE; border-color: #EFB634; }

.action-btn.btn-hold.held { color: var(--danger); }

.action-btn.btn-hold.held:hover { background: #FEF0F0; border-color: var(--danger); }

.action-btn.btn-mute { color: #1D6FA5; }

.action-btn.btn-mute:hover { background: #EEF4FB; border-color: #5B9BD5; }

.action-btn.btn-mute.muted { color: #DC3545; border-color: #F0C0C5; background: #FEF5F5; }

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

.action-btn.btn-hangup:hover { background: #FEF0F0; border-color: var(--danger); }

/* Deshabilitado: gris explicito en lugar de opacity 0.35.
   Con opacidad, el texto de color quedaba en ~1.8:1 de contraste (ilegible) y
   los emojis seguian a todo color mientras la etiqueta se apagaba. Forzando
   color e imponiendo grayscale al icono, el boton se lee y se ve inactivo. */
.action-btn:disabled {
    color: #7D8794;
    background: #F4F6F9;
    border-color: #E6E9EF;
    box-shadow: none;
    cursor: not-allowed;
    pointer-events: none;
}

/* Con SVG en currentColor el icono ya toma el gris del boton; el grayscale
   solo sigue haciendo falta para los emojis que quedan fuera de esta barra. */
.action-btn:disabled .btn-icon {
    opacity: 0.9;
}

.session-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #F8FAFD;
}

.session-timer-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.session-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.session-timer {
    font-size: 20px;
    color: #22C55E;
    letter-spacing: 1px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.session-metrics {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
}

/* Oculta: DND se movio a .action-bar. */
.feature-bar { display: none; }

.forward-group {
    display: flex;
    gap: 8px;
}

.forward-group input {
    width: 100%;
    min-width: 150px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #FAFBFD;
    color: var(--text-primary);
    font-size: 12px;
    padding: 7px 12px;
    outline: none;
    transition: border-color var(--transition);
}

.forward-group input:focus {
    border-color: var(--accent-blue);
}

.connection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.conn-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-actions {
    display: flex;
    gap: 8px;
}

/* min-height 36px + padding: sube el objetivo tactil de 25px, que quedaba
   muy por debajo del minimo comodo (~44px) en pantallas tactiles. */
.btn-small {
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    cursor: pointer;
    transition: all var(--transition);
}

/* Conectar y Desconectar se deshabilitan segun el estado del registro. */
.btn-small:disabled {
    color: #A8B0BC;
    border-color: #E6E9EF;
    background: #F4F6F9;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-small:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: #F5F6F8;
}

.btn-small.btn-connect { border-color: #C5E0B3; color: #22C55E; }

.btn-small.btn-connect:hover { background: #EDF8E8; }

.btn-small.btn-disconnect { border-color: #F0C0C5; color: var(--danger); }

.btn-small.btn-disconnect:hover { background: #FEF5F5; }

.btn-small.btn-dnd { border-color: #F5E6C8; color: #C5971A; }

.btn-small.btn-dnd.active { background: #FEF9EE; border-color: #EFB634; color: #B3880D; }

.btn-small.btn-forward { border-color: #C5D9EC; color: var(--accent-blue); }

.btn-small.btn-forward:hover { background: #EDF4FA; }

.btn-small.btn-hotkeys { border-color: #D5D0EE; color: #6B5FAA; }

.btn-small.btn-hotkeys:hover { background: #F4F2FB; }

.btn-small.btn-actions { border-color: #CFE0DA; color: #2F7D68; }

.btn-small.btn-actions:hover { background: #EFF7F4; }

.btn-small.btn-clear-history {
    width: 100%;
    margin-top: 8px;
    border-color: #F0C0C5;
    color: #C0392B;
}

.btn-small.btn-clear-history:hover { background: #FEF5F5; }

.blf-panel {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    background: #F8FAFD;
    overflow: hidden;
    border-left: 1px solid var(--border);
}

.blf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.blf-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.blf-subtitle {
    font-size: 9px;
    background: var(--bg-chip);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.blf-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.blf-tab {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 7px 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.blf-tab:hover {
    border-color: var(--border-light);
    color: var(--text-secondary);
}

.blf-tab.active {
    background: #FFF8E7;
    border-color: #EFB634;
    color: #B3880D;
}

.blf-tab-panels {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.blf-tab-panel {
    display: none;
    height: 100%;
    padding: 10px 12px;
}

.blf-tab-panel.active {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.blf-list,
.favorites-list,
.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}

.blf-list::-webkit-scrollbar,
.favorites-list::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 4px;
}

.blf-list::-webkit-scrollbar-thumb,
.favorites-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 4px;
}

.blf-button,
.favorite-item,
.history-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    transition: all var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.blf-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    cursor: pointer;
}

.blf-button:hover {
    background: #F5F7FA;
    border-color: #C5CAD3;
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.blf-led {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #C5CAD3;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.blf-led.led-idle {
    background: #22C55E;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.45), 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.blf-led.led-busy {
    background: #EF4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.45), 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.blf-led.led-ringing {
    background: #EF4444;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.6), 0 0 0 3px rgba(0, 0, 0, 0.06);
    animation: blf-blink 0.6s ease-in-out infinite;
}

.blf-led.led-unavailable {
    background: #9CA3AF;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.blf-led.led-unknown {
    background: #C5CAD3;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

@keyframes blf-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.15; }
}

.blf-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.blf-ext {
    font-size: 15px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: #333;
}

.blf-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.blf-call-icon,
.mini-call,
.mini-delete {
    /* 36px en vez de 28: es el boton de llamar de cada extension, uno de los
       mas pulsados, y 28px es incomodo de acertar con el dedo. */
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #F5E6C8;
    background: transparent;
    color: #EFB634;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.blf-call-icon svg,
.mini-call svg,
.mini-delete svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}

.blf-call-icon:hover,
.mini-call:hover {
    background: #EFB634;
    color: #fff;
}

/* Variante de borrar: hereda tamaño y forma del bloque agrupado de arriba
   (.blf-call-icon, .mini-call, .mini-delete) y solo cambia los colores.
   No es un duplicado: para cambiar el tamaño hay que editar ese bloque. */
.mini-delete {
    border-color: #F0C0C5;
    color: #DC3545;
}

.mini-delete:hover {
    background: #FEF0F0;
}

.favorites-form {
    display: grid;
    /* minmax(0, 1fr) en lugar de 1fr: un <input> tiene ancho intrinseco
       por defecto (~20 caracteres) y 1fr equivale a minmax(auto, 1fr),
       que no baja de ese minimo. Por eso el grid desbordaba a la derecha. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.favorites-form input {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #FAFBFD;
    color: var(--text-primary);
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    /* Sin box-sizing, padding y borde suman al ancho y vuelve a desbordar. */
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

.favorites-form input:focus {
    border-color: var(--accent-blue);
}

/* El boton se dimensiona por contenido (columna 'auto'); evitamos que
   "Guardar" se parta en dos lineas cuando el panel se estrecha. */
.favorites-form .btn-small {
    white-space: nowrap;
    padding: 8px 12px;
}

.favorite-item {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.favorite-main {
    flex: 1;
    min-width: 0;
}

.favorite-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

.favorite-number {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Lo comun (borde, fondo, sombra) esta en el bloque agrupado con
   .blf-button y .favorite-item; aqui solo va lo propio del historial. */
.history-item {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-main {
    flex: 1;
    min-width: 0;
}

.history-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.history-number {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.history-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 3px;
}

.history-status {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-secondary);
    background: #EDF0F3;
    border: 1px solid #D5DAE0;
    border-radius: 12px;
    padding: 2px 7px;
}

.history-duration {
    font-size: 10px;
    color: var(--text-muted);
}

.status-finalizada .history-status { color: #1E7E34; border-color: #B7DFC5; background: #E8F8EE; }

.status-transferida .history-status { color: #1E73BE; border-color: #B7D2EC; background: #E8F2FA; }

.status-rechazada .history-status,
.status-dnd .history-status { color: #C0392B; border-color: #F0C0C5; background: #FEF0F0; }

.status-perdida .history-status,
.status-no-contesta .history-status { color: #C0911A; border-color: #F5E6C8; background: #FEF9EE; }

.history-empty,
.favorites-empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

.blf-footer {
    padding: 11px 14px;
    border-top: 1px solid var(--border);
}

.blf-footer-text {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.2s ease;
}

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

.modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 36px;
    text-align: center;
    min-width: 360px;
    max-width: 92vw;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: pulse 1.2s infinite;
}

.modal-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal-caller-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #333;
}

.modal-caller-number {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    margin-bottom: 28px;
}

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

.modal-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid;
    letter-spacing: 0.5px;
}

.modal-btn span { font-size: 16px; }

.modal-btn-reject {
    background: transparent;
    color: var(--danger);
    border-color: #F0C0C5;
}

.modal-btn-reject:hover {
    background: #FEF0F0;
    border-color: var(--danger);
}

.modal-btn-accept {
    background: #22C55E;
    color: #fff;
    border-color: #22C55E;
}

.modal-btn-accept:hover {
    background: #1DA84E;
    border-color: #1DA84E;
}

.actions-dialog {
    max-width: 420px;
}

/* Unico modal con texto corrido: el resto son formularios o avisos de una
   linea, por eso .modal-dialog no traia estilo de parrafo. */
.modal-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 24px;
    text-align: left;
}

.hotkeys-dialog {
    width: 420px;
}

.hotkeys-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.hotkey-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.hotkey-row input {
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #FAFBFD;
    color: var(--text-primary);
    font-size: 12px;
    padding: 8px 10px;
    text-align: center;
    cursor: pointer;
}

.hotkey-row input:focus {
    border-color: #EFB634;
    outline: none;
}

.legacy-bridge {
    display: none;
}

@media (max-width: 1100px) {
    .phone-app {
        width: 98vw;
        height: 96vh;
    }

    .blf-panel {
        flex-basis: 320px;
    }

    .favorites-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    /* El diseno de escritorio son dos columnas de 1120x720 con altura fija y
       overflow:hidden. Aqui se apilan en vertical, con lo que el contenido pasa
       a necesitar el doble de alto: hay que soltar la altura y dejar que la
       pagina haga scroll, o se recorta sin posibilidad de desplazarse. */
    .phone-app {
        flex-direction: column;
        width: 100vw;
        height: auto;
        min-height: 100vh;
        max-height: none;
        overflow: visible;
        border-radius: 0;
    }

    /* Centrado vertical con contenido mas alto que la pantalla: descuadra el
       inicio de la pagina. */
    body {
        align-items: flex-start;
        min-height: 0;
    }

    .phone-panel {
        flex: 0 0 auto;
        padding: 16px;
    }

    .blf-panel {
        flex: 0 0 auto;
        max-height: none;
        border-top: 1px solid var(--border);
        border-left: none;
    }

    .feature-bar {
        grid-template-columns: 1fr;
    }

    .forward-group {
        display: grid;
        grid-template-columns: 1fr auto;
    }

    .action-bar {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .session-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .session-metrics {
        text-align: left;
    }
}

@media (max-width: 560px) {
    .action-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    /* La marca es una fila flex de una linea: con el logo apaisado, el titulo y
       la pastilla de estado no cabe en 375px y la pastilla se salia por la
       derecha. Al envolver, el estado baja a su propia linea. */
    .brand-area {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* El subtitulo va en versalitas con letter-spacing y no parte en dos
       lineas: pedia 118px dentro de una caja de 81px. El logo, con
       flex-shrink:0, no cedia ancho. Se limita el logo y se deja partir. */
    .brand-info {
        min-width: 0;
        flex: 1 1 auto;
    }

    .brand-logo {
        max-width: 45vw;
    }

    .brand-logo img {
        max-width: 100%;
        height: auto;
    }

    .brand-subtitle {
        letter-spacing: 0.6px;
        overflow-wrap: break-word;
    }

    .brand-status {
        margin-left: auto;
    }

    .connection-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Cinco controles (Conectar, Desconectar, Salir, Atajos, Acciones) no caben
       en una fila: con flex:1 y sin envolver se desbordaban. En rejilla de dos
       columnas quedan legibles y con area tactil suficiente. El de Salir va
       envuelto en un <form>, de ahi que este selector sea descendiente. */
    .connection-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .connection-actions .btn-small {
        flex: initial;
        width: 100%;
    }

    /* min-width 300px + padding lateral sumaba 336px y desbordaba a 320px de
       ancho, aun con el modal oculto. */
    .modal-overlay {
        padding: 16px;
    }

    .modal-dialog {
        min-width: 0;
        width: 100%;
        padding: 24px 18px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .hotkey-row {
        grid-template-columns: 1fr;
        text-align: left;
    }

}

/* Modal de transferencia */
.transfer-input {
    width: 100%;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #FAFBFD;
    color: var(--text-primary);
    font-size: 18px;
    padding: 12px 16px;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    letter-spacing: 2px;
    outline: none;
    margin-bottom: 20px;
    transition: border-color var(--transition);
}

.transfer-input:focus {
    border-color: #EFB634;
    box-shadow: 0 0 0 3px rgba(239, 182, 52, 0.15);
}

/* Selector de tipo de transferencia */
.transfer-type-group {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    justify-content: center;
}

.transfer-type-btn {
    flex: 1;
    max-width: 140px;
    padding: 9px 14px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.transfer-type-btn.active {
    border-color: var(--accent);
    background: #FFF9ED;
    color: var(--accent);
}

.transfer-type-btn:hover:not(.active) {
    border-color: var(--border-light);
    background: #FAFBFD;
}

/* Barra de consulta (transferencia con consulta) */
.consultation-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFF3D6;
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    margin: 0 28px;
    animation: consultationSlideIn 0.3s ease;
}

@keyframes consultationSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.consultation-label {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.consultation-label strong {
    color: var(--accent-blue);
    font-weight: 700;
}

.consultation-actions {
    display: flex;
    gap: 8px;
}

.consultation-btn {
    padding: 8px 14px;
    border-radius: 18px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.consultation-btn-complete {
    background: var(--accent);
    color: #fff;
}

.consultation-btn-complete:hover {
    background: var(--accent-hover);
}

.consultation-btn-cancel {
    background: #fff;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.consultation-btn-cancel:hover {
    background: var(--danger);
    color: #fff;
}

/* Botón de configuración */
.btn-small.btn-config {
    border-color: #C5CAD3;
    color: var(--text-secondary);
}

.btn-small.btn-config:hover {
    background: #F0F3F7;
    color: var(--text-primary);
}

/* Modal de configuración */
.config-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    text-align: left;
}

.config-row {
    display: grid;
    /* minmax(0,1fr) y no 1fr: el minimo automatico de una columna de rejilla es
       el ancho intrinseco del input (~200px por su atributo size), que impedia
       encogerlo y desbordaba el modal en pantallas estrechas. */
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.config-row input {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #FAFBFD;
    color: var(--text-primary);
    font-size: 13px;
    padding: 9px 12px;
    outline: none;
    transition: border-color var(--transition);
}

.config-row input:focus {
    border-color: #EFB634;
    box-shadow: 0 0 0 3px rgba(239, 182, 52, 0.12);
}

.action-btn.btn-dnd { color: #8A6A0D; }

.action-btn.btn-dnd:hover { background: #FEF9EE; border-color: #EFB634; }

.action-btn.btn-dnd.active { color: #B3880D; background: #FEF9EE; border-color: #EFB634; }

/* Overlay DND sobre el teclado */
.dial-pad-wrapper {
    position: relative;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}

.dnd-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(3px);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    gap: 8px;
    pointer-events: none;
}

.dnd-overlay-icon {
    font-size: 56px;
    line-height: 1;
    animation: pulse 1.5s infinite;
}

.dnd-overlay-text {
    font-size: 13px;
    font-weight: 800;
    color: #B3880D;
    /* letter-spacing reducido y ancho acotado: el texto es de dos lineas y
       con 3px de espaciado desbordaba el ancho del teclado. */
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.5;
    max-width: 90%;
}

/* El media query de 560px vive antes de .config-row en este fichero, asi que
   con la misma especificidad ganaba la regla base. Va al final para que la
   cascada lo respete: a 320px no caben 110px de etiqueta mas un campo usable
   en la misma fila, la etiqueta pasa encima del campo. */
@media (max-width: 560px) {
    .config-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Aviso de auriculares. Se inserta al final del fichero por lo mismo que la
   regla de .config-row: los @media de este CSS estan a mitad de archivo y una
   regla posterior con la misma especificidad los anularia. */
.headset-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #EEF4FB;
    border: 1px solid #C5D9EC;
    color: #1A5F9E;
    font-size: 12px;
    line-height: 1.4;
}

/* [hidden] necesita ganar al display:flex de arriba. */
.headset-hint[hidden] {
    display: none;
}

.headset-hint-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.headset-hint-text {
    flex: 1 1 auto;
    min-width: 0;
}

.headset-hint-close {
    flex-shrink: 0;
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid #C5D9EC;
    border-radius: 16px;
    background: var(--bg-secondary);
    color: #1A5F9E;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.headset-hint-close:hover {
    background: #E3EDF7;
    border-color: #1E73BE;
}

@media (max-width: 560px) {
    /* En vertical el texto necesita el ancho completo; el boton baja debajo. */
    .headset-hint {
        flex-wrap: wrap;
    }

    .headset-hint-close {
        margin-left: auto;
    }
}

/* ============================================================
   Pantalla de acceso (login.php)
   ============================================================ */

.login-body {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
    text-align: center;
}

.login-logo {
    height: 40px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 18px;
}

.login-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 22px;
}

.login-error {
    background: #FEF5F5;
    border: 1px solid #F0C0C5;
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 18px;
    text-align: left;
}

.login-row {
    display: block;
    text-align: left;
    margin-bottom: 16px;
}

.login-row span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-row input {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    /* 16px evita que Safari en iOS haga zoom al enfocar el campo. */
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: #FAFBFD;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 11px 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-row input:focus {
    border-color: #EFB634;
    box-shadow: 0 0 0 3px rgba(239, 182, 52, 0.12);
}

.login-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 4px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #EFB634 0%, #D4A01E 100%);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: filter var(--transition);
}

.login-submit:hover { filter: brightness(1.06); }

.login-submit:active { transform: scale(0.99); }

.login-foot {
    margin-top: 18px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Salir de la sesion. Va en un <form> por POST (con GET, cualquier web ajena
   podia cerrar la sesion y cortar la llamada). El form es una celda mas de la
   barra, y el boton ha de ocuparla por completo. */
.logout-form {
    display: flex;
    margin: 0;
}

.btn-small.btn-logout {
    width: 100%;
    border-color: #F0C0C5;
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-small.btn-logout:hover { background: #FEF5F5; }
