/* =========================================
   PAGOR PDV - STYLESYSTEM (UPDATED)
   ========================================= */
:root {
    --pdv-primary: #8C52FF;
    --pdv-primary-hover: #7b42f6;
    --pdv-bg: #F4F6F9;
    --pdv-white: #FFFFFF;
    --pdv-text: #333333;
    --pdv-gray-light: #E0E0E0;
    --pdv-gray-bg: #F8F9FA;
    --pdv-radius: 12px;
    --pdv-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: flex !important;
}

@media (max-width: 1023px) {
    .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* CONTAINER LAYOUT */
#pagor-pdv-app {
    display: grid;
    grid-template-columns: 80px 1fr 350px;
    height: calc(100vh - 40px);
    gap: 20px;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
    overflow: hidden;
    max-width: 100%;
}

/* Hide Cart Modifier */
#pagor-pdv-app.pdv-no-cart {
    grid-template-columns: 80px 1fr;
}

#pagor-pdv-app.pdv-no-cart .pdv-cart-column {
    display: none !important;
}

#pagor-pdv-app * {
    box-sizing: border-box;
}

/* --- 1. SIDEBAR NAV (Mini) --- */
.pdv-sidebar {
    background: var(--pdv-white);
    border-radius: var(--pdv-radius);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: var(--pdv-shadow);
    overflow-y: auto;
    /* Enable vertical scrolling */
    height: 100%;
    /* Ensure it fills the grid height */
}

.pdv-menu-item {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    transition: all 0.2s ease;
}

.pdv-menu-item:hover {
    background: #f0f0f0;
    color: var(--pdv-primary);
}

.pdv-menu-item.active {
    background: #F4ECF7;
    color: var(--pdv-primary);
}

.pdv-menu-item .icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.pdv-menu-item .label {
    font-size: 12px;
    font-weight: 600;
}

/* --- 2. MAIN CONTENT (Products) --- */
/* Main Content */
.pdv-main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 100%;
}

.pdv-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border-radius: 12px;
}

/* Header (Global/Caixa) */
.pdv-header-caixa {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 20px;
}

.pdv-search-bar {
    flex: 1;
    background: var(--pdv-white);
    border-radius: var(--pdv-radius);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--pdv-shadow);
}

.pdv-search-bar input {
    border: none;
    width: 100%;
    font-size: 15px;
    outline: none;
    background: transparent;
}

.btn-scanner-trigger {
    background: #f0f0f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: 0.2s;
    color: var(--pdv-primary);
}

.btn-scanner-trigger:hover {
    background: var(--pdv-primary);
    color: white;
}

/* MODERN HEADER (Subpages) */
.pdv-view-header-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    background: white;
    padding: 20px;
    border-radius: var(--pdv-radius);
    box-shadow: var(--pdv-shadow);
}

/* Button Refinement (+ Novo Produto / + Novo Item) */
.btn-new-product,
.btn-new-item {
    background: linear-gradient(135deg, var(--pdv-primary), #a881fb) !important;
    color: white !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(140, 82, 255, 0.3) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-new-product:hover,
.btn-new-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(140, 82, 255, 0.4) !important;
    opacity: 0.95;
}

.btn-new-product:active,
.btn-new-item:active {
    transform: translateY(0);
}

.btn-manual-sale {
    background: #10b981 !important;
    color: white !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-right: 10px;
}

.btn-manual-sale:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4) !important;
    opacity: 0.95;
}

.btn-manual-sale:active {
    transform: translateY(0);
}

/* Mobile Bottom Scanner Button */
.pdv-sidebar .mobile-only .icon {
    font-size: 24px;
    color: var(--pdv-primary);
}

.pdv-header-info h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.pdv-header-info .subtitle {
    margin: 5px 0 0;
    color: #888;
    font-size: 13px;
}

.pdv-header-actions {
    display: flex;
    gap: 15px;
}

.pdv-mini-search {
    background: #f4f6f9;
    padding: 8px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    transition: 0.2s;
    width: 250px;
}

