@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-main: #f9fafb;
    --bg-panel: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #059669;
    --warning: #d97706;
    --font-family: 'Inter', sans-serif;
}

/* Dark mode overrides for corporate style */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #0f172a;
        --bg-panel: #1e293b;
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --border-color: #334155;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --danger: #ef4444;
        --danger-hover: #f87171;
    }
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 13px; /* Corporate density */
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--bg-main);
}

.auth-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 6px;
    width: 320px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.auth-box h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.input-group { margin-bottom: 12px; }
.input-group label { display: block; margin-bottom: 4px; font-weight: 500; color: var(--text-secondary); }
.input-group input { width: 100%; padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-main); color: var(--text-primary); font-family: inherit; }

.btn {
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-main);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn:hover { background: var(--border-color); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); color: white; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); color: white; }
.btn-small { padding: 2px 8px; font-size: 11px; }

#dashboard-container {
    display: none;
    padding: 16px;
    max-width: 1600px;
    margin: 0 auto;
    height: 100vh;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header h1 { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 240px 1fr 300px;
    gap: 16px;
    height: calc(100vh - 90px);
}

@media (max-width: 1200px) {
    body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }
    #dashboard-container {
        height: auto;
    }
    .dashboard-grid {
        grid-template-columns: 1fr 300px;
        height: auto;
    }
    .sidebar {
        grid-column: 1 / -1;
        display: flex;
        gap: 16px;
        height: auto;
    }
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.panel-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.panel-content {
    padding: 12px;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Sidebar Widgets */
.widget { margin-bottom: 16px; }
.widget:last-child { margin-bottom: 0; }
.widget-title { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.stat-val { font-weight: 600; }
.progress-bar { height: 6px; background: var(--border-color); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.6s ease, background 0.4s ease; }

/* Jobs Table */
.jobs-panel { height: 100%; min-width: 0; overflow: hidden; }
.jobs-panel > .panel-content { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
th { font-weight: 600; color: var(--text-secondary); position: sticky; top: 0; background: var(--bg-panel); z-index: 10; font-size: 12px; }
tr:hover td { background: var(--bg-main); }

/* Job ID cell - never truncate */
.job-id-cell {
    font-family: monospace;
    font-size: 11px;
    white-space: nowrap;
    overflow: visible !important;
    max-width: none !important;
    text-overflow: clip !important;
}

.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}
.badge.pending { background: rgba(217, 119, 6, 0.1); color: var(--warning); }
.badge.processing { background: rgba(37, 99, 235, 0.1); color: var(--accent); }
.badge.completed { background: rgba(5, 150, 105, 0.1); color: var(--success); }
.badge.failed { background: rgba(220, 38, 38, 0.1); color: var(--danger); }

/* Logs Panel */
.logs-panel { height: 100%; }
@media (max-width: 1200px) {
    .jobs-panel, .logs-panel {
        height: calc(100vh - 120px);
        min-height: 450px;
    }
}
.log-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 11px;
}
.log-item:last-child { border-bottom: none; }
.log-meta { color: var(--text-secondary); margin-bottom: 2px; }
.log-error { color: var(--danger); }

/* Utils */
.action-links { display: flex; gap: 8px; }
.action-links a { color: var(--accent); text-decoration: none; cursor: pointer; }
.action-links a:hover { text-decoration: underline; }
.action-links a.text-danger { color: var(--danger); }

.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 12px 16px;
    background: var(--text-primary);
    color: var(--bg-main);
    border-radius: 4px;
    font-size: 13px;
    transform: translateY(100px);
    opacity: 0;
    transition: 0.3s;
    z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.loader { width: 16px; height: 16px; border: 2px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

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

.modal.show {
    display: flex !important;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
}

.form-group input[type="datetime-local"],
.form-group select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}
.form-group input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Sortable Headers */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    background: var(--bg-main);
}

/* Sequence job groups */
.group-toggle {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0 4px 0 0;
    font-size: 12px;
    line-height: 1;
    vertical-align: middle;
}
.group-toggle:hover { color: var(--accent-hover); }
tr.job-child-row td:first-child + td { border-left: 2px solid var(--accent); }

/* Confirm modal */
#confirm-modal { z-index: 10000; }
#confirm-modal .modal-content { animation: slideUp 0.18s ease; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
#confirm-message { font-size: 14px; line-height: 1.6; color: var(--text-primary); }
#confirm-ok-btn { min-width: 90px; }

/* Responsive styles for smaller viewports */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        flex-direction: column;
    }
    .jobs-panel, .logs-panel {
        height: 500px;
        min-height: 400px;
    }
}
