/* --- BIẾN MÀU (THEME "XANH SÁNG") --- */
:root {
    --primary-color: #007bff;
    --text-dark: #212529;
    --text-light: #6c757d;
    --text-money: #007bff;
    --text-danger: #dc3545;
    --text-warning: #ffc107;
    --text-success: #28a745;
    --bg-light: #f4f6f8;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
}

/* --- CÀI ĐẶT CHUNG --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

/* --- BỐ CỤC "VỎ" ỨNG DỤNG --- */
.app-shell {
    width: 100%;
    min-height: 100vh;
}

/* --- HEADER (THANH TRÊN CÙNG) --- */
.app-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}
.app-header .header-actions {
    display: flex;
    align-items: center;
    font-size: 18px;
    color: var(--primary-color);
}

/* --- MENU DƯỚI CÙNG (BOTTOM NAV) --- */
.app-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.app-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-light);
    font-size: 11px;
    padding: 5px 0;
}
.app-bottom-nav a i {
    font-size: 18px;
    margin-bottom: 4px;
}
.app-bottom-nav a.active {
    color: var(--primary-color);
}

/* --- NỘI DUNG CHÍNH (APP CONTENT) --- */
.app-content {
    padding-top: 20px;
    padding-bottom: 80px;
    padding-left: 16px;
    padding-right: 16px;
}

/* --- LỚP "CARD" (THẺ) DÙNG CHUNG --- */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px;
    padding: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}
.card-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
}

/* --- CÁC LỚP TIỆN ÍCH CHO SỐ LIỆU (Dashboard) --- */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}
.stat-item .label {
    font-size: 14px;
    color: var(--text-light);
}
.stat-item .value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
}
.value.money, .value.primary {
    color: var(--primary-color);
}
.value.danger {
    color: var(--text-danger);
}
.value.warning {
    color: var(--text-warning);
}

.today-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
    padding: 0;
}
.today-stat-item {
    text-align: center;
}
.today-stat-item .label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
    display: block;
}
.today-stat-item .value {
    font-size: 20px;
    font-weight: 700;
}

.monthly-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    text-align: center;
}
.monthly-stat-item .label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
    display: block;
}
.monthly-stat-item .value {
    font-size: 20px;
    font-weight: 700;
}

/* CSS CHO TRANG "NHIỀU HƠN" (MORE) */
.menu-list-card {
    padding: 0 16px;
}
.menu-item {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-dark);
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}
.menu-list-card .menu-item:last-child {
    border-bottom: none;
}
.menu-item-icon {
    font-size: 18px;
    width: 30px;
    text-align: center;
    margin-right: 12px;
}
.menu-item-label {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
}
.menu-item-arrow {
    font-size: 12px;
    color: var(--text-light);
    opacity: 0.7;
}

/* CSS CHO CÁC TRANG DANH SÁCH (LIST PAGES) */
.fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    font-size: 24px;
    text-decoration: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
}
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    position: relative;
}
.search-box i {
    color: var(--text-light);
    margin-right: 8px;
}
.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    background: transparent;
}
.btn-filter {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}
.list-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 12px;
    overflow: hidden;
}
.list-card-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.customer-avatar {
    font-size: 32px;
    color: var(--text-light);
    margin-right: 12px;
}
.list-card-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-right: 10px;
}
.list-card-title span {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
}
.list-card-title .sub-text {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-light);
}
.list-card-actions {
    display: flex;
    gap: 16px;
}
.list-card-actions i {
    font-size: 16px;
    color: var(--text-light);
}
.icon-edit { color: var(--primary-color); }
.icon-delete { color: var(--text-danger); }
.list-card-body {
    padding: 12px 16px;
}
.list-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
}
.list-stat-item .label {
    color: var(--text-light);
}
.list-stat-item .value {
    font-weight: 500;
    color: var(--text-dark);
    text-align: right;
}

/* CSS CHO TRANG HÀNG HÓA */
.card-primary-stat {
    background-color: var(--primary-color);
}
.card-primary-stat .stat-item .label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
}
.card-primary-stat .stat-item .value {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
}
.toggle-filter-bar {
    display: flex;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}
