/* ========================================
GLOBAL STYLES
========================================
*/
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    padding: 8px;
    color: #333;
}

#app-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.page {
    padding: 20px;
}

.user-info {
    font-size: 14px;
    color: #666;
    margin-right: 12px;
}

.loading-text {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.success-message {
    color: #28a745;
    font-weight: 500;
    font-size: 14px;
    margin-top: 8px;
}

.error-message {
    color: #dc3545;
    font-weight: 500;
    font-size: 14px;
    margin-top: 8px;
}

/* ========================================
LOGIN PAGE STYLES
========================================
*/
.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 400px;
    margin: 60px auto;
    padding: 40px 20px;
}

.logo-placeholder {
    font-size: 80px;
    margin-bottom: 20px;
}

.login-card h2 {
    margin: 0 0 8px 0;
    color: #1a1a1a;
    font-size: 28px;
}

.login-card h3 {
    margin: 0 0 32px 0;
    font-weight: 500;
    color: #666;
    font-size: 16px;
}

#login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ========================================
FORM AND INPUT STYLES
========================================
*/
.input-group {
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.input-group input,
.input-group textarea,
.input-group select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Button Group Toggle */
.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-toggle {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.btn-toggle:hover {
    border-color: #007bff;
}

/* ========================================
BUTTON STYLES
========================================
*/
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

/* ========================================
ADMIN APP STYLES
========================================
*/
.admin-header,
.driver-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 16px;
    margin-bottom: 20px;
    gap: 12px;
}

.admin-header h2,
.driver-header h2 {
    margin: 0;
    font-size: 24px;
    flex: 1;
}

.admin-header > div,
.driver-header > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tab Navigation */
.admin-nav,
.driver-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

.nav-tab,
.driver-nav-tab {
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-tab:hover,
.driver-nav-tab:hover {
    background-color: #f8f9fa;
}

.nav-tab.active,
.driver-nav-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

/* Tab Content */
.tab-content,
.driver-section {
    display: none;
}

.tab-content.active,
.driver-section.active {
    display: block;
}

/* Cards and Sections */
.card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 16px;
    color: #1a1a1a;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.card p {
    margin: 0 0 16px 0;
    color: #666;
}

.section-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 32px 0;
}

/* ========================================
FORM STYLES
========================================
*/
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

/* ========================================
DATA LISTS AND TABLES
========================================
*/
.data-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.data-item {
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.data-item-info {
    flex: 1;
    min-width: 200px;
}

.data-item-info strong {
    display: block;
    margin-bottom: 4px;
}

.data-item-info small {
    color: #999;
}

.data-item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.data-item-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.data-table th {
    background-color: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    font-size: 14px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

/* ========================================
FINANCE MODULE STYLES
========================================
*/
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-item {
    background-color: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.summary-item .label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.summary-item .value {
    display: block;
    font-size: 24px;
    color: #007bff;
    font-weight: bold;
}

.ledger-summary {
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin-top: 16px;
    font-size: 16px;
}

.reconciliation-item {
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.reconciliation-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.reconciliation-item label {
    flex: 1;
    margin: 0;
    cursor: pointer;
}

/* ========================================
DRIVER APP STYLES
========================================
*/
.orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.order-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    background: white;
}

.order-card h5 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #1a1a1a;
}

.order-card p {
    margin: 4px 0;
    font-size: 12px;
    color: #666;
}

.order-card .status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.status-badge.assigned {
    background-color: #cfe2ff;
    color: #084298;
}

.status-badge.in-transit {
    background-color: #fff3cd;
    color: #664d03;
}

.status-badge.delivered {
    background-color: #d1e7dd;
    color: #0f5132;
}

.order-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.detail-item {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
}

.detail-item strong {
    display: block;
    margin-bottom: 4px;
    color: #666;
    font-size: 12px;
}

.detail-item span {
    display: block;
    font-size: 16px;
    color: #1a1a1a;
}

/* ========================================
NOTIFICATION STYLES
========================================
*/
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.notification {
    background: white;
    border-left: 4px solid #007bff;
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    border-left-color: #28a745;
}

.notification.error {
    border-left-color: #dc3545;
}

.notification.warning {
    border-left-color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
NEW ENHANCED STYLES
======================================== */

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Dashboard Styles */
.summary-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.summary-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
}

.summary-content h3 {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
    color: #1a1a1a;
}

.summary-content p {
    margin: 4px 0 0 0;
    color: #666;
    font-size: 14px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.quick-action-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.quick-action-btn:hover {
    border-color: #007bff;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.quick-action-btn span:first-child {
    font-size: 24px;
}

.quick-action-btn span:last-child {
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

/* Search and Filter */
.search-filter-container {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

/* Bulk Actions */
.bulk-actions {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.bulk-actions select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

/* Report Styles */
.report-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.report-summary h5 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #333;
}

.data-table-container {
    overflow-x: auto;
    max-width: 100%;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Enhanced Status Badges */
.status-badge.completed {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-badge.invoiced {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Print Styles */
@media print {
    .admin-nav,
    .driver-nav,
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
}

/* Enhanced Form Validation */
.input-group input:invalid {
    border-color: #dc3545;
}

.input-group input:valid {
    border-color: #28a745;
}

/* Animation Enhancements */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ========================================
RESPONSIVE DESIGN
========================================
*/
@media (max-width: 768px) {
    .page {
        padding: 16px;
    }

    .admin-header,
    .driver-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-header > div,
    .driver-header > div {
        width: 100%;
        justify-content: space-between;
    }

    .admin-header h2,
    .driver-header h2 {
        width: 100%;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .orders-grid {
        grid-template-columns: 1fr;
    }

    .order-details-grid {
        grid-template-columns: 1fr;
    }

    .data-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-item-actions {
        width: 100%;
    }

    .data-item-actions button {
        flex: 1;
    }

    .login-card {
        margin: 40px auto;
        padding: 20px;
    }

    .notification-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    /* Enhanced Mobile Styles */
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .bulk-actions select {
        width: 100%;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-card {
        flex-direction: column;
        text-align: center;
    }

    .modal-content {
        margin: 20px;
        width: auto;
    }
}

@media (max-width: 480px) {
    #app-container {
        border-radius: 0;
    }

    body {
        padding: 0;
    }

    .page {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

    .btn-large {
        font-size: 14px;
        padding: 12px;
    }

    .summary-item .value {
        font-size: 20px;
    }

    .admin-nav,
    .driver-nav {
        margin-bottom: 16px;
    }

    .nav-tab,
    .driver-nav-tab {
        padding: 10px 12px;
        font-size: 12px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .summary-card {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .data-table {
        color: #e2e8f0;
    }
    
    .data-table th {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .data-table tr:hover {
        background: #4a5568;
    }
}