:root {
    --bg: #121826;
    --surface: #1e293b;
    --surface-2: #263147;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --radius: 12px;
    --font: 'Poppins', sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg);
    background-image: linear-gradient(rgba(18, 24, 38, 0.88), rgba(18, 24, 38, 0.88)), url('../images/padel-court.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Layout ── */
.page-wrapper {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 100vh;
}

/* ── Header ── */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
    width: fit-content;
}

.back-link:hover { color: var(--text); }

.header-title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.header-icon {
    font-size: 2rem;
    line-height: 1;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}

.header-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── SEO intro ── */
.seo-intro {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
}

.seo-intro strong { color: var(--text); }

/* ── Chat container ── */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

/* ── Suggestions ── */
.suggestions {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.suggestions-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.625rem;
}

.suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    padding: 0.4rem 0.875rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    text-align: left;
}

.suggestion-btn:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--accent);
    color: var(--accent-hover);
}

/* ── Messages header ── */
.messages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.messages-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
    transition: color 0.2s, border-color 0.2s;
}

.clear-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Messages ── */
.messages {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    min-height: 300px;
    max-height: 65vh;
    overflow-y: auto;
    padding: 0.25rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-2) transparent;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 2px; }

.message {
    display: flex;
    max-width: 85%;
}

.message--user {
    align-self: flex-end;
    justify-content: flex-end;
}

.message--bot {
    align-self: flex-start;
}

.bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.message--user .bubble {
    background: var(--accent);
    color: #0f172a;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.message--bot .bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* ── Markdown dentro de burbujas bot ── */
.message--bot .bubble h1,
.message--bot .bubble h2,
.message--bot .bubble h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.75rem 0 0.4rem;
    color: var(--text);
}

.message--bot .bubble h1:first-child,
.message--bot .bubble h2:first-child,
.message--bot .bubble h3:first-child {
    margin-top: 0;
}

.message--bot .bubble p {
    margin-bottom: 0.5rem;
}

.message--bot .bubble p:last-child {
    margin-bottom: 0;
}

.message--bot .bubble ul,
.message--bot .bubble ol {
    padding-left: 1.25rem;
    margin: 0.4rem 0 0.5rem;
}

.message--bot .bubble li {
    margin-bottom: 0.3rem;
    line-height: 1.5;
}

.message--bot .bubble strong {
    color: var(--accent-hover);
    font-weight: 600;
}

.message--bot .bubble em {
    color: var(--text-muted);
}

.message--bot .bubble code {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.85em;
}

.message--bot .bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.75rem 0;
}

/* ── Typing indicator ── */
.bubble--typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.875rem 1.125rem;
}

.bubble--typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.bubble--typing span:nth-child(2) { animation-delay: 0.2s; }
.bubble--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input form ── */
.chat-form {
    display: flex;
    gap: 0.625rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    transition: border-color 0.2s;
}

.chat-form:focus-within {
    border-color: rgba(56, 189, 248, 0.4);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 0.45rem 0.5rem;
    outline: none;
}

.chat-input::placeholder { color: var(--text-muted); }

.send-btn {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #0f172a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.875rem;
    transition: background 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── FAQ acordeón ── */
.faq-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.faq-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.faq-item[open] {
    border-color: rgba(56, 189, 248, 0.25);
}

.faq-question {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    padding: 0.875rem 1rem;
    list-style: none;
    user-select: none;
    transition: color 0.2s, background 0.2s;
}

.faq-question::-webkit-details-marker { display: none; }

.faq-question::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transition: transform 0.25s ease;
}

.faq-item[open] .faq-question::after {
    transform: rotate(180deg);
}

.faq-item[open] .faq-question {
    color: var(--accent-hover);
}

.faq-answer {
    padding: 0 1rem 0.875rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.65;
    animation: faq-open 0.22s ease both;
}

.faq-answer p { margin: 0; }

@keyframes faq-open {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Footer ── */
.page-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover { color: var(--text); }

.social-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.social-links a {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s;
}

.social-links a:hover { transform: translateY(-3px); }

.social-icon {
    width: 22px;
    height: 22px;
    fill: var(--text-muted);
    transition: fill 0.2s;
}

.social-links a:hover .social-icon { fill: var(--text); }

.language-selector {
    display: flex;
    gap: 0.875rem;
}

.lang-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.lang-link:hover,
.lang-link.active { color: var(--text); }

.flag-icon {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    object-fit: cover;
}

/* ── Transiciones y animaciones ── */

/* Entrada de página */
.page-wrapper {
    animation: page-in 0.4s ease both;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Entrada de mensajes */
.message--user {
    animation: msg-from-right 0.28s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

.message--bot {
    animation: msg-from-left 0.28s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes msg-from-right {
    from { opacity: 0; transform: translateX(18px) scale(0.97); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes msg-from-left {
    from { opacity: 0; transform: translateX(-18px) scale(0.97); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* Sugerencias: stagger en carga + fade-out al enviar */
.suggestion-btn:nth-child(1) { animation: suggestion-in 0.35s 0.05s ease both; }
.suggestion-btn:nth-child(2) { animation: suggestion-in 0.35s 0.1s  ease both; }
.suggestion-btn:nth-child(3) { animation: suggestion-in 0.35s 0.15s ease both; }
.suggestion-btn:nth-child(4) { animation: suggestion-in 0.35s 0.2s  ease both; }
.suggestion-btn:nth-child(5) { animation: suggestion-in 0.35s 0.25s ease both; }

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

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

.suggestions {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.suggestions.is-hiding {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

/* Send button: press feedback + glow en hover */
.send-btn {
    transition: background 0.2s, opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}

.send-btn:hover:not(:disabled) {
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.9);
}

/* Form: glow al enfocar */
.chat-form {
    transition: border-color 0.25s, box-shadow 0.25s;
}

.chat-form:focus-within {
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.07);
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .page-wrapper { padding: 1rem 0.75rem 1.5rem; }
    .header-title h1 { font-size: 1.25rem; }
    .message { max-width: 95%; }
    .messages { max-height: 60vh; }
}
