/* RESET */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f4f6f9;
}

/* ================= LOGIN ================= */

.login-page {
    height: 100vh;
    background: url('../img/login-bg.jpg') center center / cover no-repeat;
    position: relative;
}

.login-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
}

.login-wrapper {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    border-radius: 18px;
    padding: 30px 25px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-header img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    border: 4px solid white;
}

.input-group {
    margin-bottom: 18px;
}

.input-group label {
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    display: block;
}

.input-group input {
    width: 100%;
    padding: 14px;
    font-size: 16px; /* evita zoom no iPhone */
    border-radius: 10px;
    border: 1px solid #ddd;
}

.input-group input:focus {
    border-color: #2e86de;
    outline: none;
}

.btn-login {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    background: #2e86de;
    color: white;
    margin-top: 10px;
}

.btn-login:active {
    transform: scale(0.98);
}

.login-error {
    background: #ffe6e6;
    color: #a00000;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 15px;
    text-align: center;
}

.login-footer {
    position: fixed;
    bottom: 10px;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #ffffff;
}

/* ================= HEADER ================= */

.top-bar {
    background: #2e86de;
    color: white;
    padding: 15px;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logout {
    text-decoration: none;
    color: white;
    font-weight: 600;
}

/* ================= MESAS ================= */

.mesas-container {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* MOBILE */
    gap: 12px;
}

/* TABLET */
@media (min-width: 600px) {
    .mesas-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* DESKTOP */
@media (min-width: 992px) {
    .mesas-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

.mesa {
    border-radius: 18px;
    padding: 16px;
    min-height: 130px;
    color: white;
    font-weight: 500;
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mesa h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.mesa p {
    font-size: 13px;
    margin-bottom: 4px;
}

.mesa small {
    font-size: 12px;
    opacity: 0.9;
}

/* CORES */

.livre {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.ocupada {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    color: #222;
}

/* ================= BOTÃO FLUTUANTE ================= */

.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    background: #2e86de;
    color: white;
    font-size: 22px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 999;
}

.fab:active {
    transform: scale(0.95);
}

/* ================= MODAL TECLADO ================= */

.keyboard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 1000;
}

.keyboard-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.keyboard-content {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-radius: 25px 25px 0 0;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.keyboard-display {
    background: #f4f6f9;
    padding: 18px;
    font-size: 28px;
    text-align: right;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: bold;
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.keyboard-grid button {
    padding: 18px;
    font-size: 20px;
    border-radius: 14px;
    border: none;
    background: #e9edf3;
}

.keyboard-grid button:active {
    transform: scale(0.95);
}

.btn-ok {
    background: #2ecc71 !important;
    color: white;
    font-weight: bold;
}

.btn-clear {
    background: #e74c3c !important;
    color: white;
}


/* ================= ERRO API ================= */

.api-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
}

.api-error img {
    width: 140px;
    opacity: 0.9;
    margin-bottom: 20px;
}

.api-error h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
}

.api-error p {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.api-error button {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    background: #2e86de;
    color: white;
    font-weight: 600;
}

/* ===== ERRO LOGIN ===== */

.login-error-box {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
}

.login-error-box.invalid {
    background: #ffe6e6;
    color: #a00000;
}

.login-error-box.connection {
    background: #fff4e5;
    color: #8a5a00;
}

.login-error-box img {
    width: 80px;
    margin-bottom: 10px;
}


/* ===== MODAL MESA ===== */

.mesa-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 2000;
}

.mesa-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.mesa-content {
    background: white;
    width: 100%;
    max-width: 600px;
    border-radius: 25px 25px 0 0;
    padding: 20px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.mesa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.mesa-header h2 {
    font-size: 18px;
}

.mesa-header button {
    border: none;
    background: none;
    font-size: 22px;
}

.mesa-itens {
    overflow-y: auto;
    flex: 1;
}

.item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.item-desc {
    font-weight: 600;
}

.item-info {
    font-size: 13px;
    color: #666;
}

.item-total {
    font-weight: bold;
}

.item.cancelado {
    opacity: 0.5;
    text-decoration: line-through;
    color: #c0392b;
}

.mesa-footer {
    margin-top: 15px;
}

.mesa-total {
    font-size: 18px;
    margin-bottom: 10px;
}

.mesa-actions {
    display: flex;
    justify-content: space-between;
}

.mesa-actions button {
    flex: 1;
    margin: 0 5px;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 18px;
    color: white;
}

.btn-print { background: #34495e; }
.btn-add { background: #2ecc71; }
.btn-transfer { background: #f39c12; }

/* ===== MODAL CONFIRMAÇÃO ===== */

.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.25s ease;
    z-index: 3000;
}

.confirm-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.confirm-content {
    width: 90%;
    max-width: 420px;
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    animation: fadeScale 0.25s ease;
}

@keyframes fadeScale {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.confirm-header h2 {
    font-size: 20px;
    margin-bottom: 15px;
}

.confirm-body p {
    font-size: 15px;
    color: #555;
    margin-bottom: 25px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-cancel {
    background: #ecf0f1;
    color: #333;
}

.btn-confirm {
    background: #2ecc71;
    color: white;
}

.btn-confirm:active,
.btn-cancel:active {
    transform: scale(0.97);
}

/* ===== PÁGINA VENDA ===== */

.venda-page {
    background: #f4f6f9;
    padding-bottom: 80px;
}

/* HEADER */

.venda-header {
    background: #2e86de;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

.venda-header button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
}

/* DESCRIÇÃO */

.descricao-box {
    padding: 15px;
}

.descricao-box input {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #ddd;
    font-size: 15px;
}

/* GRUPOS */

.grupos-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 15px;
}

.grupo {
    padding: 10px 18px;
    border-radius: 25px;
    background: white;
    border: 2px solid #e0e0e0;
    font-size: 14px;
    white-space: nowrap;
    transition: 0.2s;
}

.grupo.active {
    background: #2e86de;
    color: white;
    border-color: #2e86de;
}

/* BUSCA COM ÍCONE */

.busca-produto {
    position: relative;
    padding: 10px 15px;
}

.busca-produto i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
}

.busca-produto input {
    width: 100%;
    padding: 14px 14px 14px 40px; /* espaço para o ícone */
    border-radius: 14px;
    border: 1px solid #ddd;
    font-size: 15px;
}


/* PRODUTOS */

.produtos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 15px;
}

.produto-card {
    background: white;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.produto-card strong {
    font-size: 14px;
    color: #2e86de;
}

.produto-card:hover {
    transform: scale(1.02);
}

/* FOOTER FIXO */

.venda-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: white;
    padding: 15px;
    display: flex;
    gap: 10px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
}

.btn-cancelar {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: #ecf0f1;
}

.btn-confirmar {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: #2ecc71;
    color: white;
    font-weight: bold;
}

/* ===== MODAL PRODUTO ===== */

.produto-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.25s ease;
    z-index: 4000;
}

.produto-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.produto-content {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border-radius: 25px 25px 0 0;
    padding: 20px;
    animation: slideUpProduto 0.25s ease;
}

@keyframes slideUpProduto {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.produto-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.produto-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.produto-header button {
    background: none;
    border: none;
    font-size: 22px;
}

.produto-info {
    background: #f4f6f9;
    padding: 12px;
    border-radius: 14px;
    margin-bottom: 15px;
    font-size: 14px;
}

.qtd-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.qtd-box button {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: none;
    background: #2e86de;
    color: white;
    font-size: 20px;
}

.qtd-box input {
    flex: 1;
    text-align: center;
    padding: 12px;
    font-size: 18px;
    border-radius: 12px;
    border: 1px solid #ddd;
}

.produto-total {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: right;
}

.produto-content textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid #ddd;
    padding: 12px;
    font-size: 14px;
    resize: none;
    margin-bottom: 15px;
}

.btn-add-produto {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: none;
    background: #2ecc71;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

/* BADGE */

.badge-carrinho {
    background: #e74c3c;
    color: white;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 20px;
    margin-left: 8px;
}

/* MODAL RESUMO */

.resumo-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.25s;
    z-index: 5000;
}

.resumo-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.resumo-content {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 25px 25px 0 0;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.resumo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.resumo-header h3 {
    font-size: 18px;
}

.resumo-itens {
    margin-bottom: 15px;
}

.resumo-item {
    background: #f4f6f9;
    padding: 12px;
    border-radius: 14px;
    margin-bottom: 10px;
}

.resumo-item-top {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 5px;
}

.resumo-controles {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.resumo-controles button {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    border: none;
    background: #2e86de;
    color: white;
}

.btn-trash {
    background: #e74c3c !important;
}

.resumo-total {
    font-size: 18px;
    margin-bottom: 15px;
}

.btn-confirmar-final {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: none;
    background: #f1c40f;
    color: #333;
    font-weight: bold;
    font-size: 16px;
}

.btn-close-modal {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.btn-close-modal:active {
    transform: scale(0.95);
}

/* ===== FOOTER TOTAL DINÂMICO ===== */

.venda-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: white;
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 15px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 1000;
}

.footer-total {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-total span {
    font-size: 13px;
    color: #777;
}

.footer-total strong {
    font-size: 20px;
    color: #2e86de;
}

/* BOTÃO CONFIRMAR */

.btn-confirmar {
    min-width: 140px;
    padding: 14px 20px;
    border-radius: 14px;
    border: none;
    background: #2ecc71;
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-align: center;
}


/* MODAL RETORNO */

.retorno-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    z-index: 6000;
}

.retorno-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.retorno-content {
    width: 90%;
    max-width: 400px;
    background: white;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
}

.btn-retorno-ok {
    margin-top: 15px;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: #2e86de;
    color: white;
    font-weight: 600;
}

/* MODAL IMPRESSÃO */

.print-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    z-index: 7000;
}

.print-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.print-content {
    width: 90%;
    max-width: 360px;
    background: white;
    border-radius: 18px;
    padding: 25px;
    text-align: center;
}

.btn-print-ok {
    margin-top: 15px;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: #2e86de;
    color: white;
    font-weight: 600;
}

/* TOTAIS DA MESA */

.mesa-totais {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: center;
}

.mesa-total-item {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: #666;
}

.mesa-total-item strong {
    font-size: 14px;
    color: #333;
}

.mesa-total-item.total-final strong {
    font-size: 16px;
    color: #2e86de;
}


/* MODAL LOADING */

.loading-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s ease;
}

.loading-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-content {
    background: white;
    padding: 25px 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.loading-content img {
    width: 80px;
    margin-bottom: 15px;
}

.loading-content p {
    font-size: 15px;
    font-weight: 500;
    color: #444;
}

