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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow-x: hidden;
    font-size: 12px;
    line-height: 1.2;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 50px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2rem;
}

.login-header p {
    color: #7f8c8d;
}

.login-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.error-message {
    color: #e74c3c;
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
}

/* App Layout */
.app-header {
    background-color: #2c3e50;
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 42px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-btn, .logout-btn {
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 14px;
    font-weight: 600;
}

.sidebar {
    position: fixed;
    top: 42px;
    left: -200px !important;
    width: 200px;
    height: calc(100vh - 42px);
    background-color: white;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}

.sidebar.open {
    left: 0 !important;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-info i {
    font-size: 16px;
    opacity: 0.9;
}

.menu-list {
    list-style: none;
    padding: 6px 0;
    margin: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.3s;
    border-bottom: 1px solid #f0f0f0;
}

.menu-item:hover, .menu-item.active {
    background-color: #f8f9fa;
    border-left: 4px solid #3498db;
}

.menu-item i {
    width: 18px;
    margin-right: 12px;
    font-size: 16px;
}

.menu-item.active i {
    color: #3498db;
}

.main-content {
    margin-top: 42px;
    margin-left: 0;
    padding: 8px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - 42px);
}

.main-content.sidebar-open {
    margin-left: 200px;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Dashboard */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background-color: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background-color: #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.stat-info h3 {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-info p {
    color: #7f8c8d;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-header h2 {
    color: #2c3e50;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
    transition: all 0.2s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.search-bar .btn {
    padding: 12px 20px;
}

/* Data Lists */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-item {
    background-color: white;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 3px solid #3498db;
}

.data-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

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

.data-item-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.data-item-actions {
    display: flex;
    gap: 4px;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-small:hover {
    transform: translateY(-1px);
}

.btn-edit {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
}

.btn-delete {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
}

.data-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    font-size: 14px;
    color: #666;
}

.detail-item {
    display: flex;
    justify-content: space-between;
}

.detail-label {
    font-weight: 500;
}

.detail-value {
    color: #333;
}

/* Reports */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.report-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.report-card h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Overlay and Modals */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.overlay.active {
    display: block;
}

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

/* Modal vuông mỏng gọn */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 450px;
    border: 1px solid #ccc;
}

.modal.small .modal-content {
    max-width: 320px;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal.large .modal-content {
    max-width: 700px;
    border-radius: 8px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.modal.small .modal-header {
    padding: 6px 10px;
}

.modal.small .modal-header h3 {
    font-size: 13px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 12px;
}

.modal.small .modal-body {
    padding: 8px 10px;
}

.modal-footer {
    padding: 12px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Product Search */
.product-search-container {
    margin-bottom: 12px;
}

.product-search-container .form-control {
    width: 100%;
}

/* Selected Products */
.selected-products {
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    min-height: 100px;
    padding: 8px;
    background: #fafbfc;
}

.empty-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #95a5a6;
    font-size: 12px;
}

.empty-selection i {
    font-size: 24px;
    margin-bottom: 8px;
}

.selected-product-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    margin-bottom: 4px;
}

.selected-product-info {
    flex: 1;
}

.selected-product-name {
    font-weight: 500;
    font-size: 12px;
}

.selected-product-price {
    font-size: 11px;
    color: #666;
}

.product-price .retail-price {
    color: #e74c3c;
    font-weight: 500;
    font-size: 11px;
}

.product-price .retail-price::after {
    content: " / ";
    color: #666;
    font-weight: normal;
}

.product-price .wholesale-price {
    color: #27ae60;
    font-size: 10px;
}

.selected-product-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.price-type-selector {
    display: flex;
    gap: 4px;
}

.price-type-btn {
    padding: 2px 6px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.price-type-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.quantity-input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: center;
    font-size: 11px;
}

.remove-product-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

/* Stats Animation */
.stat-number.updating {
    animation: statsUpdate 0.3s ease-in-out;
}

@keyframes statsUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: #3498db; }
    100% { transform: scale(1); }
}

.modal.small .modal-footer {
    padding: 8px 10px;
}

/* Form Styles */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
    transition: all 0.2s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Status Badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-new {
    background-color: #3498db;
    color: white;
}

.status-in_delivery {
    background-color: #f39c12;
    color: white;
}

.status-done {
    background-color: #27ae60;
    color: white;
}

.status-cancelled {
    background-color: #e74c3c;
    color: white;
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 16px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Delivery Form */
.delivery-form-container {
    background-color: white;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}

.delivery-form-container h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 6px;
    font-size: 16px;
}

.form-section {
    margin-bottom: 12px;
}

.form-section h4 {
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.form-row .form-group {
    flex: 1;
}

.form-control {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
}

.form-actions {
    text-align: center;
    margin-top: 16px;
}

.btn-large {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
}

.delivery-history-container h3 {
    margin-bottom: 16px;
    color: #2c3e50;
}

.history-table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.history-table th {
    background-color: #f8f9fa;
    color: #2c3e50;
    font-weight: 600;
    padding: 12px 8px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap; /* Prevent text wrapping */
}

.history-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
    white-space: nowrap; /* Prevent text wrapping */
    min-width: 80px; /* Minimum width for readability */
}

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

.history-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}


