/* Ventas · Doblamos — vista de diseño
   Sobrio a propósito: bordes de 1px, sin degradados ni sombras fuertes. */

:root {
    --tinta:        #16181d;
    --tinta-media:  #4e5460;
    --tinta-suave:  #858b97;
    --linea:        #e3e5e9;
    --fondo:        #f4f5f7;
    --superficie:   #ffffff;
    --marca:        #10203f;
    --dato:         #2a78d6;
    --baja:         #d64550;
    --alza:         #1f7a52;
    --radio:        10px;

    /* Degradados de marca, al estilo de los de ASLY pero con los azules de Doblamos:
       del azul profundo del logo al azul de los datos, pasando por el intermedio. */
    --grad-marca:   linear-gradient(145deg, #0b1b33 0%, #13417f 48%, #2a8ad6 100%);
    --grad-suave:   linear-gradient(120deg, #f3f6fc 0%, #f7f9fc 58%, #f3f5f8 100%);
    --grad-enviar:  linear-gradient(135deg, #2a8ad6 0%, #14508f 100%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--fondo);
    background-image: var(--grad-suave);
    color: var(--tinta);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: transparent;
    border-left: 1px solid var(--linea);
    border-right: 1px solid var(--linea);
}

/* ---------- barra superior ---------- */

.barra {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    color: #fff;

    /* El degradado se pinta al doble de ancho y se desliza despacio: le da vida
       a la barra sin que nada se mueva en pantalla. */
    background: var(--marca);
    background-image: var(--grad-marca);
    background-size: 220% 220%;
    animation: respirar 18s ease-in-out infinite;
}

@keyframes respirar {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.barra-id { flex: 1; min-width: 0; }

.barra-logo {
    display: block;
    height: 26px;
    width: auto;
}

.barra-titulo {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: .02em;
    color: rgba(255, 255, 255, .78);
}

.barra-accion {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    cursor: pointer;
}

.barra-accion img { filter: invert(1); opacity: .85; }
.barra-accion:hover { background: rgba(255, 255, 255, .08); }

/* ---------- aviso de datos de ejemplo ---------- */

.aviso {
    flex: 0 0 auto;
    padding: 8px 16px;
    background: #fdf6e3;
    border-bottom: 1px solid #f0e4c3;
    color: #7a5c17;
    font-size: 12px;
}

/* ---------- conversación ---------- */

.lienzo {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
}

.conversacion {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Divisor del día */
.divisor {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 2px;
    color: var(--tinta-suave);
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.divisor::before,
.divisor::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--linea);
}

/* Sello de DOBI */
.sello {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--marca);
    background-image: var(--grad-marca);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.sello-grande {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 15px;
}

.intro { padding: 6px 2px 0; }

.intro-marca {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.intro-saludo {
    margin: 2px 0 2px;
    font-size: 15px;
    font-weight: 700;
    color: var(--tinta);
}

.intro-texto {
    margin: 0;
    color: var(--tinta-media);
    font-size: 14px;
}

.sugerencias {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    overflow: hidden;
}

.sugerencias li + li { border-top: 1px solid var(--linea); }

.sugerencias button {
    width: 100%;
    text-align: left;
    padding: 13px 14px;
    background: none;
    border: 0;
    font: inherit;
    font-size: 14px;
    color: var(--tinta);
    cursor: pointer;
}

.sugerencias button:hover { background: #fafbfc; }

/* ---------- mensajes ---------- */

.mensaje {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 9px;
}

.mensaje.de-usuario {
    justify-content: flex-end;
    align-items: flex-end;
}

.burbuja {
    max-width: 84%;
    padding: 11px 13px;
    border-radius: var(--radio);
    font-size: 14.5px;
}

.sello-hora {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--tinta-suave);
    font-variant-numeric: tabular-nums;
    padding-bottom: 2px;
}

.de-usuario .burbuja {
    background: var(--marca);
    background-image: var(--grad-enviar);
    color: #fff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 6px 16px -8px rgba(20, 80, 143, .55);
}

.de-dobi .burbuja {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-top-left-radius: 3px;
    box-shadow: 0 1px 2px rgba(16, 32, 63, .04);
}

.de-dobi .burbuja p { margin: 0; }

/* Cada bloque entra por separado, como si la respuesta se fuera componiendo */
.bloque {
    animation: bloque-entra .26s ease-out both;
}

.bloque + .bloque { margin-top: 9px; }

@keyframes bloque-entra {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.respuesta-pie {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 11px;
    padding-top: 9px;
    border-top: 1px solid var(--linea);
}

.pie-hora {
    flex: 1;
    font-size: 11px;
    color: var(--tinta-suave);
}

.copiar {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--linea);
    border-radius: 7px;
    padding: 3px 9px;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--tinta-media);
    cursor: pointer;
}

.copiar:hover { background: #f6f8fa; color: var(--tinta); }

/* Preguntas que siguen, debajo de la respuesta */
.seguir {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 2px 0 0 35px;
    animation: bloque-entra .3s ease-out both;
}

.seguir button {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 8px;
    padding: 6px 11px;
    font: inherit;
    font-size: 12.5px;
    color: var(--dato);
    cursor: pointer;
}

.seguir button:hover { border-color: #b9d2ee; background: #f7fbff; }

/* ---------- bloque de cifra ---------- */

.cifra {
    margin: 2px 0 11px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--linea);
}

.cifra-rotulo {
    font-size: 11.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tinta-suave);
}

.cifra-valor {
    margin-top: 2px;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;

    /* La cifra principal lleva el degradado recortado al texto, como los títulos
       de ASLY. Si el navegador no lo soporta, queda en azul sólido. */
    color: var(--marca);
    background-image: var(--grad-marca);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
    .cifra-valor { -webkit-text-fill-color: currentColor; }
}

.cifra-nota {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--tinta-media);
}

.var-alza  { color: var(--alza);  font-weight: 600; }
.var-baja  { color: var(--baja);  font-weight: 600; }

/* ---------- gráfico de barras ---------- */

.grafico { margin: 4px 0 2px; }

.grafico-titulo {
    font-size: 11.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    margin-bottom: 9px;
}

.barra-fila {
    display: grid;
    grid-template-columns: 92px 1fr auto;
    align-items: center;
    gap: 9px;
    margin-bottom: 7px;
    font-size: 12.5px;
}

.barra-fila:last-child { margin-bottom: 0; }

.barra-nombre {
    color: var(--tinta-media);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.barra-pista {
    height: 9px;
    background: #eef0f3;
    border-radius: 3px;
    overflow: hidden;
}

.barra-valor-pista {
    height: 100%;
    background: var(--dato);
    background-image: linear-gradient(90deg, #14508f 0%, #2a8ad6 100%);
    border-radius: 3px;
    transform-origin: left center;
    animation: crecer .5s cubic-bezier(.22, .61, .36, 1) both;
}

@keyframes crecer {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

.barra-cifra {
    font-variant-numeric: tabular-nums;
    color: var(--tinta);
    font-weight: 500;
}

/* ---------- tabla ---------- */

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 2px 0;
}

.tabla th {
    text-align: left;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    font-weight: 600;
    padding: 0 0 6px;
    border-bottom: 1px solid var(--linea);
}

.tabla td {
    padding: 8px 0;
    border-bottom: 1px solid var(--linea);
}

.tabla tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- línea de tendencia ---------- */

.linea { display: block; overflow: visible; }

.linea-trazo {
    fill: none;
    stroke: var(--dato);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: trazar 1.1s cubic-bezier(.3, .7, .4, 1) forwards;
}

@keyframes trazar { to { stroke-dashoffset: 0; } }

.linea-area {
    fill: var(--dato);
    opacity: .08;
}

.linea-punta {
    fill: var(--dato);
    stroke: var(--superficie);
    stroke-width: 2;
    animation: aparecer .3s 1s both;
}

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

.linea-pie {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 11px;
    color: var(--tinta-suave);
    font-variant-numeric: tabular-nums;
}

/* ---------- bajar al final ---------- */

.bajar {
    position: absolute;
    right: 14px;
    bottom: 12px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 50%;
    box-shadow: 0 4px 12px -4px rgba(16, 32, 63, .25);
    cursor: pointer;
    animation: bloque-entra .2s ease-out both;
}

.bajar[hidden] { display: none; }

.bajar-flecha {
    width: 8px;
    height: 8px;
    margin-top: -3px;
    border-right: 2px solid var(--tinta-media);
    border-bottom: 2px solid var(--tinta-media);
    transform: rotate(45deg);
}

/* ---------- escribiendo ---------- */

.escribiendo { display: flex; gap: 4px; padding: 4px 2px; }

.escribiendo span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dato);
    animation: brinco 1.2s infinite ease-in-out;
}

.escribiendo span:nth-child(2) { animation-delay: .15s; }
.escribiendo span:nth-child(3) { animation-delay: .3s; }

@keyframes brinco {
    0%, 80%, 100% { transform: translateY(0);    opacity: .4; }
    40%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- redactor ---------- */

.redactor {
    flex: 0 0 auto;
    display: flex;
    gap: 9px;
    padding: 11px 14px calc(11px + env(safe-area-inset-bottom, 0px));
    background: var(--superficie);
    border-top: 1px solid var(--linea);
}

.redactor {
    align-items: flex-end;
}

.redactor textarea {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    max-height: 120px;
    padding: 11px 13px;
    font: inherit;
    font-size: 15px;
    line-height: 1.35;
    color: var(--tinta);
    background: var(--fondo);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    resize: none;
    overflow-y: auto;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.redactor textarea:focus {
    outline: none;
    border-color: #9dc0e8;
    background: var(--superficie);
    box-shadow: 0 0 0 3px rgba(42, 138, 214, .14);
}

.redactor button {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--marca);
    background-image: var(--grad-enviar);
    border: 0;
    border-radius: var(--radio);
    cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(42, 120, 214, .75);
    transition: filter .15s ease, box-shadow .15s ease, transform .1s ease;
}

.redactor button img { filter: invert(1); }
.redactor button:hover { filter: brightness(1.07); box-shadow: 0 10px 22px -8px rgba(42, 120, 214, .85); }
.redactor button:active { transform: translateY(1px); }
.redactor button:disabled { opacity: .45; cursor: default; box-shadow: none; }

@media (min-width: 560px) {
    body { padding: 0; }
    .app { height: 100%; }
}

/* ---------- entrada de los mensajes ---------- */

.mensaje {
    animation: entrar .28s cubic-bezier(.22, .61, .36, 1) both;
}

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

/* A quien le molesta el movimiento se le deja todo quieto. */
@media (prefers-reduced-motion: reduce) {
    .barra,
    .mensaje,
    .bloque,
    .seguir,
    .bajar,
    .barra-valor-pista,
    .linea-trazo,
    .linea-punta,
    .escribiendo span {
        animation: none;
    }
    .linea-trazo { stroke-dashoffset: 0; }
    .conversacion { scroll-behavior: auto; }
    .barra { background-position: 0 50%; }
    .barra-valor-pista { transform: none; }
}
