/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Container */
.pos-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.pos-header {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-info {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-tab:hover {
    background: var(--background);
    color: var(--primary-color);
}

.nav-tab.active {
    background: var(--primary-color);
    color: white;
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* Main Content */
.pos-main {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .pos-main {
        grid-template-columns: 1fr;
    }
    
    .cart-section {
        order: -1;
    }
}

@media (max-width: 768px) {
    .nav-tabs {
        padding: 8px;
        gap: 4px;
        margin-bottom: 12px;
    }
    
    .nav-tab {
        padding: 10px 12px;
        font-size: 12px;
        gap: 6px;
    }
    
    .nav-tab svg {
        width: 16px;
        height: 16px;
    }
    
    /* แสดงแค่ไอคอนบนมือถือ */
    .nav-tab span {
        display: none;
    }
    
    .nav-tab::before {
        content: attr(data-label);
        display: none;
    }
}

@media (max-width: 480px) {
    .nav-tabs {
        justify-content: space-between;
        padding: 6px;
    }
    
    .nav-tab {
        padding: 10px 8px;
        flex: 1;
        justify-content: center;
    }
    
    .nav-tab svg {
        width: 20px;
        height: 20px;
    }
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Products Section */
.products-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.search-box input {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 250px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding-right: 8px;
}

.products-grid::-webkit-scrollbar {
    width: 6px;
}

.products-grid::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 3px;
}

.products-grid::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

/* Product Card */
.product-card {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-align: center;
}

.product-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.product-card.selected {
    border-color: var(--success-color);
    background: #ecfdf5;
}

.product-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.product-icon svg {
    width: 36px;
    height: 36px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Cart Section */
.cart-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--danger-color);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.btn-clear:hover {
    background: #fef2f2;
}

/* Cart Items */
.cart-items {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    max-height: 300px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.empty-cart {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    opacity: 0.5;
    color: var(--text-secondary);
}

.empty-icon svg {
    width: 48px;
    height: 48px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.cart-item:last-child {
    margin-bottom: 0;
}

.cart-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.cart-item-icon svg {
    width: 24px;
    height: 24px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.cart-item-price {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.qty-value {
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.cart-item-total {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 80px;
    text-align: right;
}

.cart-item-remove {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-remove:hover {
    opacity: 1;
}

/* Cart Summary */
.cart-summary {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.summary-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.discount-input {
    display: flex;
    align-items: center;
    gap: 4px;
}

.discount-input input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    font-size: 14px;
}

.discount-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.total-row {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    padding-top: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

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

.btn-success:hover {
    background: #059669;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    flex: 0 0 auto;
    background: var(--surface);
}

.modal-footer .btn {
    flex: 1;
}

/* Modal Responsive for Mobile */
@media (max-width: 768px) {
    .modal {
        padding: 10px;
        align-items: flex-end;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius) var(--radius) 0 0;
        animation: modalSlideUp 0.3s ease;
    }
    
    @keyframes modalSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-close {
        font-size: 24px;
    }
    
    .modal-body {
        padding: 15px;
        max-height: none;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 5px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 12px;
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .modal-body {
        padding: 12px;
        max-height: none;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 12px;
        gap: 8px;
    }
}

/* Receipt */
.receipt {
    font-family: 'Courier New', monospace;
}

/* ==================== Settings Section ==================== */
.settings-section {
    padding: 20px;
}

.settings-container {
    max-width: 600px;
    margin: 0 auto;
}

.settings-header {
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-form {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.store-logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.store-logo-preview {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    overflow: hidden;
}

.store-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.store-logo-preview svg {
    color: var(--text-secondary);
}

.store-logo-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.settings-actions .btn {
    width: 100%;
}

@media (max-width: 768px) {
    .settings-section {
        padding: 15px;
    }
    
    .settings-form {
        padding: 16px;
    }
    
    .store-logo-section {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .store-logo-preview {
        width: 80px;
        height: 80px;
    }
    
    .store-logo-actions {
        flex-direction: row;
    }
}

.receipt-header {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 2px dashed var(--border-color);
    margin-bottom: 16px;
}

.receipt-store {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.receipt-store svg {
    width: 18px;
    height: 18px;
}

.receipt-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.receipt-items {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.receipt-item-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.receipt-item-name svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.receipt-item-qty {
    width: 50px;
    text-align: center;
}

.receipt-item-price {
    width: 80px;
    text-align: right;
}

.receipt-totals {
    font-size: 13px;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.receipt-row.total {
    font-size: 16px;
    font-weight: 700;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 2px solid var(--text-primary);
}

.receipt-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px dashed var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .pos-main {
        grid-template-columns: 1fr;
    }
    
    .cart-section {
        max-height: none;
    }
    
    .cart-items {
        max-height: 200px;
    }
}

@media (max-width: 600px) {
    .pos-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .header-info {
        flex-direction: column;
        gap: 4px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tab {
        flex: 1;
        justify-content: center;
    }
    
    .report-summary-cards {
        grid-template-columns: 1fr;
    }
    
    .report-table-container {
        overflow-x: auto;
    }
}

/* ==================== Reports Section ==================== */
.reports-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.reports-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.reports-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.report-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.report-filters select,
.report-filters input[type="date"] {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
}

.report-filters select:hover,
.report-filters input[type="date"]:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
}

.report-filters select:focus,
.report-filters input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Summary Cards */
.report-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.summary-card {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.summary-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-card-icon.sales {
    background: #dbeafe;
    color: var(--primary-color);
}

.summary-card-icon.orders {
    background: #d1fae5;
    color: var(--success-color);
}

.summary-card-icon.items {
    background: #fef3c7;
    color: var(--warning-color);
}

.summary-card-icon.discount {
    background: #fee2e2;
    color: var(--danger-color);
}

.summary-card-icon svg {
    width: 24px;
    height: 24px;
}

.summary-card-info {
    display: flex;
    flex-direction: column;
}

.summary-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.summary-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Report Table */
.report-table-container {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.report-table-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.report-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--surface);
}

.report-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.report-table tbody tr:hover {
    background: var(--surface);
}

.btn-print-row {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-print-row:hover {
    background: var(--primary-dark);
}

.btn-print-row svg {
    width: 16px;
    height: 16px;
}

/* ==================== History Section ==================== */
.history-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.history-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.history-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.history-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.history-filters input[type="date"] {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
}

.history-filters input[type="date"]:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
}

.history-filters input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.history-filters span {
    color: var(--text-secondary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.history-item {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-bill-no {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 14px;
}

.history-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-item-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.history-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item-tag {
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.history-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
}

.history-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.history-item-footer span {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-reprint {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-reprint svg {
    width: 14px;
    height: 14px;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ==================== Modal Enhancements ==================== */
.modal-large {
    max-width: 800px !important;
}

 /* Checkout modal can be very tall; allow the whole modal to scroll so footer fields are reachable */
 #checkoutModal .modal-content {
     overflow-y: auto;
 }

 #checkoutModal .modal-body {
     flex: 0 0 auto;
     overflow: visible;
 }

 #checkoutModal .modal-footer {
     flex: 0 0 auto;
 }

.modal-footer {
    flex-direction: column;
    gap: 16px;
}

.bill-type-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bill-type-selector label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.bill-type-selector select {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
    flex: 1;
}

.bill-type-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.customer-info {
    display: flex;
    gap: 12px;
}

.customer-info input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.customer-info input:focus {
    outline: none;
    border-color: var(--primary-color);
}

 .modal-footer input[type="date"] {
     width: 100%;
     padding: 10px 14px;
     border: 2px solid var(--border-color);
     border-radius: var(--radius-sm);
     font-size: 14px;
     background: var(--surface);
 }

 .modal-footer input[type="date"]:focus {
     outline: none;
     border-color: var(--primary-color);
 }

.modal-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.modal-actions .btn {
    flex: 1;
}

/* ==================== Date Picker ==================== */
.modal-small {
    max-width: 400px !important;
}

.date-picker-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.date-picker-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s;
}

.date-picker-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.date-picker-actions {
    display: flex;
    gap: 12px;
}

.date-picker-actions .btn {
    flex: 1;
}

/* Header date hover effect */
.header-info .date:hover {
    background-color: var(--background);
}

/* Enhanced date input styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.5);
}

/* ==================== Print Preview Modal ==================== */
.print-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.print-settings .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.print-settings .form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.print-settings select {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

.print-settings select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.orientation-options {
    display: flex;
    gap: 16px;
}

.radio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.radio-option:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option input[type="radio"]:checked + .radio-label {
    color: var(--primary-color);
    font-weight: 600;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.radio-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.orientation-icon {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.radio-option:has(input[type="radio"]:checked) .orientation-icon {
    opacity: 1;
}

.radio-option:has(input[type="radio"]:checked) .orientation-icon rect {
    stroke: var(--primary-color);
}

.print-preview-box {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.preview-paper {
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.preview-paper.portrait {
    width: 60px;
    height: 85px;
}

.preview-paper.landscape {
    width: 85px;
    height: 60px;
}

.preview-paper.a4.portrait {
    width: 60px;
    height: 85px;
}

.preview-paper.a4.landscape {
    width: 85px;
    height: 60px;
}

.preview-paper.a5.portrait {
    width: 50px;
    height: 70px;
}

.preview-paper.a5.landscape {
    width: 70px;
    height: 50px;
}

.preview-paper.letter.portrait {
    width: 58px;
    height: 75px;
}

.preview-paper.letter.landscape {
    width: 75px;
    height: 58px;
}

.preview-text {
    font-size: 8px;
    color: var(--text-secondary);
    text-align: center;
}

@media (max-width: 480px) {
    .orientation-options {
        flex-direction: column;
        gap: 8px;
    }
    
    .radio-option {
        flex-direction: row;
        justify-content: flex-start;
    }
    
    .orientation-icon {
        width: 30px;
        height: auto;
    }
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.5);
    transition: filter 0.2s;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-small {
        max-width: 350px !important;
    }
    
    .date-picker-actions {
        flex-direction: column;
    }
}

/* ==================== Document Preview ==================== */
.document {
    font-family: 'Segoe UI', sans-serif;
}

.document-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--text-primary);
    margin-bottom: 16px;
}

.document-logo {
    color: var(--primary-color);
}

.document-logo svg {
    width: 40px;
    height: 40px;
}

.document-title h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.document-title p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0;
}

.document-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.document-type {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
}

.document-meta {
    text-align: right;
}

.document-meta p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0;
}

.customer-info-display {
    background: var(--background);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.customer-info-display p {
    font-size: 13px;
    color: var(--text-primary);
    margin: 4px 0;
}

.document-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.document-table th,
.document-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border-color);
    font-size: 12px;
}

.document-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-primary);
}

.document-table td:nth-child(n+3) {
    text-align: right;
}

.document-totals {
    margin-left: auto;
    width: 250px;
    margin-bottom: 16px;
}

.document-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

.document-totals .total-row.discount {
    color: var(--danger-color);
}

.document-totals .grand-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px solid var(--text-primary);
    border-bottom: none;
    padding-top: 12px;
    margin-top: 8px;
}

.payment-info,
.delivery-info {
    background: var(--background);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.payment-info p,
.delivery-info p {
    font-size: 13px;
    color: var(--text-primary);
    margin: 4px 0;
}

.signature-box {
    display: inline-block;
    width: 48%;
    margin-top: 16px;
    vertical-align: top;
}

.signature-box p {
    font-size: 13px;
    margin: 12px 0;
}

.document-footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
    margin-top: 16px;
}

.document-footer p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0;
}

@media (max-width: 768px) {
    .report-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .customer-info {
        flex-direction: column;
    }
    
    .document-header {
        flex-direction: column;
        text-align: center;
    }
    
    .document-info {
        flex-direction: column;
        gap: 12px;
    }
    
    .document-meta {
        text-align: center;
    }
    
    .document-totals {
        width: 100%;
    }
    
    .signature-box {
        display: block;
        width: 100%;
    }
}

/* ==================== Products Management Section ==================== */
.products-management-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.products-management-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.products-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.products-management-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.products-table-container {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 20px;
    overflow-x: auto;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
}

.products-table th,
.products-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.products-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--surface);
}

.products-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.products-table tbody tr:hover {
    background: var(--surface);
}

.products-table .product-icon svg {
    width: 28px;
    height: 28px;
}

/* Stock indicators */
.stock-low {
    color: var(--warning-color);
    font-weight: 600;
}

.stock-out {
    color: var(--danger-color);
    font-weight: 600;
}

/* Product actions */
.product-actions {
    display: flex;
    gap: 8px;
}

.btn-edit,
.btn-delete {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-edit {
    background: #dbeafe;
    color: var(--primary-color);
}

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

.btn-delete {
    background: #fee2e2;
    color: var(--danger-color);
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
}

.btn-download-row {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #dcfce7;
    color: #16a34a;
    margin-left: 4px;
}

.btn-download-row:hover {
    background: #16a34a;
    color: white;
}

 .history-item {
     position: relative;
 }

 .history-actions {
     display: flex;
     align-items: center;
     gap: 6px;
 }

.btn-view-row {
    background: #dbeafe;
    color: #2563eb;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-view-row:hover {
    background: #2563eb;
    color: white;
}

.btn-download-row {
    background: #dcfce7;
    color: #16a34a;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

 @media (max-width: 768px) {
     .history-actions {
         margin-left: 8px;
     }
 }

/* ==================== Form Styles ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    transition: border-color 0.2s;
}

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

.form-group input::placeholder {
    color: var(--text-secondary);
}

/* ==================== Product Card Stock ==================== */
.product-card .product-stock {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.product-card .product-stock.low {
    color: var(--warning-color);
    font-weight: 600;
}

.product-card .product-stock.out {
    color: var(--danger-color);
    font-weight: 600;
}

/* ไม่ปิดกั้นการขาย - แค่แสดงว่าหมดสต็อก */

.no-products {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 16px;
    grid-column: 1 / -1;
}

/* ==================== Image Upload Styles ==================== */
.image-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.image-preview {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview svg {
    color: var(--text-secondary);
}

/* ==================== Product Image Styles ==================== */
.product-image,
.product-thumbnail,
.cart-item-image {
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.product-card .product-image {
    width: 60px;
    height: 60px;
}

.product-thumbnail {
    width: 40px;
    height: 40px;
}

.cart-item-image {
    width: 40px;
    height: 40px;
}

.product-no-image,
.cart-item-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.product-card .product-no-image {
    width: 60px;
    height: 60px;
}

.product-no-image {
    width: 40px;
    height: 40px;
}

.cart-item-no-image {
    width: 40px;
    height: 40px;
}

.product-no-image svg,
.cart-item-no-image svg {
    color: var(--text-secondary);
}
