body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    padding-bottom: 50px;
}

.navbar {
    background-color: #333;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.navbar button {
    background-color: inherit;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 20px;
    transition: 0.3s;
    font-size: 17px;
    color: white;
}

.navbar button:hover {
    background-color: #ddd;
    color: black;
}

.navbar button.active {
    background-color: #04AA6D;
    color: white;
}

.container {
    max-width: 800px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.tab-content {
    display: none;
    animation: fadeEffect 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeEffect {
    from {opacity: 0;}
    to {opacity: 1;}
}

/* Style Tab 1: Card */
.input-group {
    margin-bottom: 20px;
}
.input-group input {
    padding: 10px;
    margin-right: 10px;
}
.card {
    border: 1px solid #ddd;
    padding: 20px;
    width: 250px;
    text-align: center;
    background: white;
    margin: 0 auto;
    border-radius: 10px;
}
#qrcode-display {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}
#qrcode-display img {
    margin: auto;
}

/* Style Tab 2: Scanner & Table */
#reader {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
table, th, td {
    border: 1px solid #ddd;
}
th, td {
    padding: 10px;
    text-align: left;
}
th {
    background-color: #f2f2f2;
}

/* Style Tab 3: Bill */
.bill-paper {
    border: 1px solid #ccc;
    padding: 20px;
    width: 90%;
    max-width: 350px;
    margin: 10px auto;
    background: #fffdf0; /* Màu giấy in nhiệt hơi vàng */
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    font-family: 'Courier New', Courier, monospace;
    box-sizing: border-box;
    text-align: left;
}

.bill-header, .bill-footer {
    text-align: center;
}

.shop-name {
    margin: 0;
    font-size: 1.5em;
    text-transform: uppercase;
}

.shop-address {
    margin: 5px 0;
    font-size: 0.9em;
    font-style: italic;
}

.bill-footer p {
    margin-top: 10px;
    font-weight: bold;
}
.bill-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}
.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2em;
    margin-top: 10px;
}
.qr-payment-section {
    text-align: center;
    margin-top: 20px;
}
button {
    padding: 10px 20px;
    background-color: #04AA6D;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 5px;
}
button:hover {
    background-color: #02794d;
}
.delete-btn {
    background-color: #ff4d4d;
    padding: 5px 10px;
}

.qty-btn {
    background-color: #e7e7e7;
    color: black;
    border: 1px solid #ddd;
    padding: 2px 8px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
}

.qty-btn:hover {
    background-color: #d4d4d4;
}

/* --- MOBILE OPTIMIZED SCANNER --- */
#reader {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
}

#reader video {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 8px;
}

/* Điều khiển zoom */
#zoom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 10px 0;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    font-size: 24px;
    font-weight: bold;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #04AA6D;
    color: white;
    border: none;
    touch-action: manipulation;
}

.zoom-btn:active {
    transform: scale(0.95);
    background: #02794d;
}

#zoom-level {
    font-size: 16px;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

/* Toast thông báo */
.scan-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    z-index: 9999;
    animation: slideDown 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scan-toast.success {
    background: #04AA6D;
    color: white;
}

.scan-toast.error {
    background: #ff4d4d;
    color: white;
}

.scan-toast.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 600px) {
    .navbar {
        flex-wrap: wrap;
    }

    .navbar button {
        flex: 1;
        padding: 12px 8px;
        font-size: 14px;
        min-width: 0;
    }

    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 8px;
    }

    h2 {
        font-size: 1.3em;
    }

    .input-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .input-group input {
        margin-right: 0;
        width: 100%;
        box-sizing: border-box;
        font-size: 16px; /* Ngăn zoom trên iOS */
        padding: 12px;
    }

    .input-group button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    /* Giỏ hàng responsive */
    #cart-table {
        font-size: 14px;
    }

    #cart-table th,
    #cart-table td {
        padding: 8px 5px;
    }

    .qty-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .delete-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Thêm thủ công responsive */
    .manual-add {
        padding: 12px !important;
    }

    .manual-add > div {
        flex-direction: column !important;
    }

    .manual-add input,
    .manual-add button {
        width: 100% !important;
        flex: none !important;
        font-size: 16px !important;
        padding: 12px !important;
        box-sizing: border-box;
    }

    /* Bill responsive */
    .bill-paper {
        width: 95%;
        padding: 15px;
    }

    /* Nút actions */
    .actions button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }
}

/* Touch-friendly buttons */
@media (pointer: coarse) {
    button {
        min-height: 44px;
        min-width: 44px;
    }

    .qty-btn {
        width: 40px;
        height: 40px;
    }
}