/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state i {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 12px;
    }

    .main-content {
        padding: 6px;
    }

    .app-header {
        padding: 6px 8px;
        height: 36px;
    }

    .sidebar {
        top: 36px;
        height: calc(100vh - 36px);
        width: 180px;
    }

    .main-content.sidebar-open {
        margin-left: 180px;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .stat-info h3 {
        font-size: 18px;
    }

    .stat-info p {
        font-size: 11px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 12px;
    }

    .page-header .btn {
        align-self: flex-start;
    }

    .search-bar {
        flex-direction: column;
        gap: 4px;
    }


    .form-row {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 12px;
    }

    .form-row .form-group {
        flex: 1;
        min-width: 0; /* Prevent flex item from overflowing */
    }

    .delivery-form-container {
        padding: 10px;
        margin-bottom: 12px;
    }

    .form-section {
        margin-bottom: 10px;
    }

    .form-section h4 {
        font-size: 13px;
        margin-bottom: 4px;
    }

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

    .btn-large {
        padding: 8px 16px;
        font-size: 13px;
    }


    .data-item {
        padding: 10px;
    }

    .data-item-title {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 10px 15px;
    }

    .header-left {
        gap: 10px;
    }

    .page-title {
        font-size: 16px;
    }

    .stat-card {
        padding: 15px;
        gap: 10px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .stat-info h3 {
        font-size: 20px;
    }
}

/* Product Selector */

.product-selector {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.product-item {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.product-item:hover {
    background-color: #f8f9fa;
}

.product-item.selected {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.product-item:last-child {
    border-bottom: none;
}

.product-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
}

.product-price {
    color: #e74c3c;
    font-weight: 600;
    font-size: 13px;
}

.unit-display {
    margin-left: 8px;
    color: #666;
    font-size: 12px;
}

/* Mobile table optimizations */
@media (max-width: 768px) {
    .history-table-container {
        margin: 0 -8px; /* Extend to container edges */
    }

    .history-table {
        font-size: 11px;
        min-width: 600px; /* Force horizontal scroll on narrow screens */
    }

    .history-table th,
    .history-table td {
        padding: 8px 6px;
        font-size: 11px;
    }

    .status-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}



.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

/* Print Styles */
@media print {
    .app-header,
    .sidebar,
    .btn {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }
}

/* Filters */
.filters-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

/* Orders Tracking */
.orders-tracking-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tracking-stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .stat-card {
        padding: 6px;
    }

    .stat-number {
        font-size: 20px;
    }

    .history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .history-table {
        min-width: 900px;
    }

    .history-table th,
    .history-table td {
        padding: 8px 12px;
        font-size: 12px;
    }
}

.stat-card {
    background: white;
    border-radius: 4px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 2px solid #007bff;
    flex: 1;
    min-width: 0;
}

.stat-card:nth-child(2) {
    border-left-color: #28a745;
}

.stat-card:nth-child(3) {
    border-left-color: #17a2b8;
}

.stat-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,123,255,0.1);
    color: #007bff;
    font-size: 14px;
}