.toggle-filter-bar a {
    flex: 1;
    text-align: center;
    padding: 8px;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
}
.toggle-filter-bar a.active {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}
.product-name-highlight {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--primary-color) !important;
    margin-bottom: 2px;
}
.product-inventory {
    font-size: 14px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 60px;
    text-align: center;
}
.stock-good { color: var(--text-success); background-color: rgba(40,167,69,0.1); }
.stock-low { color: #e69a00; background-color: rgba(255,193,7,0.1); }
.stock-out { color: var(--text-danger); background-color: rgba(220,53,69,0.1); }
.product-card.status-inactive {
    opacity: 0.6;
}
.product-price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding-top: 8px;
}
.price-item {
    text-align: left;
}
.price-item .label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
    display: block;
}
.price-item .value {
    font-size: 14px;
    font-weight: 500;
}
.price-item .sell-price {
    color: var(--text-danger);
    font-weight: 700;
}
.price-item .wholesale-price {
    color: var(--primary-color);
    font-weight: 700;
}
.price-item .cost-price {
    color: var(--text-dark);
}
.btn-select-customer {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}
/* (MỚI) Đánh dấu sản phẩm đã chọn */
.product-card {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.selection-checkmark {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    color: var(--primary-color);
}
.product-card.is-in-cart {
    border-color: var(--primary-color);
    background-color: #f0f7ff;
}
.product-card.is-in-cart .selection-checkmark {
    display: block;
}

/* CSS TRANG ĐƠN HÀNG */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding: 12px;
}
.summary-item {
    text-align: center;
}
.summary-item .label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
    display: block;
}
.summary-item .value {
    font-size: 15px;
    font-weight: 700;
}
.filter-container {
    padding: 12px;
}
.filter-dates {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.form-control { 
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff; 
}
.filter-quick-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.btn-quick-date {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}
.btn-quick-date.active {
    background-color: var(--primary-color);
    color: #fff;
}
.order-card .list-card-header {
    align-items: flex-start;
}
.order-code {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--primary-color) !important;
}
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}
.status-completed { background-color: var(--text-success); }
.status-draft { background-color: var(--text-warning); color: var(--text-dark); }
.status-deleted { background-color: var(--text-light); color: var(--text-dark); }
.order-card-actions {
    display: flex;
    background-color: var(--bg-light);
    border-top: 1px solid var(--border-color);
}
.btn-action {
    flex: 1;
    text-align: center;
    padding: 10px;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
}
.btn-action:not(:last-child) {
    border-right: 1px solid var(--border-color);
}
.btn-action i {
    margin-right: 4px;
}
.btn-action.btn-edit { color: var(--primary-color); }
.btn-action.btn-delete-order { color: var(--text-danger); }
.order-details-content {
    padding: 0 16px 16px 16px;
    background: #fff;
}
.order-details-content .loading-spinner {
    text-align: center;
    padding: 20px;
    font-size: 20px;
    color: var(--primary-color);
}
.order-details-content .loading-spinner::before {
    content: '\f110'; 
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    -webkit-animation: fa-spin 1s infinite linear;
    animation: fa-spin 1s infinite linear;
}
.order-details-content .error {
    text-align: center;
    padding: 10px;
    color: var(--text-danger);
}
.order-details-content .no-items {
    text-align: center;
    padding: 10px;
    color: var(--text-light);
}
.details-table {
    width: 100%;
    border-collapse: collapse;
}
.details-table th, .details-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.details-table th {
    background-color: var(--bg-light);
    text-align: left;
    color: var(--text-dark);
}
.details-table .item-name {
    display: block;
    font-weight: 500;
    color: var(--text-dark);
}
.details-table .item-code {
    display: block;
    font-size: 12px;
    color: var(--text-light);
}
.details-table .text-center { text-align: center; }
.details-table .text-right { text-align: right; }

