/*
 * POS ACCESO RÁPIDO — ESTILOS v2.0
 * ============================================
 */

/* ---- MODE TABS (bajo el título) ---- */
.pos-mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.75rem;
}

.pos-mode-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
    bottom: -2px;
}

.pos-mode-tab:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.06);
}

.pos-mode-tab-active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--primary);
    border-bottom-color: var(--bg-main);
}

.pos-mode-tab .tab-badge {
    font-size: 0.7rem;
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 20px;
}

/* ---- ACTION BAR (top of QA panel) ---- */
.qa-action-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.qa-action-main {
    flex-shrink: 0;
}

.qa-action-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.2rem;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

.qa-action-btn:hover {
    background: linear-gradient(135deg, #6d28d9, #4c1d95);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.5);
}

.qa-action-btn .fa-print {
    font-size: 1.1rem;
}

.qa-action-label {
    line-height: 1.2;
}

.qa-action-label small {
    font-size: 0.72rem;
    opacity: 0.85;
    display: block;
}

.qa-kbd {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.7rem;
    font-family: monospace;
    margin-left: 0.2rem;
}

.qa-action-secondary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.qa-action-btn-sm {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.qa-action-btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(139, 92, 246, 0.07);
}

/* ---- TOTALS PANEL (dentro de action bar) ---- */
.qa-totals-panel {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    padding: 0.45rem 1rem;
    border-left: 1px solid var(--border);
    min-width: 190px;
}

.qa-totals-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.82rem;
}

.qa-totals-label {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.qa-totals-label small {
    font-size: 0.72rem;
    opacity: 0.75;
}

.qa-totals-val {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.85rem;
}

.qa-totals-tax {
    color: #f59e0b;
}

.qa-totals-total-row {
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
    padding-top: 0.3rem;
}

.qa-totals-total-label {
    color: var(--text-main);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.qa-totals-total {
    color: #10b981;
    font-size: 1rem;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* ---- HEADER GRID (3 panels) ---- */
.qa-header-grid {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1.5fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.qa-panel {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
}

.qa-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Doc panel */
.qa-doc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}

.qa-doc-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 68px;
}

.qa-doc-val {
    color: var(--text-main);
    font-weight: 600;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.85rem;
}

/* Doc type panel */
.qa-doctype-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.qa-type-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.qa-type-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
}

.qa-type-btn.qa-type-active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981;
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.qa-type-btn[data-type="credit"].qa-type-active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.qa-type-btn[data-type="quote"].qa-type-active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.qa-type-num {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.2);
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Client Panel */
.qa-client-info {
    margin-bottom: 0.6rem;
    min-height: 52px;
}

.qa-client-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 0.2rem;
}

.qa-client-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
}

.qa-client-addr {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.qa-client-btns {
    display: flex;
    gap: 0.4rem;
}

.qa-client-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: all 0.15s ease;
    background: transparent;
    color: var(--text-muted);
}

.qa-btn-search:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.06);
}

.qa-btn-edit:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.06);
}

.qa-btn-add:hover {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.06);
}

/* ---- TABLE ---- */
.qa-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.4);
    position: relative;
    /* Important: so modal z-index is relative to this */
}

.qa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0;
}

.qa-table thead th {
    background: rgba(30, 41, 59, 0.9);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.6rem;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
}

.qa-table .qa-col-no {
    width: 36px;
    text-align: center;
}

.qa-table .qa-col-code {
    width: 100px;
}

.qa-table .qa-col-desc {
    min-width: 180px;
}

.qa-table .qa-col-qty {
    width: 80px;
    text-align: right;
}

.qa-table .qa-col-price {
    width: 90px;
    text-align: right;
}

.qa-table .qa-col-total {
    width: 90px;
    text-align: right;
    font-weight: 700;
    color: var(--success);
}

.qa-table .qa-col-del {
    width: 36px;
    text-align: center;
}

.qa-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.1s;
}

.qa-row:hover {
    background: rgba(139, 92, 246, 0.04);
}

.qa-row td {
    padding: 0.3rem 0.5rem;
}

.qa-col-no {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
}

.qa-row-filled {
    background: rgba(16, 185, 129, 0.04);
}

.qa-row-filled:hover {
    background: rgba(16, 185, 129, 0.08);
}

/* Inputs inside table */
.qa-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.3rem 0.4rem;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    /* Ocultar spinners (flechas arriba/abajo) */
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Chrome, Safari, Edge, Opera */
.qa-input::-webkit-outer-spin-button,
.qa-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qa-input:focus {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
}

