/* Clean, modern styling for order dispatcher */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.login-box .subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

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

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

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

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

.error-message {
    background: #fee2e2;
    color: var(--error-color);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

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

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

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

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

/* Dashboard */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-header h1 {
    font-size: 24px;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Monitoring Section */
.monitoring-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.monitoring-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

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

.status-card {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.status-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.status-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Orders Section */
.orders-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.sent-orders-section {
    max-height: 500px;
}

.sent-orders-section .orders-table-container {
    max-height: 350px;
    overflow-y: auto;
}

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

.section-header h2 {
    font-size: 18px;
}

.orders-table-container {
    overflow-x: auto;
}

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

.orders-table th {
    background: var(--bg-color);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
}

.orders-table td {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.orders-table tbody tr:hover {
    background: var(--bg-color);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-sent {
    background: #dbeafe;
    color: var(--primary-color);
}

.status-pending {
    background: #fef3c7;
    color: var(--warning-color);
}

.status-failed {
    background: #fee2e2;
    color: var(--error-color);
}

.status-confirmed {
    background: #d1fae5;
    color: var(--success-color);
}

.status-sent_externally {
    background: #e0e7ff;
    color: #6366f1;
}

.status-error {
    background: #fee2e2;
    color: var(--error-color);
}

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

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 15px;
    font-size: 16px;
}

/* Log Details */
.log-entry {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.log-entry h4 {
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.log-entry p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 5px 0;
}

.log-entry pre {
    background: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    margin-top: 8px;
}

/* Progress Bar */
.progress-bar-container {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    position: relative;
    height: 60px;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #60a5fa);
    border-radius: 8px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-bar-text {
    position: relative;
    z-index: 1;
    text-align: center;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 30px;
    padding-top: 5px;
}

/* Filter Section */
.filter-section {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

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

/* Toggle Switch */
.cronjob-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cronjob-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.cronjob-info {
    text-align: center;
}

.cronjob-info small {
    color: var(--text-secondary);
    font-size: 11px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .status-cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .sent-orders-section {
        max-height: none;
    }
}