.pdv-mini-search:focus-within {
    border-color: var(--pdv-primary);
    background: white;
}

.pdv-mini-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    width: 100%;
}

.btn-new-item {
    background: var(--pdv-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}

.btn-new-item:hover {
    background: var(--pdv-primary-hover);
    transform: translateY(-2px);
}

/* MODERN TABLE */
.pdv-modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.pdv-modern-table thead th {
    text-transform: uppercase;
    font-size: 11px;
    color: #888;
    padding: 0 15px 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: left;
    /* Align with TDs */
}

.pdv-modern-table thead th:last-child {
    text-align: right;
    /* Match Action column */
}

.pdv-modern-table tbody tr {
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s;
}

.pdv-modern-table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.pdv-modern-table td {
    padding: 15px;
    vertical-align: middle;
    color: #555;
    font-size: 14px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.pdv-modern-table td:first-child {
    border-left: 1px solid #eee;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.pdv-modern-table td:last-child {
    border-right: 1px solid #eee;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    text-align: right;
}

.fw-bold {
    font-weight: 600;
    color: #333;
}

.text-muted {
    color: #999;
    font-size: 12px;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Badges */
.pdv-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-active,
.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-purple {
    background: #f3e8ff;
    color: #7e22ce;
}

/* Actions */
.pdv-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: 0.2s;
}

.btn-view-modern {
    background: #6366f1;
    color: white !important;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}

.btn-view-modern:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-view-modern:active {
    transform: translateY(0);
}

.btn-edit {
    background: #E3F2FD;
    color: #1976D2;
}

.btn-edit:hover {
    background: #BBDEFB;
}

.btn-delete {
    background: #FFEBEE;
    color: #D32F2F;
}

.btn-delete:hover {
    background: #FFCDD2;
}

.btn-label {
    background: #F3E5F5;
    color: #8C52FF;
}

.btn-label:hover {
    background: #E1BEE7;
}

/* Grid Products */
.pdv-view {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    padding-bottom: 20px;
}

.pdv-grid-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding-bottom: 20px;

}

.pdv-product-card {
    background: var(--pdv-white);
    border-radius: var(--pdv-radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--pdv-shadow);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    /* Hit draggable */
    user-select: none;
    -webkit-user-select: none;
}

.pdv-product-card:active,
.pdv-product-card.pdv-card-active {
    transform: scale(0.98);
    background: #fdfdfd;
    cursor: grabbing;
}

.pdv-product-card:hover {
    transform: translateY(-5px);
}

.pdv-prod-image {
    width: 120px;
    height: 120px;
    margin-bottom: 15px;
    object-fit: contain;
}

.pdv-prod-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pdv-product-card h4 {
    font-size: 16px;
    margin: 10px 0;
    color: #333;
    font-weight: 600;
}

.pdv-product-card .price {
    font-size: 18px;
    font-weight: 800;
    color: #00C853;
    /* Green price */
    margin-bottom: 15px;
}

.btn-add-cart {
    background: var(--pdv-primary);
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-add-cart:hover {
    background: var(--pdv-primary-hover);
}

.pdv-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* --- 3. CART COLUMN --- */
.pdv-cart-column {
    background: var(--pdv-white);
    border-radius: var(--pdv-radius);
    box-shadow: var(--pdv-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdv-cart-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdv-cart-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.pdv-cart-header .item-count {
    font-size: 12px;
    color: #888;
}

.pdv-cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #FAFAFA;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    align-items: center;
}

.cart-item .info {
    flex: 1;
    text-align: left;
}

.cart-item .title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.cart-item .meta {
    font-size: 12px;
    color: #888;
}

.cart-item .actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-item .price {
    font-weight: 700;
    color: #333;
}

.btn-remove {
    background: #FFEBEE;
    color: #D32F2F;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdv-empty-cart {
    text-align: center;
    color: #999;
    margin-top: 50px;
    font-size: 14px;
}

.pdv-cart-footer {
    padding: 20px;
    background: var(--pdv-white);
    border-top: 1px solid #f0f0f0;
}

/* Client Selector in Footer */
.pdv-client-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F4F6F9;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.pdv-select-box {
    width: 100%;
    margin-right: 10px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    color: #333;
}

.pdv-client-selector label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    pointer-events: none;
}

.btn-add-client-mini {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    line-height: normal;
    text-align: center;
    padding: 0;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.btn-add-client-mini:hover {
    background: #e0e0e0;
}

/* Totals */
.pdv-totals {
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.btn-finalize-sale {
    width: 100%;
    background: var(--pdv-primary);
    color: white;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s;
}

.btn-finalize-sale:hover {
    background: var(--pdv-primary-hover);
    transform: translateY(-2px);
}

.btn-finalize-sale:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* MODAL STYLES REFINED */
.pdv-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    /* Slightly darker/modern */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    padding: 20px;
}

.pdv-modal-container {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    padding: 35px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: pdvModalSlideUp 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

@keyframes pdvModalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pdv-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.pdv-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.pdv-modal-body h3 {
    margin: 0 0 25px;
    color: #0f172a;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

/* FORM FIELDS REFINEMENT */
.pdv-input {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #1e293b;
    transition: all 0.2s;
    background: #f8fafc;
    box-sizing: border-box !important;
    display: block;
}

.pdv-input:focus {
    outline: none;
    border-color: var(--pdv-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(140, 82, 255, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

/* ORDER DETAILS (SINGLE VIEW) STYLES */
.pdv-order-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.pdv-order-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .pdv-order-main-grid {
        grid-template-columns: 1fr;
    }
}

.pdv-order-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid #e2e8f0;
}

.pdv-order-section .section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #cbd5e1;
}

.pdv-order-section .section-header .icon {
    font-size: 20px;
    color: var(--pdv-primary);
}

.pdv-order-section .section-header h4 {
    margin: 0;
    font-size: 16px;
    color: #0f172a;
    font-weight: 700;
}

.pdv-order-section .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.pdv-order-section .info-row strong {
    color: #64748b;
}

.pdv-order-section .info-row span {
    color: #0f172a;
    font-weight: 500;
    text-align: right;
}

.pdv-order-section .info-row.highlight {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    font-size: 18px;
}

.pdv-order-section .info-row.highlight span {
    color: var(--pdv-primary);
    font-weight: 800;
}

.pdv-loading-placeholder {
    padding: 100px;
    text-align: center;
    color: #94a3b8;
    font-style: italic;
}

.payment-methods-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.pay-method {
    background: #f8f9fa;
    border: 1px solid #eee;
    padding: 20px 10px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.pay-method:hover {
    background: var(--pdv-primary);
    color: white;
    border-color: var(--pdv-primary);
    transform: translateY(-3px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 1023px) {
    #pagor-pdv-app {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
        padding-bottom: 80px;
        /* Space for footer menu */
        background: #F4F6F9;
        padding-top: 20px;
    }

    /* Sidebar shifts to bottom fixed menu */
    .pdv-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
        border-radius: 20px 20px 0 0;
        z-index: 1000;
        padding: 10px;
        height: 70px;
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
    }

    .pdv-menu-item {
        flex: 1;
        height: 100%;
    }

    /* Main Content stacks */
    .pdv-main-content,
    .pdv-view,
    .pdv-panel {
        display: contents;
        /* Unwraps containers to allow global ordering */
    }

    .pdv-header-caixa,
    .pdv-view-header-modern {
        order: 1;
        display: flex;
        gap: 15px;
        padding: 0 15px;
        margin-bottom: 20px !important;
        width: 100%;
    }

    .pdv-header-caixa {
        flex-direction: column-reverse;
        /* Button on TOP for Caixa */
    }

    .pdv-view-header-modern {
        flex-direction: column;
        /* Title on TOP for other pages */
    }

    .pdv-header-info h3 {
        font-size: 18px;
    }

    .pdv-header-info .subtitle {
        font-size: 12px;
    }

    .pdv-header-actions {
        width: 100%;
        display: flex;
        flex-direction: column-reverse;
        /* Button on TOP on mobile inside secondary views */
        gap: 10px;
    }

    .pdv-mini-search {
        width: 100% !important;
        max-width: none;
    }

    .btn-new-product,
    .btn-new-item {
        width: 100%;
        justify-content: center;
        padding: 12px !important;
        text-align: center;
    }

    .pdv-cart-column {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        height: auto;
        padding: 0 15px;
        margin: 0 0 25px 0;
        box-shadow: none;
        order: 2;
        /* Cart BETWEEN header and products */
        z-index: 10;
    }

    .pdv-view {
        padding: 0;
        overflow: visible;
    }

    /* Content AT THE BOTTOM - Shared order */
    .pdv-grid-products,
    .pdv-table-responsive,
    #pdv-home-grid-container,
    #pdv-sales-history-container,
    #pdv-clients-list-container,
    #pdv-products-list-container,
    #pdv-reports-table-container,
    #pdv-shift-active-content,
    #pdv-shift-closed-content,
    #pdv-shifts-history-container,
    #pdv-order-details-content,
    #pdv-appointments-list-container {
        order: 3;
        padding: 0 15px;
        margin-bottom: 40px;
        width: 100%;
    }

    .pdv-grid-products {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    .pdv-table-responsive,
    #pdv-reports-table-container,
    #pdv-sales-history-container,
    #pdv-clients-list-container,
    #pdv-products-list-container,
    #pdv-online-orders-container,
    #pdv-appointments-list-container,
    #pdv-shifts-history-container,
    #pdv-shift-active-content {
        display: block !important;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Adjust product card for smaller columns if needed */
    .pdv-product-card {
        padding: 15px 10px;
    }

    .pdv-prod-image {
        width: 100px;
        height: 100px;
    }
}

/* =========================================
   PAGOR PDV - DRAG & DROP EXTENSION
   ========================================= */

/* Dragging visual states */
.pdv-product-card.dragging-source {
    opacity: 0.4;
    filter: grayscale(100%);
}

.pdv-drag-ghost {
    position: fixed;
    z-index: 2147483647;
    /* Max Z-Index possible */
    pointer-events: none !important;
    /* CRITICAL: Allows mouse events to pass through to dropzone */
    background: var(--pdv-white);
    padding: 10px;
    border-radius: var(--pdv-radius);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    width: 200px;
    /* Fixed width for consistency while dragging */
    opacity: 0.9;
    transform: scale(1.05) rotate(2deg);
    transform-origin: center;
    border: 2px solid var(--pdv-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pdv-drag-ghost img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
}

.pdv-drag-ghost h4,
.pdv-drag-ghost button,
.pdv-drag-ghost .price {
    display: none;
    /* Hide details, show only image/style for clean drag */
}

/* Dropzone States */
.pdv-cart-column {
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), border 0.2s, box-shadow 0.2s;
    position: relative;
}

.pdv-cart-column.drag-hover {
    border: 2px dashed var(--pdv-primary) !important;
    background: #F0EAFA !important;
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(140, 82, 255, 0.2);
}



/* Payment Selector Styles - Enhanced */
.pdv-payment-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2x2 grid */
    gap: 10px;
    margin-bottom: 20px;
}

.pdv-pay-option {
    background: #F4F6F9;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    padding: 12px 5px;
    /* More space */
    display: flex;
    flex-direction: column;
    /* Stack Icon + Text */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    height: auto;
    min-height: 70px;
}

.pdv-pay-option .icon {
    font-size: 20px;
    margin-bottom: 5px;
}

.pdv-pay-option .label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-align: center;
    line-height: 1.2;
}

.pdv-pay-option:hover {
    background: #fff;
    border-color: var(--pdv-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.pdv-pay-option.selected {
    background: var(--pdv-primary);
    border-color: var(--pdv-primary);
    box-shadow: 0 4px 10px rgba(140, 82, 255, 0.3);
}

.pdv-pay-option.selected .label,
.pdv-pay-option.selected .icon {
    color: white;
}

/* Mobile cart toggle hint */
/* Mobile cart toggle hint disabled as cart is now always on top */
/* 
@media (max-width: 1023px) {
    .pdv-cart-toggle-hint {
        position: fixed;
        bottom: 90px;
        right: 20px;
        background: var(--pdv-primary);
        color: white;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(140, 82, 255, 0.4);
        z-index: 1090;
        cursor: pointer;
    }
}
*/

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.pop-anim {
    animation: pop 0.3s ease;
}

/* =========================================
   PAGOR PDV - REPORTS EXTENSION
   ========================================= */

.pdv-reports-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.pdv-stat-box {
    background: var(--pdv-white);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #f1f1f1;
    display: flex;
    flex-direction: column;
    box-shadow: var(--pdv-shadow);
    transition: transform 0.2s ease;
}

.pdv-stat-box:hover {
    transform: translateY(-3px);
}

.pdv-stat-box.accent {
    background: linear-gradient(135deg, var(--pdv-primary) 0%, #6A3DE8 100%);
    color: white;
    border: none;
}

.pdv-stat-box .label {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pdv-stat-box.accent .label {
    color: rgba(255, 255, 255, 0.82);
}

.pdv-stat-box .value {
    font-size: 28px;
    font-weight: 800;
    color: var(--pdv-text);
    letter-spacing: -1px;
}

.pdv-stat-box.accent .value {
    color: white;
}

.pdv-date-filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    padding: 6px 15px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.pdv-input-date {
    border: none;
    background: transparent;
    font-size: 14px;
    color: #495057;
    font-weight: 600;
    outline: none !important;
    font-family: 'Inter', sans-serif;
}

.btn-refresh-report {
    background: var(--pdv-primary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-print-report {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-print-report:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-refresh-report:hover {
    background: var(--pdv-primary-hover);
    box-shadow: 0 4px 10px rgba(140, 82, 255, 0.2);
}

.pdv-badge.badge-info {
    background: #E0F2F1;
    color: #00796B;
}

#pdv-reports-table-container {
    transition: opacity 0.3s ease;
}

/* PDOR PDV - CHANGE LOGIC (TROCO) */
.pdv-change-logic {
    background: #f8fafc;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    animation: fadeIn 0.3s ease;
}

.change-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.change-row:last-child {
    margin-bottom: 0;
}

.change-row label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.pdv-input-received {
    width: 100px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 700;
    text-align: right;
    color: #1e293b;
    outline: none;
    transition: 0.2s;
}

.pdv-input-received:focus {
    border-color: var(--pdv-primary);
    box-shadow: 0 0 0 3px rgba(140, 82, 255, 0.1);
}

.change-row.result {
    padding-top: 10px;
    border-top: 1px dashed #cbd5e1;
    margin-top: 10px;
}

.change-row.result span:first-child {
    font-weight: 700;
    color: #1e293b;
}

#pdv-change-result {
    font-size: 16px;
    font-weight: 800;
    color: #10b981;
}

@media (max-width: 768px) {
    .pdv-date-filter-group {
        width: 100%;
        justify-content: space-between;
    }
}

/* SHIFT LOCK OVERLAY */
.pdv-shift-lock {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.lock-content {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    animation: slideUp 0.4s ease;
}

.lock-icon {
    font-size: 50px;
    margin-bottom: 20px;
}

.lock-content h3 {
    font-size: 24px;
    color: #1e293b;
    margin-bottom: 10px;
}

.lock-content p {
    color: #64748b;
    margin-bottom: 25px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* MODAL ADJUSTMENTS FOR SHIFT */
.pdv-modal-field {
    margin-bottom: 20px;
}

.pdv-modal-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.pdv-modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}

.pdv-modal-input:focus {
    border-color: var(--pdv-primary);
}

@media (max-width: 1023px) {
    .pdv-menu-item.desktop-only {
        display: none !important;
    }
}

/* Styles for icons in global popup PDV menu */
.menu-pdv-specific .popup-menu-item span {
    font-size: 20px;
}

/* Sync Page visibility utilities */
.mobile-only-content {
    display: none !important;
}

.desktop-only-content {
    display: block !important;
}

@media (max-width: 1023px) {
    .mobile-only-content {
        display: block !important;
    }

    .desktop-only-content {
        display: none !important;
    }
}

@keyframes pdv-wait-pulse {
    0% {
        background-color: #f8fafc;
        border-color: var(--pdv-primary);
    }

    50% {
        background-color: #f0f7ff;
        border-color: #4b8df8;
    }

    100% {
        background-color: #f8fafc;
        border-color: var(--pdv-primary);
    }
}

/* QR Registration Form Grid */
.pdv-qr-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 1024px) {
    .pdv-qr-form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
        margin-top: 15px;
    }

    .pdv-qr-register-container {
        order: 2;
        /* After modernized header */
        background: white;
        margin: 0 15px 40px;
        padding: 25px 20px;
        border-radius: var(--pdv-radius);
        box-shadow: var(--pdv-shadow);
        box-sizing: border-box;
        display: block !important;
        width: auto !important;
        /* Allow margins to work without forcing 100% width overflow */
        max-width: calc(100% - 30px);
        /* Safety constraint */
        margin-left: 15px !important;
        margin-right: 15px !important;
    }

    /* Adjust inputs inside this grid to never overflow */
    .pdv-qr-form-grid .pdv-input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.pdv-btn-secondary {
    padding: 10px 20px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #475569;
    transition: all 0.2s;
}

.pdv-btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* PAGINATION */
.pdv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 25px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pdv-page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pdv-page-link:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #f5f3ff;
}

.pdv-page-link.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.pdv-page-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

.pdv-page-link.prev,
.pdv-page-link.next {
    font-size: 18px;
}

@media (max-width: 768px) {
    .pdv-pagination {
        gap: 5px;
    }

    .pdv-page-link {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
        padding: 0 8px;
    }
}

/* --- SETTINGS TOGGLE (PAGOR SWITCH) --- */
.pagor-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.pagor-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pagor-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 34px;
}

.pagor-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.pagor-switch input:checked+.slider {
    background-color: var(--pdv-primary);
}

.pagor-switch input:checked+.slider:before {
    transform: translateX(20px);
}

/* --- IMPORTADOR MERCADO LIVRE --- */
.pdv-import-container {
    max-width: 800px;
    margin: 0 auto;
}

.pdv-alert {
    font-size: 14px;
    font-weight: 500;
}

#pdv_ipml_preview_content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ipml-preview-item {
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

.ipml-preview-image {
    width: 180px;
    height: 180px;
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ipml-preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ipml-preview-details {
    flex: 1;
}

.ipml-preview-details h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #1e293b;
    font-weight: 700;
}

.ipml-preview-details p {
    margin: 5px 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.4;
}

.ipml-preview-details strong {
    color: #334155;
}

@media (max-width: 768px) {
    .ipml-preview-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .pdv-import-form div {
        flex-direction: column;
    }

    #pdv_ipml_parse_button {
        width: 100%;
    }
}

/* CENTER BUTTON IN LOCK OVERLAY */
.lock-content .btn-new-item {
    margin-left: auto;
    margin-right: auto;
    display: flex;
}

/* --- CATEGORY FILTER BAR --- */
.pdv-categories-filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 5px 2px 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--pdv-primary) transparent;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.pdv-categories-filter-bar.active-dragging {
    cursor: grabbing;
}

.pdv-categories-filter-bar::-webkit-scrollbar {
    height: 4px;
}

.pdv-categories-filter-bar::-webkit-scrollbar-thumb {
    background: var(--pdv-primary);
    border-radius: 10px;
}

.pdv-cat-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 12px 20px;
    border-radius: 14px;
    min-width: 90px;
    cursor: pointer;
    box-shadow: var(--pdv-shadow);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.pdv-cat-filter-btn.active {
    background: var(--pdv-primary);
    color: white;
    border-color: var(--pdv-primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(140, 82, 255, 0.3);
}

.pdv-cat-filter-btn .cat-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 18px;
    transition: inherit;
}

.pdv-cat-filter-btn.active .cat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.pdv-cat-filter-btn .cat-name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* Category Management in Settings */
.pdv-category-mgr-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    padding: 20px;
}

.pdv-category-form-wrap {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--pdv-shadow);
    border: 1px solid #e2e8f0;
}

.pdv-categories-list-wrap {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--pdv-shadow);
    border: 1px solid #e2e8f0;
}

.pdv-cat-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid #f1f5f9;
}

