/* Teléfono reutilizable (PhoneFrame + PhoneChat), estilo WhatsApp. Modo oscuro con el tema oscuro de Radzen o .pc-phone.pc-dark.
   El verde del teléfono es el verde de marca (--app-brand-green) */

.pc-phone {
    --pc-bezel: #37474f;
    --pc-header: var(--app-brand-green, #33cc33);
    --pc-header-fg: #ffffff;
    --pc-chat-bg: #efeae2;
    --pc-in: #ffffff;
    --pc-out: #e7f6e7;
    --pc-fg: #303030;
    --pc-time: #667781;
    --pc-check: #53bdeb;
    --pc-input-area: #ffffff;
    --pc-input-bg: #ffffff;
    --pc-accent: var(--app-brand-green, #33cc33);
    --pc-error: hsl(0 72% 51%);
    --pc-note-bg: #ffeecd;
    --pc-note-fg: #54656f;
    --pc-doc-bg: rgb(0 0 0 / .05);
    width: 360px;
    max-width: 100%;
    height: min(720px, 85vh);
    padding: 8px;
    border-radius: 40px;
    background-color: var(--pc-bezel);
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / .45);
}

:root:has(#radzen-theme-link[href*="-dark"]) .pc-phone,
.pc-phone.pc-dark {
    --pc-bezel: #11181c;
    --pc-header: #1f2c34;
    --pc-chat-bg: #0b141a;
    --pc-in: #202c33;
    --pc-out: #005c4b;
    --pc-fg: #e9edef;
    --pc-time: #8696a0;
    --pc-input-area: #111b21;
    --pc-input-bg: #202c33;
    --pc-error: hsl(0 85% 70%);
    --pc-note-bg: #182229;
    --pc-note-fg: #ffd279;
    --pc-doc-bg: rgb(255 255 255 / .06);
}

/* Variante más baja para diálogos con controles encima del teléfono */
.pc-phone.pc-phone-fit { height: min(720px, 70vh); }

/* Variante para páginas con cabecera (ej. TrainingPage): ocupa el alto del título más el editor (70vh) */
.pc-phone.pc-phone-page { height: clamp(420px, calc(70vh + 2.5rem), 760px); }

/* Simulador (PhoneSimulator): los botones toman el ancho del teléfono */
.pc-simulator { max-width: 360px; }

.pc-screen { position: relative; height: 100%; border-radius: 32px; overflow: hidden; display: flex; flex-direction: column; background-color: var(--pc-chat-bg); }
.pc-notch { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 104px; height: 20px; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; background-color: var(--pc-bezel); z-index: 2; }

/* Cabecera */
.pc-header { flex-shrink: 0; display: flex; align-items: center; gap: .625rem; padding: 28px 12px 10px 14px; background-color: var(--pc-header); color: var(--pc-header-fg); }

.pc-avatar { width: 36px; height: 36px; border-radius: 9999px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background-color: #ffffff; color: var(--pc-accent); font-size: 14px; font-weight: 700; }
.pc-header-text { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

/* Acciones al extremo derecho de la cabecera: el nombre se recorta con "..." antes que ocultarlas */
.pc-header-actions { flex-shrink: 0; display: flex; align-items: center; gap: .25rem; }
.pc-header .pc-header-action { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; background-color: transparent; color: var(--pc-header-fg); font-size: 17px; box-shadow: none; cursor: pointer; }
.pc-header .pc-header-action:hover,
.pc-header .pc-header-action:focus-visible { background-color: rgb(255 255 255 / .15); color: var(--pc-header-fg); }
.pc-name { font-size: 15px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-subtitle { font-size: 12px; opacity: .85; }

/* Línea de estado con ayuda (texto blanco + icono "?"); solo ocupa lo que mide el texto para que el cursor no abarque toda la fila */
.pc-header-text .pc-subtitle-hint { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; max-width: 100%; margin-top: 1px; color: #ffffff; opacity: 1; cursor: help; }
.pc-subtitle-text { min-width: 0; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-subtitle-icon.rzi { flex-shrink: 0; font-size: 13px; opacity: .9; }
.pc-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* Mensajes (column-reverse: pegado al último mensaje) */
.pc-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pc-messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; gap: .75rem; padding: 12px; }
.pc-row { display: flex; }
.pc-row.pc-out { justify-content: flex-end; }
.pc-bubble { max-width: 80%; padding: 10px 12px 6px 12px; border-radius: 10px; background-color: var(--pc-in); color: var(--pc-fg); font-size: 14px; line-height: 1.45; box-shadow: 0 1px .5px rgb(11 20 26 / .13); overflow-wrap: anywhere; }
.pc-out .pc-bubble { background-color: var(--pc-out); }
/* Pico en la esquina superior: a la derecha los mensajes enviados, a la izquierda los recibidos */
.pc-bubble { position: relative; margin-left: 8px; border-top-left-radius: 0; }
.pc-bubble::before { content: ""; position: absolute; top: 0; left: -8px; width: 8px; height: 13px; background-color: var(--pc-in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.pc-out .pc-bubble { margin-left: 0; margin-right: 8px; border-top-left-radius: 10px; border-top-right-radius: 0; }
.pc-out .pc-bubble::before { left: auto; right: -8px; background-color: var(--pc-out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.pc-text { white-space: pre-wrap; }
.pc-bubble.pc-error .pc-text { color: var(--pc-error); }
.pc-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 4px; font-size: 11px; color: var(--pc-time); }
.pc-check.rzi { color: var(--pc-check); font-size: 14px; }

/* Multimedia y documentos (el pie va debajo) */
.pc-media { display: block; max-width: 100%; height: auto; max-height: 300px; border-radius: 6px; background-color: var(--pc-doc-bg); }
.pc-audio { display: block; width: 240px; max-width: 100%; height: 40px; }
.pc-phone a.pc-doc { display: flex; align-items: center; gap: .5rem; min-width: 0; padding: 10px 12px; border-radius: 6px; background-color: var(--pc-doc-bg); color: var(--pc-fg); text-decoration: none; }
.pc-phone a.pc-doc:hover { text-decoration: underline; }
.pc-doc-icon.rzi { flex-shrink: 0; font-size: 24px; color: var(--pc-accent); }
.pc-doc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-media + .pc-text, .pc-doc + .pc-text { display: block; margin-top: 6px; }

/* Avisos del simulador (estilo mensaje de sistema de WhatsApp) */
.pc-row.pc-note-row { justify-content: center; }
.pc-note { max-width: 90%; padding: 6px 12px; border-radius: 8px; background-color: var(--pc-note-bg); color: var(--pc-note-fg); font-size: 12.5px; line-height: 1.4; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px .5px rgb(11 20 26 / .13); }

/* Escribiendo... */
@keyframes pc-typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.pc-bubble.pc-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.pc-typing > span { width: 7px; height: 7px; border-radius: 9999px; background-color: var(--pc-time); animation: pc-typing 1.2s infinite ease-in-out; }
.pc-typing > span:nth-child(2) { animation-delay: .2s; }
.pc-typing > span:nth-child(3) { animation-delay: .4s; }

/* Entrada */
.pc-input-area { flex-shrink: 0; padding: 8px 10px 12px 10px; background-color: var(--pc-input-area); }
.pc-input-box { display: block; margin: 0; cursor: text; position: relative; min-height: 96px; padding: 10px 56px 10px 12px; border: 1px solid var(--pc-accent); border-radius: 10px; background-color: var(--pc-input-bg); }
.pc-input-box:focus-within { box-shadow: 0 0 0 1px var(--pc-accent); }
.pc-phone .pc-input { display: block; width: 100%; height: auto; padding: 0; outline: none; border: 0; border-radius: 0; box-shadow: none; background-color: transparent; color: var(--pc-fg); font-size: 15px; }
.pc-phone .pc-input::placeholder { color: var(--pc-time); opacity: 1; }
.pc-phone .pc-send { position: absolute; right: 10px; bottom: 10px; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 9999px; display: flex; align-items: center; justify-content: center; background-color: var(--pc-accent); color: #ffffff; box-shadow: none; transition: opacity .15s; }
.pc-phone .pc-send:hover { opacity: .9; }
.pc-phone .pc-send:disabled { opacity: .5; cursor: not-allowed; pointer-events: auto; }
.pc-phone .pc-send .rzi { font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
    .pc-typing > span { animation: none; }
}
