/* Mais PDV — PWA Offline CSS (Mobile First) */
:root {
    --primary: #1a73e8;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --dark: #212529;
    --gray: #6c757d;
    --light: #f8f9fa;
    --border: #dee2e6;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== STATUS BAR ===== */
.pwa-status-bar {
    background: linear-gradient(90deg, var(--danger), #c82333);
    color: white;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.pwa-status-bar.online {
    background: linear-gradient(90deg, var(--success), #20c997);
}

.pwa-status-bar .sync-info {
    font-size: 11px;
    opacity: 0.9;
}

/* ===== BUSCA ===== */
.pwa-search {
    background: white;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
}

.pwa-search input[type="text"] {
    flex: 1;
    height: 42px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 16px;
    background: #fafafa;
    -webkit-appearance: none;
}

.pwa-search input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.pwa-search input[type="number"] {
    width: 60px;
    height: 42px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    -webkit-appearance: none;
}

/* ===== DROPDOWN PRODUTOS ===== */
.pwa-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pwa-dropdown-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.pwa-dropdown-item:active {
    background: #e8f0fe;
}

.pwa-dropdown-item .name {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.pwa-dropdown-item .info {
    font-size: 12px;
    color: var(--gray);
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

/* ===== CARRINHO ===== */
.pwa-cart {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.pwa-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #adb5bd;
}

.pwa-cart-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.pwa-cart-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    background: white;
}

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

.pwa-cart-item .item-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-cart-item .item-detail {
    font-size: 12px;
    color: var(--gray);
}

.pwa-cart-item .item-total {
    font-size: 14px;
    font-weight: 700;
    color: var(--success);
    margin: 0 8px;
    white-space: nowrap;
}

.pwa-cart-item .item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
}

.pwa-cart-item .item-qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.pwa-cart-item .item-qty span {
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.pwa-cart-item .item-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

/* ===== TOTAL + AÇÕES ===== */
.pwa-footer {
    background: white;
    border-top: 2px solid var(--border);
    position: sticky;
    bottom: 0;
}

.pwa-total {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.pwa-total .total-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--success);
}

.pwa-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
}

.pwa-actions button {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-cancel-sale {
    background: #f8d7da;
    color: var(--danger);
}

.btn-pay {
    background: var(--success);
    color: white;
    flex: 2 !important;
}

.btn-pay:disabled {
    background: #6c757d;
    opacity: 0.6;
}

/* ===== MODAL PAGAMENTO ===== */
.pwa-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
}

.pwa-modal-overlay.active {
    display: flex;
}

.pwa-modal {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pwa-modal h3 {
    margin: 0 0 16px;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pwa-modal .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
}

.pwa-modal select,
.pwa-modal input {
    width: 100%;
    height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 16px;
    margin-bottom: 12px;
    -webkit-appearance: none;
}

.pwa-modal select:focus,
.pwa-modal input:focus {
    outline: none;
    border-color: var(--primary);
}

.payment-summary {
    background: var(--light);
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0;
}

.payment-summary .row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.payment-summary .row.total {
    font-size: 18px;
    font-weight: 800;
    color: var(--success);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
}

.payment-summary .row.change {
    font-weight: 700;
    color: var(--primary);
}

.pwa-modal .btn-finalize {
    width: 100%;
    height: 52px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
}

.pwa-modal .btn-finalize:disabled {
    background: var(--gray);
    opacity: 0.6;
}

/* ===== TOAST ===== */
.pwa-toast-container {
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    max-width: 400px;
}

.pwa-toast {
    padding: 10px 16px;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    animation: fadeInDown 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pwa-toast.success { background: var(--success); }
.pwa-toast.error { background: var(--danger); }
.pwa-toast.warning { background: var(--warning); color: var(--dark); }
.pwa-toast.info { background: var(--primary); }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LAYOUT PRINCIPAL ===== */
.pwa-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height (mobile) */
}

.pwa-search-wrapper {
    position: relative;
}

/* ===== SUCCESS SCREEN ===== */
.pwa-success-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2500;
    align-items: center;
    justify-content: center;
}

.pwa-success-overlay.active {
    display: flex;
}

.pwa-success-box {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    width: 90%;
    max-width: 360px;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.pwa-success-box .checkmark {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #d4edda;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
}

.pwa-success-box h3 {
    margin: 0 0 4px;
    color: var(--success);
}

.pwa-success-box p {
    color: var(--gray);
    margin: 0 0 20px;
    font-size: 14px;
}

.pwa-success-box .actions {
    display: flex;
    gap: 10px;
}

.pwa-success-box .actions button {
    flex: 1;
    height: 44px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-receipt {
    background: var(--primary);
    color: white;
}

.btn-new-sale {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border) !important;
}