.pdv-cat-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pdv-cat-thumb {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdv-cat-name-txt {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

/* CUSTOM SEARCHABLE DROPDOWN */
.pdv-custom-select-wrapper {
    position: relative;
    width: 100%;
}

.pdv-custom-select-trigger {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: #333;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
    min-height: 40px;
    transition: all 0.2s;
    user-select: none;
}

.pdv-custom-select-trigger:hover,
.pdv-custom-select-trigger:focus {
    border-color: var(--pdv-primary);
    background: #fdfdfd;
}

.pdv-custom-select-trigger .arrow {
    font-size: 10px;
    color: #999;
}

.pdv-custom-select-dropdown {
    position: absolute;
    bottom: calc(100% + 5px);
    /* Open Upwards */
    left: 0;
    width: 100%;
    min-width: 250px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

.pdv-dropdown-search-wrapper {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
}

.pdv-dropdown-search-wrapper input {
    border: none;
    width: 100%;
    font-size: 13px;
    outline: none;
    background: transparent;
    color: #333;
    font-weight: 500;
}

.pdv-dropdown-search-wrapper .icon {
    color: #94a3b8;
    font-size: 14px;
}

#pdv-client-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    max-height: 250px;
}

#pdv-client-dropdown-list li {
    padding: 10px 15px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.1s;
    display: flex;
    justify-content: space-between;
}

#pdv-client-dropdown-list li:hover {
    background: #eff6ff;
    color: var(--pdv-primary);
}

