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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    color: #2c3e50;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#current-time {
    color: #7f8c8d;
    font-size: 14px;
}

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

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

.stat-label {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #3498db;
}

/* Filters */
.filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.search-input, .filter-select {
    padding: 10px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 5px;
    font-size: 14px;
    flex: 1;
    min-width: 200px;
}

.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: #3498db;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-icon, .btn-danger, .btn-success {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

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

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #2ecc71;
    color: white;
}

.btn-success:hover {
    background: #27ae60;
}

.btn-icon {
    background: #ecf0f1;
    padding: 8px 12px;
    font-size: 16px;
}

.btn-icon:hover {
    background: #bdc3c7;
}

/* Jobs Container */
.jobs-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.jobs-header h2 {
    font-size: 24px;
}

.jobs-count {
    color: #7f8c8d;
    font-size: 14px;
}

/* Jobs List */
.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.job-card {
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.job-card:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.job-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.job-id {
    font-weight: bold;
    font-size: 16px;
    color: #2c3e50;
}

.job-state {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.state-pending_payment { background: #f39c12; color: white; }
.state-payment_secured { background: #27ae60; color: white; }
.state-dispatching { background: #3498db; color: white; }
.state-assigned { background: #9b59b6; color: white; }
.state-accepted { background: #16a085; color: white; }
.state-en_route { background: #2980b9; color: white; }
.state-in_progress { background: #e67e22; color: white; }
.state-completed { background: #27ae60; color: white; }
.state-cancelled { background: #95a5a6; color: white; }

.job-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.job-detail {
    display: flex;
    flex-direction: column;
}

.job-detail-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 3px;
}

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

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 10px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #ecf0f1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #7f8c8d;
    line-height: 1;
}

.close-btn:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 30px;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 3px;
}

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

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

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

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

/* Change Orders */
.change-order-card {
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

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

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

.change-order-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

/* State History */
.state-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    gap: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3498db;
}

.history-state {
    min-width: 140px;
}

.history-details {
    flex: 1;
}

.history-time {
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 3px;
}

.history-note {
    font-size: 14px;
    color: #2c3e50;
}

/* Additional state colors for change orders */
.state-pending { background: #f39c12; color: white; }
.state-approved { background: #27ae60; color: white; }
.state-rejected { background: #e74c3c; color: white; }
.state-charged { background: #16a085; color: white; }

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
    }

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

    .filters {
        flex-direction: column;
    }

    .job-card-body {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        gap: 8px;
    }

    .change-order-body {
        grid-template-columns: 1fr;
    }
}
