/* tienda.css — CSS compartido del chrome (header + busqueda + carrito + menu usuario).
   Generado desde los templates (parte 3 refactor DRY). Cargado por base.html
   ANTES de block styles, asi cada pagina puede sobreescribir si hace falta. */

.header { padding: 20px 40px; border-bottom: 1px solid #eee; display: flex; align-items: center; gap: 40px; }
.header > img { height: 56px; }
.search-box { flex: 1; max-width: 600px; margin: 0 auto; position: relative; }
.search-box input { width: 100%; padding: 12px 20px; padding-right: 50px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; font-family: 'Inter', sans-serif; outline: none; transition: border-color 0.2s; }
.search-box input:focus { border-color: #1a1a1a; }
.search-box input::placeholder { color: #bbb; }
.search-btn { position: absolute; right: 12px; top: 12px; background: none; border: none; cursor: pointer; color: #999; }
.search-btn:hover { color: #1a1a1a; }
.user-area { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.cart-icon-btn { position: relative; background: none; border: none; cursor: pointer; color: #555; padding: 6px; transition: color 0.2s; }
.cart-icon-btn:hover { color: #1a1a1a; }
.cart-badge { position: absolute; top: -2px; right: -4px; background: #e74c3c; color: #fff; font-size: 10px; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; display: none; align-items: center; justify-content: center; padding: 0 4px; }
.cart-badge.active { display: flex; }
.user-menu { position: relative; display: inline-flex; align-items: center; }
.user-avatar { display: block; width: 36px !important; height: 36px !important; max-width: 36px; max-height: 36px; border-radius: 50%; background-size: cover; background-position: center; cursor: pointer; border: 2px solid #eee; transition: border-color 0.2s; flex-shrink: 0; flex-grow: 0; aspect-ratio: 1/1; }
.user-avatar:hover { border-color: #999; }
.user-dropdown { display: none; position: absolute; top: 44px; right: 0; background: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 200px; z-index: 100; padding: 8px 0; }
.user-dropdown.active { display: block; }
.user-dropdown-info { padding: 12px 16px; border-bottom: 1px solid #eee; }
.user-dropdown-info .uname { font-weight: 500; font-size: 14px; }
.user-dropdown-info .uemail { font-size: 12px; color: #999; }
.user-dropdown a { display: block; padding: 10px 16px; font-size: 13px; color: #555; text-decoration: none; }
.user-dropdown a:hover { background: #f5f5f5; color: #1a1a1a; }
.google-login-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border: 1px solid #ddd; border-radius: 8px; background: #fff; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 13px; color: #555; transition: border-color 0.2s, box-shadow 0.2s; white-space: nowrap; text-decoration: none; }
.google-login-btn:hover { border-color: #999; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.google-login-btn img { width: 18px; height: 18px; }
.cart-checkout-btn { display: block; width: 100%; padding: 14px; background: #1a1a1a; color: #fff; border: none; border-radius: 8px; font-size: 15px; font-family: 'Inter', sans-serif; cursor: pointer; }
.cart-checkout-btn:disabled { background: #ccc; cursor: not-allowed; }
.cart-checkout-btn:hover { background: #333; }
.cart-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw; background: #fff; z-index: 301; transform: translateX(100%); transition: transform 0.3s ease; display: flex; flex-direction: column; }
.cart-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.cart-drawer-close { background: none; border: none; font-size: 24px; color: #999; cursor: pointer; }
.cart-drawer-footer { padding: 20px; border-top: 1px solid #eee; }
.cart-drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid #eee; }
.cart-drawer-header h2 { font-size: 16px; font-weight: 600; }
.cart-drawer-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 300; }
.cart-drawer-overlay.active { display: block; }
.cart-drawer.active { transform: translateX(0); }
.cart-empty { text-align: center; padding: 40px 20px; color: #999; font-size: 14px; }
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.cart-item-author { font-size: 11px; color: #999; margin-bottom: 6px; }
.cart-item-img { width: 60px; height: 80px; background: #f5f5f5; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-price { font-size: 14px; font-weight: 500; }
.cart-item-qty { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cart-item-qty button { width: 26px; height: 26px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.cart-item-qty button:hover { background: #f5f5f5; }
.cart-item-qty span { font-size: 14px; min-width: 20px; text-align: center; }
.cart-item-qty label { font-size: 12px; color: #888; }
.cart-item-qty select { padding: 4px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; background: #fff; cursor: pointer; }
.cart-item-remove { background: none; border: none; color: #ccc; cursor: pointer; font-size: 18px; padding: 4px; align-self: flex-start; }
.cart-item-remove:hover { color: #e74c3c; }
.cart-item-title { font-size: 13px; font-weight: 500; margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cart-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 600; margin-bottom: 15px; }


/* ===== Selector de dirección "Enviar a" (estilo MeLi) en el header ===== */
.ship-to { position: relative; flex-shrink: 0; }
.ship-to-btn { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: #555; font-family: 'Inter', sans-serif; }
.ship-to-btn:hover { background: #f5f5f5; }
.ship-to-text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.ship-to-label { font-size: 11px; color: #999; }
.ship-to-value { font-size: 13px; color: #1a1a1a; font-weight: 500; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-to-dropdown { display: none; position: absolute; top: 50px; left: 0; background: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 270px; z-index: 100; padding: 6px 0; }
.ship-to-dropdown.active { display: block; }
.ship-to-item { padding: 10px 16px; cursor: pointer; }
.ship-to-item:hover { background: #f5f5f5; }
.ship-to-item.active { background: #f0f7ff; }
.ship-to-item .sti-label { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.ship-to-item .sti-line { font-size: 12px; color: #777; margin-top: 2px; }
.ship-to-add { display: block; padding: 10px 16px; font-size: 13px; color: #1565c0; text-decoration: none; border-top: 1px solid #eee; margin-top: 4px; }
.ship-to-add:hover { background: #f5f5f5; }
@media (max-width: 768px) {
    .ship-to-label { display: none; }
    .ship-to-value { max-width: 90px; font-size: 12px; }
    .ship-to-btn { padding: 6px 4px; gap: 4px; }
}


/* ===== Modal pedir CP al loguear ===== */
.cp-modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:400; align-items:center; justify-content:center; }
.cp-modal-overlay.active { display:flex; }
.cp-modal { background:#fff; border-radius:12px; width:420px; max-width:92vw; padding:28px 26px; box-shadow:0 8px 30px rgba(0,0,0,0.2); }
.cp-modal h3 { font-family:'Cormorant Garamond',serif; font-size:22px; font-weight:500; margin-bottom:8px; }
.cp-modal p { font-size:14px; color:#666; line-height:1.5; margin-bottom:18px; }
.cp-modal input { width:100%; padding:12px 14px; border:1px solid #ddd; border-radius:8px; font-size:16px; font-family:'Inter',sans-serif; outline:none; letter-spacing:2px; }
.cp-modal input:focus { border-color:#1a1a1a; }
.cp-modal-err { color:#c62828; font-size:13px; min-height:18px; margin-top:6px; }
.cp-modal-ok { color:#2e7d32; font-size:13px; min-height:18px; margin-top:6px; font-weight:500; }
.cp-modal-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:8px; }
.cp-modal-actions button { padding:10px 22px; border-radius:8px; font-size:14px; cursor:pointer; font-family:'Inter',sans-serif; }
.cp-modal-actions .cp-skip { background:none; border:1px solid #ddd; color:#777; }
.cp-modal-actions .cp-skip:hover { border-color:#999; }
.cp-modal-actions .cp-save { background:#1a1a1a; color:#fff; border:none; }
.cp-modal-actions .cp-save:hover { background:#333; }
.cp-modal-actions .cp-save:disabled { background:#ccc; cursor:default; }


/* ===== Barra inferior fija en mobile (estilo MeLi) ===== */
.mobnav { display: none; }
.mobnav-lbl { display: none; }
@media (max-width: 768px) {
    body { padding-bottom: 66px; }
    .user-area {
        position: fixed; left: 0; right: 0; bottom: 0; margin: 0;
        background: #fff; border-top: 1px solid #eee; box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
        justify-content: space-around; align-items: flex-end; gap: 0;
        padding: 7px 0 9px; z-index: 300;
    }
    .mobnav { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; text-decoration: none; color: #555; }
    .mobnav svg { width: 22px; height: 22px; }
    .mobnav-lbl { display: block; font-size: 10px; color: #555; line-height: 1; }
    .cart-icon-btn { flex-direction: column; align-items: center; gap: 3px; flex: 1; color: #555; padding: 0; }
    .google-login-btn { flex-direction: column; align-items: center; gap: 3px; flex: 1; border: none; box-shadow: none; padding: 0; font-size: 10px; color: #555; }
    .google-login-btn img { width: 22px; height: 22px; }
    .google-login-btn span { display: block; font-size: 10px; }
    .user-menu { flex-direction: column; align-items: center; gap: 3px; flex: 1; }
    .user-dropdown { position: fixed; top: auto; bottom: 66px; right: 8px; left: 8px; min-width: 0; }
}

/* Pie con enlaces legales (base.html -> _footer.html) */
.site-footer { border-top: 1px solid #eee; margin-top: 48px; padding: 22px 16px; background: #fafafa; }
.site-footer-in { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; font-size: 12px; color: #888; }
.site-footer-in a { color: #666; text-decoration: none; }
.site-footer-in a:hover { color: #1a1a1a; text-decoration: underline; }
.footer-ig { display: inline-flex; align-items: center; gap: 5px; }
/* Menú "Enviar a": cambiar CP de referencia */
.ship-to-cp { display: block; padding: 10px 16px; font-size: 13px; color: #1565c0; cursor: pointer; border-top: 1px solid #eee; margin-top: 4px; }
.ship-to-cp:hover { background: #f5f5f5; }
.ship-to-cp + .ship-to-add { margin-top: 0; }
.cp-cancel { width: 100%; margin-top: 8px; background: none; border: none; color: #888; font-size: 13px; cursor: pointer; padding: 6px; }

/* ── Carruseles (norma del sitio: ver tienda.js) ── */
.carrusel { overflow-x: auto; scrollbar-width: none; cursor: grab; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.carrusel::-webkit-scrollbar { display: none; }
.carrusel.arrastrando { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.carrusel img { -webkit-user-drag: none; user-select: none; }
.carrusel-lateral { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid #ddd; background: rgba(255,255,255,.95); box-shadow: 0 2px 8px rgba(0,0,0,.12); cursor: pointer; font-size: 22px;
    line-height: 1; display: flex; align-items: center; justify-content: center; color: #555; padding: 0; transition: all .15s; }
.carrusel-lateral:hover { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.carrusel-prev { left: 6px; }
.carrusel-next { right: 6px; }
@media (max-width: 768px) { .carrusel-lateral { display: none !important; } }

/* ── Sugerencias del buscador (todas las páginas; la portada usa las mismas clases) ── */
.search-box { position: relative; }
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.suggestions.active { display: block; }
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 14px;
    color: #333;
}
.suggestion-item:hover { background: #f5f5f5; }
.suggestion-item .sug-icon {
    color: #bbb;
    flex-shrink: 0;
}
.suggestion-item .sug-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.suggestion-item .sug-text b { font-weight: 600; }
/* Corrección de tipeo del buscador */
.sug-corregido { padding: 10px 16px; font-size: 13px; color: #5a5148; cursor: pointer; border-bottom: 1px solid #f0ebe3; }
.sug-corregido:hover { background: #f7f3ec; }
.sug-corregido b { color: #E0895A; font-weight: 600; }
.busqueda-aviso { font-size: 14px; color: #5a5148; margin-bottom: 6px; }
.busqueda-aviso b { color: #1a1a1a; }
.busqueda-aviso a { color: #E0895A; font-weight: 600; text-decoration: none; border-bottom: 1px solid rgba(224,137,90,.4); }
.busqueda-aviso a:hover { border-bottom-color: #E0895A; }
.sug-grupo { font-size: 11px; font-weight: 600; letter-spacing: .6px; color: #999; text-transform: uppercase; padding: 10px 16px 4px; }
.suggestion-item .sug-autor { color: #999; font-size: 12px; flex-shrink: 0; max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-item .sug-cuenta { color: #999; font-size: 12px; flex-shrink: 0; }


/* Etiqueta de idioma en tarjetas de libros (solo libros que no están en español) */
.lang-tag { display: inline-block; align-self: flex-start; font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
            color: #5a5148; background: #F2EBDD; border-radius: 4px; padding: 2px 6px; margin: 2px 0 4px; }
