/* ================================================================
   SHERPALIFE — Recomendador de Equipamiento
   Tipografía: Poppins | Color primario: #CA0000
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --red:        #CA0000;
    --red-dark:   #a00000;
    --red-light:  #f9eaea;
    --gray-50:    #f8f8f8;
    --gray-100:   #f0f0f0;
    --gray-200:   #e4e4e4;
    --gray-400:   #9ca3af;
    --gray-600:   #4b5563;
    --gray-800:   #1f2937;
    --white:      #ffffff;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:  0 8px 24px rgba(0,0,0,.12);
    --radius-sm:  8px;
    --radius-md:  14px;
    --radius-lg:  20px;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}


/* ── Header ───────────────────────────────────────────────────── */
.app-header {
    background: var(--red);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(202,0,0,.35);
    z-index: 10;
}

.header-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-sub {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.85;
}

.btn-reset {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.15);
    color: white;
    border: 1.5px solid rgba(255,255,255,.3);
    padding: 7px 14px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-reset:hover {
    background: rgba(255,255,255,.25);
}


/* ── Chat Container ───────────────────────────────────────────── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 24px 20px;
}

.messages-area {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}


/* ── Mensajes ─────────────────────────────────────────────────── */
.message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: fadeSlide .25s ease;
}

.message.user {
    flex-direction: row-reverse;
}

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

/* Avatar */
.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.msg-avatar svg {
    width: 18px;
    height: 18px;
}

/* Burbuja */
.msg-bubble {
    max-width: min(72%, 560px);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    border-radius: var(--radius-lg);
}

.message.ai .msg-bubble {
    background: var(--white);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.user .msg-bubble {
    background: var(--red);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

/* Grupo de mensajes AI consecutivos — ocultar avatar en intermedios */
.message.ai + .message.ai .msg-avatar {
    visibility: hidden;
}


/* ── Typing indicator ─────────────────────────────────────────── */
.message.typing .msg-bubble {
    padding: 14px 18px;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}


/* ── Sección de productos ─────────────────────────────────────── */
.products-section {
    margin-top: 8px;
    animation: fadeSlide .3s ease;
}

.products-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 12px;
    padding-left: 44px; /* alineado con burbuja AI */
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 14px;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    transition: transform .2s, box-shadow .2s;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.product-card__img-wrap {
    width: 100%;
    height: 155px;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 12px;
}

.product-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-card__body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card__brand {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .6px;
}

.product-card__title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    margin: 5px 0 8px;
    line-height: 1.35;
    /* Truncar a 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card__prices {
    margin-top: auto;
    margin-bottom: 10px;
}

.product-card__sale {
    font-size: 17px;
    font-weight: 700;
    color: var(--red);
    line-height: 1;
}

.product-card__original {
    font-size: 12px;
    color: var(--gray-400);
    text-decoration: line-through;
    margin-top: 2px;
}

.product-card__regular {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.product-card__btn {
    display: block;
    text-align: center;
    background: var(--red);
    color: var(--white);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .2px;
    transition: background .2s;
}

.product-card__btn:hover {
    background: var(--red-dark);
}

/* Sin resultados */
.no-products {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    color: var(--gray-600);
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    margin-left: 44px;
}

.no-products a {
    color: var(--red);
    font-weight: 600;
    text-decoration: none;
}


/* ── Input Area ───────────────────────────────────────────────── */
.input-area {
    flex-shrink: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 12px 20px 16px;
}

.input-inner {
    max-width: 820px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 8px 8px 8px 16px;
    transition: border-color .2s, box-shadow .2s;
}

.input-wrapper:focus-within {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(202,0,0,.10);
}

.user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 4px 0;
}

.user-input::placeholder {
    color: var(--gray-400);
}

.user-input:disabled {
    opacity: 0.5;
}

.btn-send {
    width: 40px;
    height: 40px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .1s;
}

.btn-send:hover {
    background: var(--red-dark);
}

.btn-send:active {
    transform: scale(.93);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.input-disclaimer {
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    margin-top: 8px;
}

.input-disclaimer a {
    color: var(--red);
    text-decoration: none;
    font-weight: 500;
}


/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
    .logo-sub     { display: none; }
    .logo-brand   { font-size: 16px; }
    .btn-reset span { display: none; }

    .chat-container { padding: 16px 12px; }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .products-title { padding-left: 0; }

    .msg-bubble { max-width: 85%; }
}

@media (max-width: 380px) {
    .products-grid { grid-template-columns: 1fr; }
}