.stat-card:nth-child(2) .stat-icon {
    background: rgba(40,167,69,0.1);
    color: #28a745;
}

.stat-card:nth-child(3) .stat-icon {
    background: rgba(23,162,184,0.1);
    color: #17a2b8;
}

.stat-info {
    flex: 1;
}

.stat-number {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: #666;
    margin-top: 1px;
}

/* Order Tracking Table */
.history-table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Orders page specific table scroll */
#orders-page .delivery-history-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#orders-page .delivery-history-container .history-table {
    min-width: 900px;
}

/* Delivery History Table - Add horizontal scroll */
.delivery-history-container .history-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.delivery-history-container .history-table {
    min-width: 900px;
}

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

.history-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.history-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    font-size: 13px;
    vertical-align: top;
}

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

.history-table tbody tr.in-delivery-row {
    background: rgba(40, 167, 69, 0.05);
    border-left: 4px solid #28a745;
}

.driver-info {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #28a745;
    font-weight: 600;
}

.driver-info i {
    font-size: 12px;
}

/* Order Tracking Styles */
.detail-row {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.detail-row .detail-item {
    flex: 1;
}

.delivery-info {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.2);
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
}

.delivery-driver {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #28a745;
    font-weight: 600;
}

.delivery-driver i {
    font-size: 16px;
}

.data-item.in-delivery {
    border-left: 4px solid #28a745;
    background: rgba(40, 167, 69, 0.05);
}

.order-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
}

.status-new {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.status-in_delivery {
    background: rgba(40, 167, 69, 0.1);
    color: #155724;
}

.status-done {
    background: rgba(23, 162, 184, 0.1);
    color: #0c5460;
}

.status-cancelled {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
}

/* Mobile responsive for filters */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: row;
        gap: 8px;
    }

    .search-group {
        flex: 2;
    }

    .filter-group {
        flex: 1;
    }

    .filter-group {
        min-width: auto;
    }

    .tracking-stats {
        grid-template-columns: 1fr;
    }

    .detail-row {
        flex-direction: column;
        gap: 8px;
    }

    /* Delivery History Table Scroll */
    .delivery-history-container .history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .delivery-history-container .history-table {
        min-width: 900px;
    }

    .delivery-history-container .history-table th,
    .delivery-history-container .history-table td {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
}

/* Orders Tracking Section in Dashboard */
.orders-tracking-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.orders-tracking-section h3 {
    color: #2c3e50;
    font-size: 18px;
    margin: 0;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 8px 12px;
    margin-bottom: 4px;
    min-width: 200px;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    pointer-events: auto;
    border-left: 2px solid;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left-color: #28a745;
}

