/* Optimized Inventory Page Styles - Space, UI/UX, Responsive */

/* ===== SPACE OPTIMIZATION ===== */
.page#page-ton-kho {
    padding: var(--spacing-md);
    max-width: 100%;
    overflow-x: hidden;
}

.page#page-ton-kho .page-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-lighter);
}

.page#page-ton-kho .page-header h2 {
    font-size: 22px;
    margin: 0;
}

.page-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
}

.warehouse-controls-row {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-md);
}

.table-card {
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.table-header h3 {
    font-size: 16px;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.table-actions .btn,
.table-actions .form-control {
    flex-shrink: 0;
    white-space: nowrap;
}

/* History filter actions - optimized for single line display */
.history-filter-actions {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.history-filter-actions .history-date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid #e0e0e0;
}

.history-filter-actions .history-date-nav .btn-sm {
    padding: 5px 10px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-filter-actions .form-control-sm {
    max-width: 130px;
    min-width: 120px;
    padding: 6px 8px;
    font-size: 12px;
    flex-shrink: 1;
}

.history-filter-actions .filter-separator {
    margin: 0 4px;
    white-space: nowrap;
    font-size: 12px;
    flex-shrink: 0;
}

.history-filter-actions .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== TABLE OPTIMIZATION ===== */
.data-table {
    font-size: 13px;
}

.data-table th {
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 8px;
    font-size: 13px;
    line-height: 1.4;
}

/* Optimize column widths for inventory table */
#inventoryTable th:nth-child(1), /* ID */
#inventoryTable td:nth-child(1) {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

#inventoryTable th:nth-child(2), /* Danh Mục */
#inventoryTable td:nth-child(2) {
    width: 120px;
    min-width: 120px;
}

#inventoryTable th:nth-child(3), /* Tên Sản Phẩm */
#inventoryTable td:nth-child(3) {
    width: auto;
    min-width: 200px;
}

#inventoryTable th:nth-child(4), /* Mã Nhập */
#inventoryTable td:nth-child(4) {
    width: 120px;
    min-width: 120px;
}

#inventoryTable th:nth-child(5), /* Hãng */
#inventoryTable td:nth-child(5) {
    width: 100px;
    min-width: 100px;
}

#inventoryTable th:nth-child(6), /* Nhà Cung Cấp */
#inventoryTable td:nth-child(6) {
    width: 140px;
    min-width: 140px;
}

#inventoryTable th:nth-child(7), /* Số Lượng */
#inventoryTable td:nth-child(7) {
    width: 90px;
    min-width: 90px;
    text-align: center;
}

#inventoryTable th:nth-child(8), /* Giá Nhập */
#inventoryTable td:nth-child(8) {
    width: 110px;
    min-width: 110px;
    text-align: right;
}

#inventoryTable th:nth-child(9), /* Giá Đại Lý */
#inventoryTable td:nth-child(9) {
    width: 110px;
    min-width: 110px;
    text-align: right;
}

#inventoryTable th:nth-child(10), /* Bảo Hành */
#inventoryTable td:nth-child(10) {
    width: 100px;
    min-width: 100px;
    text-align: center;
}

#inventoryTable th:nth-child(11), /* Cập Nhật */
#inventoryTable td:nth-child(11) {
    width: 120px;
    min-width: 120px;
}

#inventoryTable th:nth-child(12), /* Thao Tác */
#inventoryTable td:nth-child(12) {
    width: 80px;
    min-width: 80px;
    text-align: center;
}

/* Optimize column widths for ke hoach nhap table */
#keHoachNhapTable {
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
}

/* Ensure table container doesn't overflow */
#tab-ke-hoach-nhap .table-responsive {
    overflow-x: auto;
    width: 100%;
}

#keHoachNhapTable th:nth-child(1), /* Mã Kế Hoạch */
#keHoachNhapTable td:nth-child(1) {
    width: 110px;
    min-width: 110px;
}

#keHoachNhapTable th:nth-child(2), /* Nhà Cung Cấp */
#keHoachNhapTable td:nth-child(2) {
    width: 120px;
    min-width: 120px;
}

