:root {
    --fondo: #101614;
    --panel: #18211d;
    --panel-2: #212c27;
    --linea: #314039;
    --texto: #e7f0ea;
    --muted: #93a79b;
    --verde: #1fa855;
    --verde-oscuro: #0d6b40;
    --entrada: #24312b;
    --aviso: #3a3218;
    --aviso-texto: #f3d48a;
    --error: #4a2424;
    --error-texto: #ffb4b4;
    --nuevo: #e3a008;
    --atencion: #5b9bff;
    --resuelto: #3dce86;
    --sombra: 0 12px 40px rgba(0, 0, 0, .28);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--fondo);
    color: var(--texto);
    font: 15px/1.45 "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; color: inherit; }

a { color: inherit; }

code {
    font-family: Consolas, monospace;
    background: #0006;
    padding: 0 .3em;
    border-radius: 4px;
}

.app {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.topbar, .marca, .top-acciones, .item-top, .item-meta, .quien-top, .composer-row, .estados {
    display: flex;
    align-items: center;
}

.topbar {
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--linea);
    background: #141c18;
}

.marca { gap: 10px; }
.marca small, .sub, .item time, .burbuja time, .ayuda { color: var(--muted); }
.marca small { display: block; }

.logo {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--verde);
    color: #062214;
    font-weight: 700;
}

.top-acciones { gap: 10px; }
.agente { color: var(--muted); }

.chip, .pill, .folio, .no-leidos {
    border-radius: 999px;
    font-size: 12px;
}

.chip { padding: 4px 10px; }
.chip.ok { background: #123c28; color: #8ee0b2; }
.chip.warn { background: var(--aviso); color: var(--aviso-texto); }

.btn-texto, .btn-principal, .pill, .volver {
    border: 0;
    cursor: pointer;
    background: transparent;
}

.btn-texto { color: var(--muted); padding: 6px 8px; }
.btn-texto:hover { color: var(--texto); }

.btn-principal {
    background: var(--verde);
    color: #062214;
    font-weight: 700;
    border-radius: 10px;
    padding: 10px 16px;
}
.btn-principal:disabled { opacity: .6; cursor: wait; }

.banner, .aviso {
    margin: 0;
    padding: 8px 16px;
    background: var(--aviso);
    color: var(--aviso-texto);
}
.aviso.error, .aviso.error.oculto { background: var(--error); color: var(--error-texto); }

.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.col-lista, .col-chat {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.col-lista { border-right: 1px solid var(--linea); background: var(--panel); }

.buscar { padding: 12px; }
.buscar input, .tarjeta-login input, textarea {
    width: 100%;
    border: 1px solid var(--linea);
    background: var(--fondo);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}
.buscar input:focus, .tarjeta-login input:focus, textarea:focus { border-color: var(--verde); }

#lista { overflow: auto; min-height: 0; }

.filtros {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 12px 10px;
}
.filtros a { text-align: center; }
.filtros a {
    text-decoration: none;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--panel-2);
}
.filtros a.activo { color: var(--texto); background: #2d473a; }
.filtros span { opacity: .8; }

.item {
    display: block;
    text-decoration: none;
    padding: 12px 14px;
    border-bottom: 1px solid var(--linea);
}
.item:hover, .item.activa { background: #223029; }
.item-top, .item-meta { justify-content: space-between; gap: 8px; }
.item-meta { margin-top: 4px; justify-content: flex-start; }
.item p {
    margin: 6px 0 0;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item time { font-size: 12px; }

.folio {
    padding: 2px 8px;
    background: #101614;
    color: var(--muted);
}

.pill { padding: 4px 8px; background: #101614; color: var(--muted); }
.pill.nuevo { color: var(--nuevo); }
.pill.atencion { color: var(--atencion); }
.pill.resuelto { color: var(--resuelto); }
.pill.activo { outline: 1px solid currentColor; }

.no-leidos {
    margin-left: auto;
    min-width: 20px;
    text-align: center;
    padding: 1px 6px;
    background: var(--verde);
    color: #062214;
    font-weight: 700;
}

.lista-vacia { color: var(--muted); padding: 18px; margin: 0; }

.vacio, .chat-panel { min-height: 0; }
.vacio {
    margin: auto;
    max-width: 420px;
    text-align: center;
    color: var(--muted);
    padding: 24px;
}
.vacio h2 { color: var(--texto); font-weight: 600; }

.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chat-cuerpo {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.chat-cabeza {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--linea);
}
.quien { min-width: 0; }
.quien-top { gap: 8px; flex-wrap: wrap; }
.sub { font-size: 13px; }
.estados { margin-left: auto; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.estados form { margin: 0; }
.volver {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--panel-2);
    display: none;
}

.mensajes {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background:
        radial-gradient(circle at top left, #1a2a22, transparent 40%),
        var(--fondo);
}

.burbuja {
    max-width: min(680px, 85%);
    padding: 8px 10px 4px;
    border-radius: 12px;
    background: var(--entrada);
}
.burbuja.salida { align-self: flex-end; background: var(--verde-oscuro); }
.burbuja.entrada { align-self: flex-start; }
.burbuja p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.burbuja time {
    display: block;
    text-align: right;
    font-size: 11px;
    margin-top: 4px;
}
.burbuja img, .burbuja video { max-width: 280px; border-radius: 8px; display: block; }
.burbuja audio { width: 240px; }
.archivo { color: #b7f0cf; }
.ticks.read { color: #8fd4ff; }
.ticks.failed { color: #ffb4b4; }

#composer { padding: 12px; border-top: 1px solid var(--linea); background: var(--panel); }
#composer .aviso { border-radius: 8px; margin-bottom: 8px; }
.composer-row { gap: 8px; align-items: flex-end; }
textarea { resize: vertical; min-height: 52px; max-height: 140px; }

.oculto { display: none !important; }

.pagina-login {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}
.tarjeta-login {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--linea);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--sombra);
}
.tarjeta-login h1 { font-size: 22px; margin: 18px 0 4px; }
.tarjeta-login form { display: grid; gap: 12px; margin-top: 18px; }
.tarjeta-login label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.tarjeta-login .btn-principal { margin-top: 4px; }

@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; }
    .col-chat { display: none; }
    .workspace.con-chat .col-lista { display: none; }
    .workspace.con-chat .col-chat { display: flex; }
    .volver { display: inline-grid; place-items: center; }
    .topbar { align-items: flex-start; }
    .estados { width: 100%; margin-left: 0; }
    .chat-cabeza { flex-wrap: wrap; }
    .burbuja { max-width: 92%; }
}