/*
=====================================
--- (MỚI) CSS CHO TRANG POS MOBILE ---
=====================================
*/
html, body {
    height: 100%;
}
.pos-shell {
    display: flex;
    flex-direction: column;
    height: 100vh; 
    background-color: var(--bg-light);
}
.pos-header {
    flex-shrink: 0; 
}
.pos-content {
    flex: 1;
    overflow-y: auto; 
    padding: 16px;
    display: flex;
    flex-direction: column;
}
.pos-footer-actions {
    flex-shrink: 0; 
}
.pos-section-actions {
    display: flex;
    gap: 10px;
}
.pos-action-button {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-decoration: none;
    color: var(--text-dark);
}
.pos-action-button i {
    font-size: 20px;
    color: var(--primary-color);
    margin-right: 12px;
}
.pos-action-button .action-text {
    display: flex;
    flex-direction: column;
}
.pos-action-button .label {
    font-size: 12px;
    color: var(--text-light);
}
.pos-action-button .value {
    font-size: 16px;
    font-weight: 700;
}
.pos-action-button-icon {
    padding: 12px 14px;
    font-size: 20px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--primary-color);
    cursor: pointer;
}

/* (MỚI) Giỏ hàng (scrollable) */
.pos-cart-container {
    flex: 1; /* Quan trọng: làm cho giỏ hàng co giãn */
    min-height: 150px; 
    display: flex;
    flex-direction: column;
    margin-top: 16px;
}
.pos-cart-list {
    overflow-y: auto; /* (MỚI) Đây là phần cuộn được */
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.pos-cart-list .no-items {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 16px;
}
/* (MỚI) Thẻ sản phẩm trong giỏ hàng (ngang) */
.pos-item-card-horizontal {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.pos-item-card-horizontal:last-child {
    border-bottom: none;
}
.pos-item-card-horizontal .item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-right: 10px;
    overflow: hidden; /* Chống vỡ chữ */
}
.pos-item-card-horizontal .item-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pos-item-card-horizontal .sub-text {
    font-size: 12px;
    color: var(--text-light);
}
.item-controls-horizontal {
    display: flex;
    align-items: center;
}
.btn-qty-horizontal {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 50%;
}
.qty-input-horizontal {
    width: 40px;
    height: 28px;
    text-align: center;
    border: none;
    font-size: 16px;
    font-weight: 700;
    /* Ẩn mũi tên của input number */
    -moz-appearance: textfield;
}
.qty-input-horizontal::-webkit-outer-spin-button,
.qty-input-horizontal::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.item-total-horizontal {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-danger);
    width: 80px;
    text-align: right;
    white-space: nowrap;
}
.btn-delete-item-horizontal {
    background: none;
    border: none;
    color: var(--text-danger);
    font-size: 18px;
    padding: 0 5px;
    cursor: pointer;
}
.pos-checkout-panel .card {
    border: 1px solid var(--border-color);
    margin-top: 16px;
}
.pos-checkout-panel .form-control {
    text-align: right;
    flex: 1;
    max-width: 180px;
}
.pos-checkout-panel .list-stat-item {
    padding: 12px 0;
}
.pos-checkout-panel .list-stat-item .label {
    flex: 1;
}
.pos-checkout-panel .summary-total-row .label {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}
.pos-checkout-panel .summary-total-row .value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-danger);
}
.form-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}
.input-group-discount {
    display: flex;
    gap: 5px;
    max-width: 180px;
}
.input-group-discount select {
    flex-basis: 70px;
    padding: 10px 5px;
}
.customer-search-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 220px;
    position: relative;
}
.customer-search-group .search-box {
    flex: 1;
    padding: 0;
    border: none;
}
.customer-search-group .form-control {
    max-width: none;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.btn-quick-add {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

/* Footer (Nút bấm) */
.pos-footer-actions {
    display: flex;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
    flex-shrink: 0;
}
.btn-action-footer {
    flex: 1;
    padding: 14px;
    border: none;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}
.btn-action-footer.btn-draft {
    background: var(--bg-light);
    color: var(--text-dark);
    border-right: 1px solid var(--border-color);
}
.btn-action-footer.btn-save {
    background: var(--primary-color);
    color: #fff;
}
.btn-action-footer:disabled {
    opacity: 0.7;
}

/* Modal Thêm Khách */
.pos-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 16px;
}
.pos-modal-content {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.pos-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.pos-modal-title {
    font-size: 18px;
    font-weight: 700;
}
.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
}
.pos-modal-body {
    padding: 16px;
}
.pos-modal-body .form-group {
    margin-bottom: 12px;
}
.pos-modal-body .form-group label {
    font-weight: 500;
    margin-bottom: 4px;
    display: block;
}
.pos-modal-footer {
    display: flex;
    border-top: 1px solid var(--border-color);
}