#keHoachNhapTable th:nth-child(3), /* Số SP */
#keHoachNhapTable td:nth-child(3) {
    width: 65px;
    min-width: 65px;
    text-align: center;
}

#keHoachNhapTable th:nth-child(4), /* Tổng SL */
#keHoachNhapTable td:nth-child(4) {
    width: 70px;
    min-width: 70px;
    text-align: center;
}

#keHoachNhapTable th:nth-child(5), /* Tổng Tiền Nhập */
#keHoachNhapTable td:nth-child(5) {
    width: 110px;
    min-width: 110px;
    text-align: right;
}

#keHoachNhapTable th:nth-child(6), /* Đã Thanh Toán */
#keHoachNhapTable td:nth-child(6) {
    width: 110px;
    min-width: 110px;
    text-align: right;
}

#keHoachNhapTable th:nth-child(7), /* Tình Trạng */
#keHoachNhapTable td:nth-child(7) {
    width: 120px;
    min-width: 120px;
}

#keHoachNhapTable th:nth-child(8), /* Ghi Chú */
#keHoachNhapTable td:nth-child(8) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#keHoachNhapTable th:nth-child(9), /* Trạng Thái */
#keHoachNhapTable td:nth-child(9) {
    width: 85px;
    min-width: 85px;
}

#keHoachNhapTable th:nth-child(10), /* Người Tạo */
#keHoachNhapTable td:nth-child(10) {
    width: 100px;
    min-width: 100px;
}

#keHoachNhapTable th:nth-child(11), /* Ngày Tạo */
#keHoachNhapTable td:nth-child(11) {
    width: 110px;
    min-width: 110px;
}

#keHoachNhapTable th:nth-child(12), /* Thao Tác */
#keHoachNhapTable td:nth-child(12) {
    width: 200px;
    min-width: 200px;
    text-align: center;
    white-space: nowrap;
}

/* ===== COMPACT UI ELEMENTS ===== */
.search-box-inline {
    min-width: 200px;
    max-width: 300px;
    flex: 1 1 auto;
}

.search-box-inline input {
    padding: 8px 12px 8px 36px;
    font-size: 13px;
    width: 100%;
}

