/*
 * components.css
 * ------------------------------------------------------------
 * Componentes UI reutilizables. Funcionan igual en público
 * y admin. Naming: BEM simple (.bloque__elemento--modificador).
 * ------------------------------------------------------------
 */

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.05rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.005em;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    background: var(--color-primary);
    color: var(--color-primary-text);
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--transition),
        border-color var(--transition),
        transform var(--transition),
        box-shadow var(--transition),
        color var(--transition);
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}

.btn:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--color-primary-text);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring-strong);
}

.btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }

.btn:disabled,
.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn--secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-xs);
}
.btn--secondary:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
    box-shadow: none;
}
.btn--ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
    border-color: transparent;
    box-shadow: none;
}

.btn--danger {
    background: var(--color-bg);
    color: var(--color-danger);
    border-color: #fecaca;
    box-shadow: var(--shadow-xs);
}
.btn--danger:hover {
    background: var(--color-danger);
    color: var(--color-primary-text);
    border-color: var(--color-danger);
}

.btn--small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn--lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ==========================================================
   Forms
   ========================================================== */
.form__field {
    display: block;
    margin: 0 0 var(--space-md);
}

.form__field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.4rem;
    letter-spacing: -0.005em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b6b73' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2rem;
    cursor: pointer;
}

input::placeholder,
textarea::placeholder { color: var(--color-text-subtle); }

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-text);
    box-shadow: var(--ring);
}

textarea {
    min-height: 6rem;
    resize: vertical;
    line-height: 1.5;
}

.form__submit { margin-top: var(--space-lg); }

.inline-form {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-md);
}
.inline-form select,
.inline-form input { width: auto; flex: 0 0 auto; }

/* ==========================================================
   Tables
   ========================================================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    margin: 0 0 var(--space-md);
}

.table th,
.table td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}

.table tbody tr:hover { background: var(--color-bg-alt); }

.table--striped tbody tr:nth-child(even) { background: var(--color-bg-alt); }
.table--striped tbody tr:nth-child(even):hover { background: var(--color-bg-hover); }

/* ==========================================================
   Alerts
   ========================================================== */
.alert {
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-alt);
    color: var(--color-text);
    margin: 0 0 var(--space-md);
    font-size: 0.92rem;
    line-height: 1.5;
}

.alert--error {
    background: var(--color-danger-soft);
    border-color: #fecaca;
    color: #7f1d1d;
}

.alert--success {
    background: var(--color-success-soft);
    border-color: #bbf7d0;
    color: #14532d;
}

/* ==========================================================
   Badges (default fuera de admin)
   ========================================================== */
.badge {
    display: inline-block;
    padding: 0.16rem 0.6rem;
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    line-height: 1.4;
}

.badge--solid {
    background: var(--color-text);
    color: var(--color-primary-text);
    border-color: var(--color-text);
}

/* ==========================================================
   Service card (home / landings)
   ========================================================== */
.service-card {
    padding: var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.service-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--color-border-strong);
}

.service-card__title {
    margin: 0 0 var(--space-sm);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.service-card__text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--color-text-muted);
}

/* ==========================================================
   Contact info (datos del negocio junto al form)
   ========================================================== */
.contact-info {
    padding: var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    box-shadow: var(--shadow-xs);
}

.contact-info__wa { margin-bottom: var(--space-md); }

.contact-info__list {
    margin: 0;
    display: grid;
    gap: var(--space-xs);
}

.contact-info__list dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

.contact-info__list dt:first-child { margin-top: 0; }

.contact-info__list dd {
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.5;
}

/* ==========================================================
   Testimonios (home)
   ========================================================== */
.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.testimonial-card {
    margin: 0;
    padding: var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.testimonial-card__quote {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text);
}

.testimonial-card__quote::before { content: "“"; }
.testimonial-card__quote::after  { content: "”"; }

.testimonial-card__author {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.88rem;
}

.testimonial-card__author span { color: var(--color-text-muted); }

/* ==========================================================
   FAQ (home) — details/summary nativo, sin JS
   ========================================================== */
.faq-list {
    margin-top: var(--space-lg);
    max-width: 720px;
    display: grid;
    gap: var(--space-sm);
}

.faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    box-shadow: var(--shadow-xs);
}

.faq-item[open] { border-color: var(--color-border-strong); }

.faq-item__question {
    padding: var(--space-md) var(--space-lg);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

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

.faq-item__question::after {
    content: "+";
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--color-text-muted);
    transition: transform var(--transition);
    flex-shrink: 0;
}

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

.faq-item__answer {
    padding: 0 var(--space-lg) var(--space-md);
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

/* ==========================================================
   Lead form (público)
   ========================================================== */
.lead-form {
    max-width: 520px;
    margin: 0 0 var(--space-lg);
}

.lead-form__field {
    margin: 0 0 var(--space-md);
}

.lead-form__field label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.lead-form__submit { margin-top: var(--space-lg); }

.lead-form__field input,
.lead-form__field textarea { width: 100%; }

/* ==========================================================
   Aparición al hacer scroll (script en layoutEnd)
   ========================================================== */
.js-reveal .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease-out-quart), transform .6s var(--ease-out-quart); }
.js-reveal .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js-reveal .reveal { opacity: 1; transform: none; } }

/* ==========================================================
   Video YouTube liviano (components/youtube_embed.php)
   ========================================================== */
