/* =========================================================
   Capa "App UI": detalles que hacen que NO se vea como una
   página web básica. Controla foco, scroll, selección,
   campos, autofill y un <select> personalizado.
   (Se carga después de styles.css para poder afinar.)
   ========================================================= */

/* ---- Quitar el flash gris/azul al tocar en móvil ---- */
* { -webkit-tap-highlight-color: transparent; }

/* ---- Campo trampa anti-spam (invisible) ---- */
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---- Selección de texto con color de marca ---- */
::selection { background: rgba(37, 99, 235, .4); color: #fff; }

/* ---- Barra de scroll elegante ---- */
* { scrollbar-width: thin; scrollbar-color: var(--gris-borde) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--gris-borde);
    border-radius: 999px;
    border: 2px solid var(--negro);
}
::-webkit-scrollbar-thumb:hover { background: var(--azul); }

/* ---- Foco accesible y elegante: solo al navegar con teclado ---- */
:focus-visible { outline: 2px solid var(--azul-claro); outline-offset: 2px; border-radius: 8px; }
:focus:not(:focus-visible) { outline: none; }

/* ---- Botones: sensación de "presionar" como en una app ---- */
.btn { -webkit-user-select: none; user-select: none; position: relative; overflow: hidden; }
.btn:active { transform: scale(.96); }

/* Efecto onda (ripple) al hacer clic en un botón */
.ripple-ink {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255, 255, 255, .45);
    pointer-events: none;
    animation: ripple .6s ease-out forwards;
}
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ripple-ink { display: none; } }

/* =========================================================
   Toasts (notificaciones flotantes estilo app)
   ========================================================= */
.toast-stack {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top));
    right: calc(1rem + env(safe-area-inset-right));
    z-index: 300;
    display: flex; flex-direction: column; gap: .6rem;
    pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: .65rem;
    min-width: 240px; max-width: calc(100vw - 2rem);
    background: var(--gris-card);
    border: 1px solid var(--gris-borde);
    border-left: 4px solid var(--azul);
    color: var(--blanco);
    padding: .85rem 1.1rem;
    border-radius: var(--radio-sm);
    box-shadow: var(--sombra);
    font-size: .9rem;
    transform: translateX(120%); opacity: 0;
    transition: transform .4s cubic-bezier(.22, 1, .36, 1), opacity .4s ease;
    pointer-events: auto;
}
.toast.is-visible { transform: none; opacity: 1; }
.toast--ok    { border-left-color: #22c55e; }
.toast--error { border-left-color: #ef4444; }
.toast__icon  { font-size: 1.2rem; flex-shrink: 0; }

@media (max-width: 540px) {
    .toast-stack { left: 1rem; right: 1rem; }
    .toast { min-width: 0; transform: translateY(-140%); }
    .toast.is-visible { transform: none; }
}

/* ---- Campos: foco con glow suave (no el borde plano del navegador) ---- */
.contacto__form input:focus,
.contacto__form textarea:focus,
.catalogo__search:focus {
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .16);
}

/* ---- Placeholder más suave ---- */
::placeholder { color: var(--gris-texto); opacity: .7; }

/* ---- Arreglar el autofill amarillo de Chrome (lo deja en tema oscuro) ---- */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--blanco);
    -webkit-box-shadow: 0 0 0 1000px var(--gris-oscuro) inset;
    caret-color: var(--blanco);
    transition: background-color 9999s ease-in-out 0s;
}

/* =========================================================
   Selector de correo (Gmail / Outlook / app / copiar)
   ========================================================= */
.email-sheet { position: fixed; inset: 0; z-index: 260; display: grid; place-items: center; padding: 1.5rem; }
.email-sheet[hidden] { display: none; }
.email-sheet__overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); }
.email-sheet__box {
    position: relative; z-index: 1; width: 100%; max-width: 380px;
    background: var(--gris-card); border: 1px solid var(--gris-borde);
    border-radius: var(--radio); box-shadow: var(--sombra);
    padding: 1.5rem; animation: pop .25s ease;
}
.email-sheet__title { font-size: 1.1rem; margin-bottom: .25rem; }
.email-sheet__sub { font-size: .85rem; color: var(--gris-texto); margin-bottom: 1.25rem; word-break: break-all; }
.email-sheet__list { display: flex; flex-direction: column; gap: .5rem; }
.email-opt {
    display: flex; align-items: center; gap: .8rem; width: 100%;
    background: var(--gris-oscuro); border: 1px solid var(--gris-borde);
    border-radius: var(--radio-sm); padding: .8rem 1rem;
    color: var(--blanco); font-family: inherit; font-size: .95rem; text-align: left;
    cursor: pointer; transition: var(--trans);
}
.email-opt:hover { border-color: var(--azul); transform: translateX(3px); background: rgba(37, 99, 235, .1); }
.email-opt__icon { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 9px; font-size: 1.1rem; font-weight: 800; color: #fff; }
.email-opt__icon--gmail   { background: #ea4335; }
.email-opt__icon--outlook { background: #0a66c2; }
.email-opt__icon--app     { background: var(--grad-azul); }
.email-opt__icon--copy    { background: #475569; }
.email-opt small { display: block; color: var(--gris-texto); font-size: .75rem; }

/* =========================================================
   <select> PERSONALIZADO (menú desplegable estilo app)
   El JS construye esta estructura sobre cada <select> real.
   ========================================================= */
.app-select { position: relative; min-width: 0; width: 100%; }

/* el <select> real queda oculto pero sigue funcionando para el formulario */
.app-select__native {
    position: absolute; width: 1px; height: 1px;
    opacity: 0; pointer-events: none; overflow: hidden;
}

/* el "botón" que se ve en lugar del select */
.app-select__trigger {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    width: 100%; min-width: 0;
    font-family: inherit; font-size: .95rem; text-align: left;
    background: var(--gris-oscuro);
    border: 1px solid var(--gris-borde);
    color: var(--blanco);
    padding: .75rem 1rem;
    border-radius: var(--radio-sm);
    cursor: pointer;
    transition: var(--trans);
}
.app-select__trigger:hover { border-color: var(--azul); }
.app-select.is-open .app-select__trigger {
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .16);
}
.app-select__trigger[data-placeholder] .app-select__label { color: var(--gris-texto); }

.app-select__label {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-select__arrow {
    flex-shrink: 0; color: var(--azul-elec); font-size: .8rem;
    transition: transform .25s ease;
}
.app-select.is-open .app-select__arrow { transform: rotate(180deg); }

/* el panel desplegable */
.app-select__panel {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
    background: var(--gris-card);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio-sm);
    box-shadow: var(--sombra);
    padding: .35rem;
    max-height: 260px; overflow-y: auto;
    opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top center;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.app-select.is-open .app-select__panel {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
}

.app-select__option {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem .8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: .92rem; color: var(--blanco);
    transition: background .15s ease;
    overflow-wrap: anywhere;
}
.app-select__option:hover,
.app-select__option.is-active { background: rgba(37, 99, 235, .16); }
.app-select__option.is-selected { color: var(--azul-claro); font-weight: 600; }
.app-select__option.is-selected::after {
    content: '✓'; margin-left: auto; color: var(--azul-elec); flex-shrink: 0;
}
.app-select__option[data-placeholder] { color: var(--gris-texto); }
