/* =====================================================================
   ÓpticaPro - Estilos del frontend público
   v1.8.0 (Fase 9 - Optimización)
   ===================================================================== */

:root {
    --primary: #0066CC;
    --primary-dark: #004999;
    --secondary: #FF6B35;
    --text: #2c3e50;
    --text-muted: #6c757d;
    --bg: #ffffff;
    --bg-alt: #f8f9fa;
    --border: #e9ecef;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Bootstrap se importa desde CDN. Sobrescribimos algunas cosas: */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ============ HEADER ============ */
.site-header { position: sticky; top: 0; z-index: 1000; background: #fff; }
.site-header .topbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 6px 0;
    font-size: 0.85rem;
}
.site-header .topbar a:hover { color: #fff; }
.navbar-brand { font-size: 1.4rem; }
.navbar .nav-link { font-weight: 500; }
.navbar .nav-link:hover { color: var(--primary); }

#searchResults .search-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; cursor: pointer;
    border-bottom: 1px solid var(--border);
    color: inherit; text-decoration: none;
}
#searchResults .search-result-item:hover { background: #f8fbff; }
#searchResults .search-result-item img {
    width: 40px; height: 40px; object-fit: cover; border-radius: 4px;
    background: #f8f9fa;
}
#searchResults .search-result-item .name { font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
#searchResults .search-result-item .meta { font-size: 0.75rem; color: var(--text-muted); }
#searchResults .search-result-item .price { color: var(--primary); font-weight: 700; font-size: 0.85rem; margin-left: auto; }

/* ============ PAGE HEADER ============ */
.page-header {
    background: var(--bg-alt);
    padding: 32px 0;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 1.75rem; margin-bottom: 4px; }

/* ============ HERO ============ */
.hero { padding: 80px 0; }
.hero h1 { font-size: 2.5rem; }
@media (max-width: 768px) {
    .hero h1 { font-size: 1.8rem; }
}

/* ============ CATEGORY TILES ============ */
.category-tile .card { transition: transform var(--transition), box-shadow var(--transition); }
.category-tile:hover .card { transform: translateY(-4px); box-shadow: var(--shadow-md); }

/* ============ PRODUCT GRID ============ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
@media (max-width: 576px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* ============ PRODUCT CARD ============ */
.product-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex; flex-direction: column;
    position: relative;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.product-card__image {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-alt);
    position: relative;
}
.product-card__image img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.3s ease;
}
.product-card:hover .product-card__image img { transform: scale(1.05); }