.yt { position: relative; display: block; border-radius: var(--radius-xl); overflow: hidden; aspect-ratio: 16 / 9; background: #000; box-shadow: var(--shadow-lg); }
.yt img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; transition: opacity var(--transition); }
.yt:hover img { opacity: 1; }
.yt__play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.yt__label { position: absolute; left: var(--space-md); bottom: var(--space-md); color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ==========================================================
   Asistente WhatsApp (components/whatsapp_assistant.php)
   ========================================================== */
.wa-assist { position: fixed; right: 18px; bottom: 18px; z-index: 95; font-size: .95rem; }

.wa-assist__fab {
    position: relative; width: 60px; height: 60px; border-radius: 50%; background: #25d366; color: #fff;
    display: flex; align-items: center; justify-content: center; text-decoration: none;
    box-shadow: 0 10px 24px -6px rgba(37,211,102,.6); transition: transform .2s, background .2s;
}
.wa-assist__fab:hover { transform: scale(1.06); color: #fff; }
.wa-assist__fab::before {
    content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #25d366;
    animation: wa-pulse 2.4s ease-out infinite;
}
.wa-assist__fab-close { display: none; font-size: 2rem; line-height: 1; }
.wa-assist.is-open .wa-assist__fab { background: #075e54; box-shadow: var(--shadow-lg); }
.wa-assist.is-open .wa-assist__fab::before, .wa-assist.is-open .wa-assist__dot { display: none; }
.wa-assist.is-open .wa-assist__fab-icon { display: none; }
.wa-assist.is-open .wa-assist__fab-close { display: block; }
.wa-assist__dot { position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
@keyframes wa-pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.55); opacity: 0; } }

.wa-assist__teaser {
    position: absolute; right: 0; bottom: 74px; width: 250px; background: #fff; border-radius: 16px 16px 4px 16px;
    padding: .8rem 2rem .8rem .9rem; box-shadow: var(--shadow-lg); border: 1px solid var(--color-border);
    display: grid; gap: .15rem; cursor: pointer; animation: wa-in .35s var(--ease-out-quart);
}
.wa-assist__teaser[hidden] { display: none; }
.wa-assist__teaser strong { color: var(--color-text-strong); }
.wa-assist__teaser span { color: var(--color-text-muted); font-size: .88rem; }
.wa-assist__teaser-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 1.2rem; color: var(--color-text-subtle); cursor: pointer; }

.wa-assist__panel {
    position: absolute; right: 0; bottom: 76px; width: min(370px, calc(100vw - 28px));
    height: min(560px, calc(100vh - 140px)); display: flex; flex-direction: column;
    background: #efeae2; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 70px -20px rgba(2,28,87,.55);
    opacity: 0; transform: translateY(12px) scale(.98); transform-origin: bottom right;
    transition: opacity .25s ease, transform .25s var(--ease-out-quart);
}
.wa-assist__panel[hidden] { display: none; }
.wa-assist.is-open .wa-assist__panel { opacity: 1; transform: none; }
@media (max-width: 860px) {
    .wa-assist__panel { height: min(560px, calc(100vh - 190px)); }
}

.wa-assist__head { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; background: #075e54; color: #fff; }
.wa-assist__avatar { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #075e54; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wa-assist__who { display: grid; flex: 1; line-height: 1.25; }
.wa-assist__who span { font-size: .75rem; opacity: .85; display: flex; align-items: center; gap: .35rem; }
.wa-assist__online { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; flex-shrink: 0; }
.wa-assist__x { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; }

.wa-assist__body { flex: 1; overflow-y: auto; padding: 1rem .9rem; display: flex; flex-direction: column; gap: .45rem;
    background-image: radial-gradient(rgba(7,94,84,.06) 1px, transparent 1px); background-size: 16px 16px; }
.wa-msg { max-width: 85%; padding: .55rem .8rem; border-radius: 12px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.08); animation: wa-in .25s ease; white-space: pre-line; }
.wa-msg--bot { align-self: flex-start; background: #fff; border-top-left-radius: 4px; color: #111b21; }
.wa-msg--me  { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 4px; color: #111b21; }
.wa-msg--typing { display: flex; gap: 4px; padding: .7rem .8rem; }
.wa-msg--typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa5ad; animation: wa-dot 1s infinite; }
.wa-msg--typing i:nth-child(2) { animation-delay: .15s; }
.wa-msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wa-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes wa-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.wa-assist__foot { background: #f0f2f5; padding: .7rem; display: grid; gap: .5rem; border-top: 1px solid #e2e5e9; }
.wa-assist__chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.wa-assist__chips:empty { display: none; }
.wa-chip {
    border: 1px solid #25d366; color: #075e54; background: #fff; border-radius: 999px; padding: .45rem .85rem;
    font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.wa-chip:hover { background: #25d366; color: #fff; }
.wa-chip--ghost { border-color: #c4ccd3; color: var(--color-text-muted); }
.wa-chip--ghost:hover { background: #e2e5e9; color: var(--color-text); }
.wa-assist__input { display: flex; gap: .4rem; }
.wa-assist__input[hidden] { display: none; }
.wa-assist__input input { flex: 1; border: 0; border-radius: 999px; padding: .7rem 1rem; font: inherit; background: #fff; }
.wa-assist__input input:focus { outline: 2px solid #25d366; }
.wa-assist__send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #25d366; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wa-assist__submit {
    display: flex; align-items: center; justify-content: center; gap: .5rem; border: 0; border-radius: 999px;
    background: #25d366; color: #fff; font: inherit; font-weight: 700; padding: .8rem 1rem; cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(37,211,102,.8);
}
.wa-assist__submit[hidden] { display: none; }
.wa-assist__submit svg { width: 20px; height: 20px; }
.wa-assist__submit.is-loading { opacity: .7; }
.wa-assist__legal { margin: 0; font-size: .7rem; color: #8696a0; text-align: center; }