@media (max-width: 768px) {
    .search-box-inline {
        min-width: 100%;
        max-width: 100%;
    }
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.form-control-sm {
    padding: 6px 10px;
    font-size: 12px;
}

/* Compact stats */
.warehouse-stats-inline {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.stat-inline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.stat-inline-label {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-inline-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

/* Compact badges */
.badge {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    display: inline-block;
    white-space: nowrap;
}

/* Compact tabs */
.tabs-container {
    margin-bottom: var(--spacing-md);
}

.tab-btn {
    padding: 10px 16px;
    font-size: 13px;
}

.tab-btn i {
    font-size: 14px;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Large tablets and small desktops */
@media (max-width: 1400px) {
    .warehouse-controls-row {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .warehouse-stats-inline {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .table-header {
        flex-wrap: wrap;
    }
    
    .table-actions {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 1200px) {
    .warehouse-controls-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .warehouse-selector-group {
        width: 100%;
    }
    
    .warehouse-stats-inline {
        width: 100%;
        justify-content: space-around;
    }
    
    .table-header {
        flex-wrap: wrap;
    }
    
    .table-header h3 {
        width: 100%;
        margin-bottom: var(--spacing-xs);
    }
    
    .table-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .table-actions > * {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .page#page-ton-kho {
        padding: var(--spacing-sm);
    }
    
    .page-header h2 {
        font-size: 20px;
    }
    
    .table-card {
        padding: var(--spacing-sm);
        margin-top: var(--spacing-sm);
    }
    
    .table-header h3 {
        font-size: 14px;
    }
    
    /* Stack table actions vertically on mobile */
    .table-actions {
        flex-direction: column;
    }
    
    .table-actions > * {
        width: 100%;
        margin-bottom: var(--spacing-xs);
    }
    
    /* Make tables scroll horizontally on mobile */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: visible;
        margin: 0 calc(-1 * var(--spacing-sm));
        padding: 0 var(--spacing-sm);
        position: relative;
    }
    
    .data-table {
        min-width: 900px; /* Ensure table doesn't get too narrow */
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    /* Hide less important columns on mobile */
    #inventoryTable th:nth-child(1), /* ID */
    #inventoryTable td:nth-child(1),
    #inventoryTable th:nth-child(4), /* Mã Nhập */
    #inventoryTable td:nth-child(4),
    #inventoryTable th:nth-child(5), /* Hãng */
    #inventoryTable td:nth-child(5),
    #inventoryTable th:nth-child(11) { /* Cập Nhật */
        display: none;
    }
    
    #inventoryTable td:nth-child(10) { /* Bảo Hành */
        display: none;
    }
    
    /* Adjust column widths for mobile */
    #inventoryTable th:nth-child(2), /* Danh Mục */
    #inventoryTable td:nth-child(2) {
        width: 100px;
        min-width: 100px;
    }
    
    #inventoryTable th:nth-child(3), /* Tên Sản Phẩm */
    #inventoryTable td:nth-child(3) {
        min-width: 180px;
    }
    
    #inventoryTable th:nth-child(6), /* Nhà Cung Cấp */
    #inventoryTable td:nth-child(6) {
        width: 120px;
        min-width: 120px;
    }
    
    #inventoryTable th:nth-child(7), /* Số Lượng */
    #inventoryTable td:nth-child(7) {
        width: 70px;
        min-width: 70px;
    }
    
    #inventoryTable th:nth-child(8), /* Giá Nhập */
    #inventoryTable td:nth-child(8) {
        width: 90px;
        min-width: 90px;
    }
    
    #inventoryTable th:nth-child(9), /* Giá Đại Lý */
    #inventoryTable td:nth-child(9) {
        width: 90px;
        min-width: 90px;
    }
    
    #inventoryTable th:nth-child(12), /* Thao Tác */
    #inventoryTable td:nth-child(12) {
        width: 60px;
        min-width: 60px;
    }
    
    #keHoachNhapTable th:nth-child(8), /* Ghi Chú */
    #keHoachNhapTable td:nth-child(8),
    #keHoachNhapTable th:nth-child(10), /* Người Tạo */
    #keHoachNhapTable td:nth-child(10),
    #keHoachNhapTable th:nth-child(11) { /* Ngày Tạo */
        display: none;
    }
    
    #keHoachNhapTable td:nth-child(11) {
        display: none;
    }
    
    /* Adjust actions column width for tablet */
    #keHoachNhapTable th:nth-child(12), /* Thao Tác */
    #keHoachNhapTable td:nth-child(12) {
        width: 180px;
        min-width: 180px;
    }
    
    .col-actions {
        gap: 3px;
    }
    
    .col-actions .btn-icon {
        width: 30px;
        height: 30px;
        padding: 5px;
    }
    
    /* Compact tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .tab-btn i {
        display: none; /* Hide icons on mobile to save space */
    }
    
    /* Compact stats */
    .stat-inline-item {
        min-width: 70px;
    }
    
    .stat-inline-label {
        font-size: 10px;
    }
    
    .stat-inline-value {
        font-size: 16px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .page#page-ton-kho {
        padding: var(--spacing-xs);
    }
    
    .page-header h2 {
        font-size: 18px;
    }
    
    .warehouse-controls-row {
        padding: var(--spacing-xs);
    }
    
    .table-card {
        padding: var(--spacing-xs);
    }
    
    .table-header h3 {
        font-size: 13px;
    }
    
    .data-table {
        min-width: 800px;
        font-size: 11px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 3px;
        font-size: 10px;
    }
    
    /* Hide more columns on very small screens */
    #inventoryTable th:nth-child(6), /* Nhà Cung Cấp */
    #inventoryTable td:nth-child(6) {
        display: none;
    }
    
    /* Compact stats */
    .stat-inline-item {
        min-width: 80px;
        padding: 4px;
    }
    
    .stat-inline-label {
        font-size: 10px;
    }
    
    .stat-inline-value {
        font-size: 14px;
    }
    
    /* Compact tabs */
    .tabs {
        padding: 0;
    }
    
    .tab-btn {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    /* Compact search */
    .search-box-inline {
        padding: 6px 8px;
    }
    
    .search-box-inline input {
        font-size: 12px;
    }
    
    /* Compact buttons */
    .btn-icon {
        width: 28px;
        height: 28px;
        padding: 4px;
    }
    
    .col-actions .btn-icon {
        width: 26px;
        height: 26px;
    }
    .page-header h2 {
        font-size: 18px;
    }
    
    .warehouse-controls-row {
        padding: var(--spacing-sm);
    }
    
    .table-card {
        padding: var(--spacing-xs);
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    /* Hide more columns on very small screens */
    #inventoryTable th:nth-child(9), /* Bảo Hành */
    #inventoryTable td:nth-child(9) {
        display: none;
    }
    
    #keHoachNhapTable th:nth-child(3), /* Số SP */
    #keHoachNhapTable td:nth-child(3),
    #keHoachNhapTable th:nth-child(4) { /* Tổng SL */
        display: none;
    }
    
    #keHoachNhapTable td:nth-child(4) {
        display: none;
    }
    
    /* Further reduce actions column width for mobile */
    #keHoachNhapTable th:nth-child(12), /* Thao Tác */
    #keHoachNhapTable td:nth-child(12) {
        width: 160px;
        min-width: 160px;
    }
    
    .col-actions {
        gap: 2px;
    }
    
    .col-actions .btn-icon {
        width: 28px;
        height: 28px;
        padding: 4px;
    }
    
    .col-actions .btn-icon i {
        font-size: 12px;
    }
    
    .search-box-inline {
        width: 100%;
        max-width: 100%;
    }
}