.qa-input-code {
    font-weight: 700;
    text-transform: uppercase;
}

.qa-input-desc {
    color: var(--text-muted);
}

.qa-input-desc:hover {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.04);
}

.qa-input-qty,
.qa-input-price {
    text-align: right;
}

/* Shake animation */
@keyframes qa-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
    }

    60% {
        transform: translateX(5px);
    }

    80% {
        transform: translateX(-3px);
    }
}

.qa-shake {
    animation: qa-shake 0.4s ease;
    border-color: var(--danger) !important;
}

/* ---- PREMIUM MANUAL PRODUCT MODAL (Dark Glassmorphism) ---- */
.qa-manual-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.qa-manual-box {
    background: rgba(30, 41, 59, 0.85);
    /* Slate 800 blur */
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 440px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: white;
    font-family: inherit;
    overflow: hidden;
    animation: qa-modal-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes qa-modal-in {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.qa-manual-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.qa-manual-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.qa-manual-field {
    display: grid;
    grid-template-columns: 110px 1fr;
    align-items: center;
    gap: 1rem;
}

.qa-manual-label {
    text-align: right;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.qa-manual-input {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 0.95rem;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.qa-manual-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.qa-manual-input-desc {
    border-left: 3px solid var(--primary);
}

.qa-manual-tax-group {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.qa-manual-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s;
}

.qa-manual-radio-label:hover {
    color: white;
}

.qa-manual-radio-label input[type="radio"] {
    accent-color: var(--primary);
}

.qa-manual-footer {
    padding: 1.5rem 2rem 2.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.qa-manual-btn {
    padding: 0.7rem 1.8rem;
    min-width: 120px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.qa-manual-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.qa-manual-btn:first-child {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.qa-manual-btn:first-child:hover {
    background: #7c3aed;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.qa-manual-btn:active {
    transform: translateY(0);
}

/* Delete button */
.qa-del-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    opacity: 0.5;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: opacity 0.15s, background 0.15s;
    font-size: 0.8rem;
}

.qa-del-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}

/* ---- PRODUCT SEARCH MODAL ---- */
/* High z-index so it appears above sticky thead AND the main modal-overlay */
.qa-product-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 99999;
    /* Above everything */
    display: flex;
    align-items: center;
    justify-content: center;
}

.qa-product-modal-content {
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: min(560px, 92vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: qa-modal-in 0.2s ease;
}

@keyframes qa-modal-in {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.qa-product-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem 0.6rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}

.qa-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.qa-modal-close:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.qa-product-search-box {
    margin: 0.75rem 1.2rem;
    padding: 0.65rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
    width: calc(100% - 2.4rem);
}

.qa-product-search-box:focus {
    border-color: var(--primary);
}

.qa-product-results {
    overflow-y: auto;
    flex: 1;
    padding: 0 0.5rem 0.5rem;
}

.qa-product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.qa-product-item:hover {
    background: rgba(139, 92, 246, 0.1);
}

.qa-pi-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.qa-pi-code {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    font-family: monospace;
    text-transform: uppercase;
}

.qa-pi-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
}

.qa-pi-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.qa-pi-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--success, #10b981);
}

.qa-pi-stock {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
}

.qa-stock-ok {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.qa-stock-low {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.qa-stock-zero {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.qa-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Fix: client-modal must appear above the sticky thead (z-index: 2) */
#client-modal {
    z-index: 9999 !important;
}

/* Responsive */
@media (max-width: 900px) {
    .qa-header-grid {
        grid-template-columns: 1fr;
    }

    .qa-doctype-grid {
        flex-direction: row;
    }

    .qa-action-bar {
        flex-wrap: wrap;
    }
}

/* ---- TABLE ACTIONS (Add Row) ---- */
.qa-table-actions {
    display: flex;
    justify-content: flex-start;
    padding: 0.8rem 0;
    margin-top: 0.2rem;
}

.qa-add-row-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    background: rgba(30, 41, 59, 0.4);
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qa-add-row-btn:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    border-style: solid;
}

.qa-add-row-btn i {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* 🛡️ Filtros de Stock en el Modal */
.qa-product-modal-filters {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 1.2rem 1rem;
}

.qa-stock-filter-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.qa-stock-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.qa-stock-filter-btn.active {
    background: var(--primary-light, rgba(139, 92, 246, 0.2));
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.qa-pi-stock.qa-stock-zero {
    color: var(--danger) !important;
}

.qa-pi-stock.qa-stock-low {
    color: var(--warning) !important;
}

.qa-pi-stock.qa-stock-ok {
    color: var(--success) !important;
}