#pdv-client-dropdown-list li.selected {
    background: var(--pdv-primary);
    color: white;
}

#pdv-client-dropdown-list li:last-child {
    border-bottom: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   DESKTOP STATIC LAYOUT OPTIMIZATION (PDV)
   ========================================= */
@media (min-width: 1024px) {

    /* 1. Portal Sidebar independent scroll (always available) */
    .pagor-sidebar {
        max-height: 100vh !important;
        overflow-y: auto !important;
        position: sticky !important;
        top: 0 !important;
    }

    .pagor-sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .pagor-sidebar::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 10px;
    }

    /* 2. Lock main portal scroll when PDV is active */
    #pagor-app.in-pdv-context .pagor-main {
        overflow: hidden !important;
        height: 100vh !important;
        padding: 0 !important;
    }

    /* 3. PDV Container Layout - Full Screen professional */
    #pagor-app.in-pdv-context #pagor-pdv-app {
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        padding: 15px !important;
        gap: 15px !important;
        grid-template-columns: 85px 1fr 380px;
        /* Slight optimized widths */
    }

    /* 4. PDV Sidebar (Menu) independent scroll */
    .pdv-sidebar {
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        scrollbar-width: none !important;
        /* Hide scrollbar Firefox */
    }

    .pdv-sidebar::-webkit-scrollbar {
        display: none !important;
        /* Hide scrollbar Chrome/Safari */
    }

    /* 5. Cart Column Fixes */
    .pdv-cart-column {
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
        /* Fixed header/footer */
        background: var(--pdv-white) !important;
    }

    .pdv-cart-items-container {
        flex: 1 !important;
        overflow-y: auto !important;
    }

    /* 6. Main Content (Product List) - Ensure it scrolls independently */
    .pdv-main-content {
        height: 100% !important;
        overflow: hidden !important;
    }

    .pdv-view {
        height: 100% !important;
        overflow-y: auto !important;
        padding-right: 10px !important;
    }

    /* Fix for when cart is hidden */
    #pagor-pdv-app.pdv-no-cart {
        grid-template-columns: 85px 1fr !important;
    }
}