/* ===== UI/UX IMPROVEMENTS ===== */
/* Better hover states */
.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Improved button spacing */
.btn-icon {
    margin: 0 2px;
    padding: 6px;
    width: 32px;
    height: 32px;
}

.btn-icon i {
    font-size: 13px;
}

/* Better form controls */
.form-control-sm {
    border-radius: 4px;
    border: 1px solid var(--gray-lighter);
    transition: border-color 0.2s ease;
}

.form-control-sm:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

/* Compact select */
select.form-control-sm {
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/20000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    appearance: none;
}

/* Better spacing for action buttons */
.col-actions {
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.col-actions .btn-icon {
    display: inline-flex;
    vertical-align: middle;
    flex-shrink: 0;
    margin: 0;
}

/* Improved text truncation */
.data-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Allow customer action buttons to remain visible */
.data-table td.customer-actions {
    overflow: visible;
    max-width: none;
    white-space: nowrap;
}

/* Better currency formatting */
.text-primary {
    font-weight: 600;
}

.text-success {
    font-weight: 500;
}

.text-danger {
    font-weight: 500;
}

/* Compact modal improvements */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

.modal-body {
    max-height: calc(90vh - 150px);
    overflow-y: auto;
}

/* Better scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--gray-lighter);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--gray-light);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

/* Mobile scrollbar improvements */
@media (max-width: 768px) {
    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: var(--gray-medium);
    }
}

/* Category/Brand Dropdown Improvements */
.category-dropdown {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--gray-light);
    animation: dropdownFadeIn 0.2s ease;
}

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

/* Ensure dropdown is always visible */
.category-dropdown {
    position: fixed !important;
    z-index: 10000 !important;
}

/* Better visibility for dropdown items */
.category-dropdown-item {
    min-height: 36px;
    display: flex;
    align-items: center;
}

/* ===== PRINT STYLES ===== */
@media print {
    .table-actions,
    .col-actions,
    .btn-icon {
        display: none !important;
    }
    
    .data-table {
        font-size: 10px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
    }
}