.product-badge {
    position: absolute; top: 10px; left: 10px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.7rem; font-weight: 700;
    color: #fff;
    z-index: 1;
}
.product-badge--sale { background: #e63946; }
.product-badge--new { background: #1d9bf0; }
.product-badge--featured { background: #f59f00; color: #fff; }

.product-card__body {
    padding: 12px;
    display: flex; flex-direction: column; flex-grow: 1;
}
.product-card__title {
    font-size: 0.95rem;
    margin: 0 0 8px;
    line-height: 1.3;
    min-height: 2.5em;
}
.product-card__title a {
    color: var(--text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card__title a:hover { color: var(--primary); }

.product-card__price { margin-bottom: 10px; }
.product-card__price .price-old {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: line-through;
    margin-right: 6px;
}
.product-card__price .price-current {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}
.product-card__actions {
    margin-top: auto;
    display: flex; gap: 6px;
}

/* ============ FILTERS SIDEBAR ============ */
.filter-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.filter-panel h5 {
    font-size: 0.95rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.filter-list { list-style: none; padding: 0; margin: 0; }
.filter-list li { margin-bottom: 6px; }
.filter-list a {
    display: block;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background var(--transition);
}
.filter-list a:hover { background: var(--bg-alt); color: var(--primary); }
.filter-list a.active { background: var(--primary); color: #fff; }
.filter-list a.active small { color: rgba(255,255,255,0.8); }

/* ============ PRODUCT GALLERY (detalle) ============ */
.product-gallery__main img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--bg-alt);
}
.product-gallery__thumbs .thumb {
    width: 70px; height: 70px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
    background: var(--bg-alt);
}
.product-gallery__thumbs .thumb:hover { border-color: var(--primary); }
.product-gallery__thumbs .thumb.active { border-color: var(--primary); }

/* ============ FOOTER ============ */
.site-footer {
    background: #1a2332;
    color: #adb5bd;
    padding: 50px 0 20px;
    margin-top: 60px;
}
.site-footer .footer-title {
    color: #fff;
    font-size: 1.05rem;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.site-footer .footer-list {
    list-style: none; padding: 0; margin: 0;
}
.site-footer .footer-list li { margin-bottom: 8px; font-size: 0.9rem; }
.site-footer a { color: #adb5bd; text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer .social-row { display: flex; gap: 14px; margin-top: 14px; font-size: 1.4rem; }
.site-footer .footer-sep { border-color: #2c3e50; margin: 30px 0 16px; }

/* ============ FLOATING WHATSAPP ============ */
.wa-floating {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px;
    background: #25d366;
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    box-shadow: 0 4px 16px rgba(37,211,102,0.4);
    z-index: 1000;
    transition: transform var(--transition);
    text-decoration: none;
}
.wa-floating:hover { transform: scale(1.1); color: #fff; }
.wa-floating::before {
    content: ''; position: absolute; inset: -4px;
    border-radius: 50%; border: 2px solid #25d366;
    opacity: 0.6;
    animation: wa-pulse 2s infinite;
}
@keyframes wa-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ============ FLASH MESSAGES ============ */
.flash {
    padding: 14px 20px; border-radius: var(--radius); margin-bottom: 16px;
    border-left: 4px solid;
    max-width: 1200px;
    margin: 0 auto 16px;
}
.flash-success { background: #d4edda; border-color: #28a745; color: #155724; }
.flash-error   { background: #f8d7da; border-color: #dc3545; color: #721c24; }
.flash-warning { background: #fff3cd; border-color: #fd7e14; color: #856404; }
.flash-info    { background: #d1ecf1; border-color: #17a2b8; color: #0c5460; }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 4rem; color: #dee2e6; }

/* ============ ACCESSIBILITY ============ */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============ RESPONSIVE TWEAKS ============ */
@media (max-width: 768px) {
    .wa-floating { width: 52px; height: 52px; font-size: 1.7rem; bottom: 18px; right: 18px; }
    .page-header { padding: 24px 0; }
    .page-header h1 { font-size: 1.4rem; }
    .hero { padding: 50px 0; }
    .site-footer { padding: 36px 0 16px; }
}

/* =====================================================================
   FASE 3 - E-COMMERCE
   ===================================================================== */

/* ============ KPI CARDS (admin) ============ */
.kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.kpi-card small {
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.kpi-card strong {
    display: block;
    font-size: 1.5rem;
    color: var(--text);
}

/* ============ CART TABLE ============ */
.cart-table thead th {
    background: var(--bg-alt);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}
.qty-control .qty-btn {
    border-color: var(--border);
    background: #fff;
    color: var(--text);
    padding: 4px 10px;
}
.qty-control .qty-btn:hover {
    background: var(--bg-alt);
    color: var(--primary);
}
.qty-control .qty-input {
    -moz-appearance: textfield;
}
.qty-control .qty-input::-webkit-outer-spin-button,
.qty-control .qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============ CHECKOUT ============ */
.checkout-page .card-title .badge {
    width: 28px; height: 28px;
    display: inline-flex;
    align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
}

/* ============ THANKS PAGE ============ */
.thanks-page .page-header { display: none; }

/* ============ TOAST ============ */
.opt-toast {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1100;
    border-left: 4px solid;
    min-width: 280px;
    max-width: 380px;
    animation: opt-toast-in 0.25s ease-out;
}
.opt-toast--success { border-color: #28a745; }
.opt-toast--error { border-color: #dc3545; }
.opt-toast--info { border-color: var(--primary); }
.opt-toast__icon { font-size: 1.5rem; }
.opt-toast--success .opt-toast__icon { color: #28a745; }
.opt-toast--error .opt-toast__icon { color: #dc3545; }
.opt-toast--info .opt-toast__icon { color: var(--primary); }
.opt-toast__msg { flex-grow: 1; font-size: 0.9rem; }
.opt-toast__action {
    background: var(--primary); color: #fff;
    padding: 4px 10px; border-radius: 4px;
    text-decoration: none; font-size: 0.85rem;
}
.opt-toast__action:hover { background: var(--primary-dark); color: #fff; }
@keyframes opt-toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============ ADMIN PANELS ============ */
.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    overflow: hidden;
}
.panel-header {
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}
.panel-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.panel-body { padding: 22px; }

/* ============ SIDEBAR BADGE COUNTERS ============ */
.sidebar-nav .nav-link .badge.ms-auto {
    margin-left: auto !important;
    font-size: 0.65rem;
    padding: 3px 7px;
}

/* =====================================================================
   FASE 4 - WhatsApp Leads
   ===================================================================== */

/* WhatsApp inquiry modal — botón flotante con clase wa-inquiry-btn */
button.wa-floating {
    border: none;
    cursor: pointer;
}

/* Modal en mobile, ocupa más altura */
@media (max-width: 576px) {
    #waInquiryModal .modal-body { padding: 14px; }
    #waInquiryModal .modal-dialog { margin: 8px; }
}

/* Lead status badges con tamaño un poco mayor en el detalle */
.panel-body .badge { font-size: 0.8rem; }

/* Form de conversión — items en filas */
.order-item {
    background: var(--bg-alt);
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.order-item:last-child { margin-bottom: 0; }

/* Resultados de búsqueda de productos en el form de conversión */
#productSearchResults { border: 1px solid var(--border); border-radius: 6px; }
#productSearchResults .list-group-item:hover { background: var(--bg-alt); cursor: pointer; }

/* ===== Fase 5 - Afiliados ===== */
.copy-btn { transition: all 0.15s ease; }
.copy-btn.btn-success { background: var(--bs-success); color: #fff; border-color: var(--bs-success); }
#productResults .product-result { cursor: pointer; }
#productResults .product-result:hover { background: var(--bs-light); }
.affiliate-link-input { font-family: monospace; font-size: 0.875rem; }

/* ===== Fase 6 - Herramientas visuales ===== */
.tool-card { transition: transform .15s, box-shadow .15s; cursor: pointer; }
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.1); }

/* ===== Fase 7 - Blog & Páginas ===== */
.blog-content, .page-content { font-size: 1.05rem; line-height: 1.7; }
.blog-content h2, .page-content h2 { margin-top: 2rem; margin-bottom: 1rem; font-weight: 600; }
.blog-content h3, .page-content h3 { margin-top: 1.5rem; margin-bottom: .75rem; font-weight: 600; }
.blog-content img, .page-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 1rem 0; }
.blog-content blockquote, .page-content blockquote { border-left: 4px solid var(--primary, #0066CC); padding-left: 1rem; margin: 1rem 0; color: #555; font-style: italic; }
.blog-content ul, .blog-content ol, .page-content ul, .page-content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.blog-content table, .page-content table { width: 100%; margin: 1rem 0; border-collapse: collapse; }
.blog-content th, .page-content th, .blog-content td, .page-content td { border: 1px solid #ddd; padding: 8px; }

/* ===== Fase 8 - PWA install prompt + update toast ===== */
.pwa-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1080;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
    border: 1px solid rgba(0,0,0,.08);
    max-width: 420px;
    width: calc(100% - 32px);
    animation: pwaSlideUp .35s ease-out;
}
.pwa-toast-body {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}
.pwa-toast-body > i {
    font-size: 1.6rem;
    color: var(--primary, #0066CC);
    flex-shrink: 0;
}
.pwa-toast-text { flex: 1; min-width: 0; }
.pwa-toast-text strong { display: block; font-size: .95rem; }
.pwa-toast-text small { display: block; color: #666; font-size: .8rem; }
@keyframes pwaSlideUp {
    from { opacity: 0; transform: translate(-50%, 30px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
@media (display-mode: standalone) {
    /* Estamos en PWA instalada — pequeños ajustes opcionales */
    body { user-select: none; -webkit-user-select: none; }
    body input, body textarea, body [contenteditable] { user-select: text; -webkit-user-select: text; }
}

/* ===== Fase 8 - Page header SEO genérico (breadcrumb + h1) ===== */
.seo-breadcrumb {
    background: #f8f9fa;
    padding: 12px 0;
    margin-bottom: 0;
    font-size: .875rem;
}
.seo-breadcrumb a { color: var(--primary, #0066CC); text-decoration: none; }
.seo-breadcrumb a:hover { text-decoration: underline; }
.seo-breadcrumb .sep { color: #adb5bd; margin: 0 6px; }

/* ===== Lazy loading: placeholder skeleton ===== */
img[loading="lazy"] {
    background: #f0f0f0;
    background: linear-gradient(90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}
img[loading="lazy"].loaded,
img[loading="lazy"][src]:not([src=""]) {
    animation: none;
    background: none;
}
@keyframes imageShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
