/* ═══════════════════════════════════════════
   WF POS — Layout & Components
   ═══════════════════════════════════════════ */

.wf-pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar (Products) ─────────────────── */

.wf-pos-sidebar {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    overflow: hidden;
}

.wf-pos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.wf-pos-logo {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.wf-pos-employee {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
}

.wf-pos-employee-name {
    font-weight: 500;
}

.wf-pos-logout-link {
    color: #94a3b8;
    display: flex;
    transition: color 0.2s;
}

.wf-pos-logout-link:hover {
    color: #ef4444;
}

.wf-pos-search-wrap {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.wf-pos-search {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.wf-pos-search:focus {
    border-color: #3b82f6;
    background: #fff;
}

.wf-pos-categories {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.wf-pos-cat-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.wf-pos-cat-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.wf-pos-cat-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Fila de subcategorías: más sutil y compacta. */
.wf-pos-subcategories {
    background: #f8fafc;
    padding-top: 8px;
    padding-bottom: 8px;
}
.wf-pos-subcategories .wf-pos-cat-btn {
    font-size: 12px;
    padding: 5px 12px;
}
.wf-pos-subcategories .wf-pos-cat-btn.active {
    background: #1e293b;
    border-color: #1e293b;
}

/* ── Products grid ──────────────────────── */

.wf-pos-products {
    flex: 1;
    min-height: 0; /* permite el scroll dentro del contenedor flex */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-content: start;
}

.wf-pos-loading,
.wf-pos-no-products {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #94a3b8;
    text-align: center;
}

.wf-pos-product {
    height: 100%;            /* llena la celda del grid (alto fijo calculado por JS) */
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.wf-pos-product:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.wf-pos-product:active {
    transform: scale(0.97);
}

.wf-pos-product-img {
    width: 100%;
    flex: 1 1 auto;           /* la imagen llena el espacio de la celda menos el cuerpo */
    min-height: 0;
    object-fit: cover;
    background: #f8fafc;
    display: block;
}

.wf-pos-product-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}

/* Vídeo como media del producto (custom field que admite vídeo o foto). */
.wf-pos-product-video {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    object-fit: cover;
    background: #0f172a;
    display: block;
}

.wf-pos-product-body {
    padding: 8px 10px;
    flex: 0 0 auto;          /* cuerpo de alto fijo; la imagen ocupa el resto */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wf-pos-product-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wf-pos-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #059669;
    margin-top: 4px;
}

.wf-pos-load-more {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    font-size: 13px;
    color: #3b82f6;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}

.wf-pos-load-more:hover {
    background: #eff6ff;
}

/* ── Main (Cart) ────────────────────────── */

.wf-pos-main {
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.wf-pos-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.wf-pos-cart-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.wf-pos-clear-cart {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.15s;
}

.wf-pos-clear-cart:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

.wf-pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.wf-pos-cart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
    padding: 40px;
}

.wf-pos-cart-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.15s;
}

.wf-pos-cart-item:hover {
    border-color: #cbd5e1;
}

.wf-pos-cart-item-info {
    flex: 1;
    min-width: 0;
}

.wf-pos-cart-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.wf-pos-cart-item-label {
    font-size: 11px;
    color: #64748b;
}

.wf-pos-cart-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wf-pos-qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    color: #475569;
    transition: all 0.15s;
}

.wf-pos-qty-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.wf-pos-cart-item-qty {
    min-width: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.wf-pos-cart-item-total {
    font-size: 14px;
    font-weight: 700;
    color: #059669;
    min-width: 60px;
    text-align: right;
}

.wf-pos-cart-item-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.15s;
}

.wf-pos-cart-item-remove:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* ── Cart Footer ────────────────────────── */

.wf-pos-cart-footer {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.wf-pos-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
}

.wf-pos-payment-methods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
}

.wf-pos-pay-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s;
}

.wf-pos-pay-btn:hover {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.wf-pos-pay-btn:active {
    transform: scale(0.97);
}

/* ── Modal ──────────────────────────────── */

.wf-pos-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.wf-pos-modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 360px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.wf-pos-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.wf-pos-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.wf-pos-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
}

.wf-pos-modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.wf-pos-modal-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wf-pos-modal-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.wf-pos-modal-option:hover {
    background: #f0fdf4;
    border-color: #86efac;
}

.wf-pos-modal-opt-label {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.wf-pos-modal-opt-price {
    font-size: 15px;
    font-weight: 700;
    color: #059669;
}

/* ── Notifications ──────────────────────── */

.wf-pos-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 999999;
    opacity: 0;
    transition: all 0.4s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.wf-pos-notification-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.wf-pos-notification-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.wf-pos-notification-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.wf-pos-notification-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ── Responsive ─────────────────────────── */

/* Tablet / pantallas medianas: carrito algo más estrecho. */
@media (max-width: 1100px) and (min-width: 769px) {
    .wf-pos-layout { grid-template-columns: 1fr 320px; }
}

/* Móvil: layout en columna (productos arriba, carrito abajo), SIN solaparse,
   con scroll real en ambos y SIEMPRE 2 columnas de producto. */
@media (max-width: 768px) {
    .wf-pos-layout {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh; /* respeta la barra del navegador móvil */
    }
    .wf-pos-sidebar {
        flex: 1 1 auto;
        min-height: 0;        /* imprescindible para que los productos scrolleen */
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .wf-pos-products {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 columnas exactas */
        gap: 10px;
        padding: 10px;
    }
    .wf-pos-main {
        position: static;     /* anula cualquier fixed previo */
        flex: 0 0 auto;
        max-height: 42vh;
        box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
    }
    .wf-pos-product-title { font-size: 13px; }
    .wf-pos-header { padding: 10px 14px; }
}

/* Móvil estrecho: tarjetas un poco más compactas pero seguimos en 2 columnas. */
@media (max-width: 380px) {
    .wf-pos-products { gap: 8px; padding: 8px; }
    .wf-pos-product-body { padding: 6px 8px; }
}