.toast.success .toast-icon {
    color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast-icon {
    font-size: 12px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 12px;
    line-height: 1.3;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 1px;
    border-radius: 2px;
    transition: color 0.2s;
    flex-shrink: 0;
    font-size: 12px;
}

.toast-close:hover {
    color: #666;
}

/* Filters Section */
.filters-section {
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.filter-group {
    flex: 1;
    min-width: 0;
}

.search-group {
    flex: 2;
    min-width: 0;
}

.search-group .form-control,
.filter-group .form-control {
    width: 100%;
    height: 36px;
}

/* Order Cards */
.order-card {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.order-card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.order-card.in-delivery {
    border-left: 3px solid #17a2b8;
    background: linear-gradient(90deg, rgba(23,162,184,0.02) 0%, rgba(23,162,184,0.01) 100%);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.order-id {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.order-date {
    color: #666;
    font-size: 12px;
}

.order-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.order-product {
    color: #333;
    font-size: 13px;
    flex: 1;
}

.order-price {
    font-weight: 600;
    color: #e74c3c;
    font-size: 14px;
}

.order-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #666;
}

.order-customer {
    flex: 1;
}

.order-driver {
    color: #17a2b8;
    font-weight: 500;
}

.order-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.complete-btn {
    background: #28a745;
    color: white;
}

.complete-btn:hover {
    background: #218838;
    transform: scale(1.1);
}

.delete-btn {
    background: #dc3545;
    color: white;
}

.undo-btn {
    background: #ffc107;
    color: #212529;
}

.undo-btn:hover {
    background: #e0a800;
    transform: scale(1.1);
}

.view-btn {
    background: #17a2b8;
    color: white;
}

.view-btn:hover {
    background: #138496;
    transform: scale(1.1);
}

/* Order Details Modal */
.order-details-grid {
    display: grid;
    gap: 20px;
}

.detail-section {
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 15px;
    background: #fafbfc;
}

.detail-section h4 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.detail-label {
    font-weight: 500;
    color: #666;
    font-size: 12px;
}

.detail-value {
    font-weight: 500;
    color: #2c3e50;
    font-size: 12px;
}

.order-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
}

.item-details {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.item-total {
    font-weight: bold;
    color: #e74c3c;
    font-size: 13px;
}

.debt-item .data-item-header {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
    border-left: 4px solid #e17055;
}

.debt-item .data-item-title {
    color: #d63031;
    font-weight: bold;
}

.font-weight-bold {
    font-weight: bold !important;
}

/* Payment Modal */
.order-summary {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    border-left: 4px solid #3498db;
}

.order-summary h4 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 14px;
}

.payment-info {
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
    border-bottom: none;
    font-weight: bold;
    color: #e74c3c;
}

.info-label {
    font-weight: 500;
    color: #666;
}

.info-value {
    font-weight: bold;
    color: #2c3e50;
}

.delete-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Order Actions */
.order-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    min-width: 70px;
    justify-content: center;
    font-size: 11px;
    white-space: nowrap;
}

/* Page Actions */
.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-actions .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
}

/* Reports Page Styles */
.reports-filter-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.reports-filter-section h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}

.reports-filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.reports-filter-group {
    flex: 1;
    min-width: 200px;
}

.reports-filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.reports-filter-group select,
.reports-filter-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.reports-generate-btn {
    padding: 8px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.reports-generate-btn:hover {
    background: #0056b3;
}

.reports-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.reports-stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.reports-stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.reports-stat-card:nth-child(1) .reports-stat-icon { background: #28a745; }
.reports-stat-card:nth-child(2) .reports-stat-icon { background: #007bff; }
.reports-stat-card:nth-child(3) .reports-stat-icon { background: #dc3545; }
.reports-stat-card:nth-child(4) .reports-stat-icon { background: #ffc107; }

.reports-stat-content {
    flex: 1;
}

.reports-stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
    display: block;
}

.reports-stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reports-content-section {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.reports-content-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reports-content-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.reports-export-btn {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
}

.reports-export-btn:hover {
    background: #218838;
}

.reports-data-container {
    padding: 0;
}

.table-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 30px; /* Extra space for scroll hint */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative; /* For positioning the scroll hint */
}

.table-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.reports-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 800px; /* Ensure minimum width for horizontal scrolling */
    margin: 0;
}

.reports-data-table th,
.reports-data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.reports-data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    font-size: 12px;
    text-transform: uppercase;
}

.reports-data-table tbody tr:hover {
    background: #f8f9fa;
    transition: background-color 0.2s ease;
}

.reports-data-table {
    transition: box-shadow 0.2s ease;
}

.table-scroll-container:active .reports-data-table {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Scroll hint indicator */
.table-scroll-container::before {
    content: "⟷ Cuộn ngang để xem thêm";
    position: absolute;
    top: -25px;
    right: 10px;
    font-size: 11px;
    color: #666;
    background: rgba(255,255,255,0.95);
    padding: 3px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
    z-index: 10;
    border: 1px solid #e0e0e0;
}

.table-scroll-container.has-scroll::before {
    display: block;
}

/* Smooth scrolling animation */
.table-scroll-container {
    scroll-behavior: smooth;
}

/* Better touch scrolling on mobile */
@media (max-width: 768px) {
    .table-scroll-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: auto; /* Disable smooth scrolling on mobile for better performance */
    }

    .table-scroll-container::before {
        font-size: 10px;
        padding: 2px 8px;
        top: -22px;
    }
}

.reports-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.reports-empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    color: #ccc;
}

.reports-summary-section {
    background: #f8f9fa;
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.reports-summary-item .reports-summary-value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    display: block;
    margin-bottom: 4px;
}

.reports-summary-item .reports-summary-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

/* Status badges for reports */
.reports-status-active,
.reports-status-inactive {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.reports-status-active {
    background: #28a745;
    color: white;
}

.reports-status-inactive {
    background: #dc3545;
    color: white;
}

.reports-text-danger {
    color: #dc3545;
    font-weight: 600;
}

/* Reports Tabs */
.reports-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
}

.reports-tab-btn {
    padding: 12px 20px;
    border: none;
    background: #f8f9fa;
    color: #666;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.reports-tab-btn:hover {
    background: #e9ecef;
    color: #333;
}

.reports-tab-btn.active {
    background: #fff;
    color: #007bff;
    border-bottom: 2px solid #007bff;
    margin-bottom: -1px;
}

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

/* Period Selector */
.reports-period-selector {
    display: flex;
    gap: 5px;
}

.reports-period-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.reports-period-btn:hover {
    background: #f8f9fa;
}

.reports-period-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

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

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

/* Overview Container */
.reports-overview-container {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.overview-metric {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.overview-metric h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.overview-metric .metric-value {
    font-size: 32px;
    font-weight: bold;
    color: #007bff;
    display: block;
    margin-bottom: 5px;
}

.overview-metric .metric-change {
    font-size: 12px;
    color: #28a745;
}

.overview-metric .metric-change.negative {
    color: #dc3545;
}

/* Mobile responsive for reports */
@media (max-width: 768px) {
    .reports-tabs {
        padding-bottom: 10px;
    }

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

    .reports-stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .reports-stat-card {
        padding: 15px;
    }

    .reports-stat-number {
        font-size: 20px;
    }

    .reports-content-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .reports-period-selector {
        justify-content: center;
        flex-wrap: wrap;
    }

    .table-scroll-container {
        margin-bottom: 15px;
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    }

    .table-scroll-container::-webkit-scrollbar {
        height: 6px;
    }

    .reports-data-table {
        font-size: 12px;
        min-width: 700px; /* Adjusted minimum width for mobile */
    }

    .reports-data-table th,
    .reports-data-table td {
        padding: 8px 10px;
        white-space: nowrap; /* Prevent text wrapping on mobile */
        font-size: 11px;
        max-width: 120px; /* Limit column width on mobile */
        overflow: hidden;
        text-overflow: ellipsis; /* Add ellipsis for long text */
    }

    .reports-data-table th {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Specific column widths for better mobile display */
    .reports-data-table th:nth-child(1),
    .reports-data-table td:nth-child(1) {
        min-width: 80px; /* Order ID */
    }

    .reports-data-table th:nth-child(2),
    .reports-data-table td:nth-child(2) {
        min-width: 100px; /* Customer/Name */
    }

    .reports-data-table th:nth-child(3),
    .reports-data-table td:nth-child(3) {
        min-width: 90px; /* Driver/Product */
    }

    .reports-summary-section {
        flex-direction: column;
        gap: 15px;
    }

    .reports-overview-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

