/* CSS Variables */
:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #64748b;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    
    --color-bg: #ffffff;
    --color-bg-secondary: #f8fafc;
    --color-bg-tertiary: #f1f5f9;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-secondary);
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

/* Configuration Grid */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.model-select {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    font-size: 0.875rem;
    color: var(--color-text);
}

.config-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Editors */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.filename {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.code-editor,
.text-editor {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Pipeline */
.pipeline-container {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pipeline-step {
    padding: 1rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.step-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.step-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.step-badge.pending {
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
}

.step-badge.running {
    background: #fef3c7;
    color: #92400e;
}

.step-badge.done {
    background: #d1fae5;
    color: #065f46;
}

.step-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.step-output {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pipeline-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Results */
.results-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.results-content {
    min-height: 400px;
}

.results-pane {
    display: none;
}

.results-pane.active {
    display: block;
}

.job-cards,
.application-cards {
    display: grid;
    gap: 1rem;
}

.job-card,
.application-card {
    padding: 1rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.job-card h4,
.application-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.job-card-company {
     font-size: 0.75rem;
     font-weight: 600;
     text-transform: uppercase;
     letter-spacing: 0.05em;
     color: var(--color-primary);
     margin-bottom: 0.25rem;
}
/* Company grouping in job matches */
.company-group {
     margin-bottom: 1.5rem;
     border: 1px solid var(--color-border);
     border-radius: var(--radius-lg);
     overflow: hidden;
}
.company-group-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     padding: 0.875rem 1.25rem;
     background: var(--color-bg-tertiary);
     border-bottom: 1px solid var(--color-border);
}
.company-group-title {
     display: flex;
     align-items: baseline;
     gap: 0.75rem;
}
.company-group-name {
     font-size: 1rem;
     font-weight: 700;
     color: var(--color-text);
}
.company-job-count {
     font-size: 0.75rem;
     color: var(--color-text-muted);
     font-weight: 400;
}
.company-group-actions {
     display: flex;
     gap: 0.5rem;
     align-items: center;
}
.company-jobs {
     padding: 1rem;
     display: grid;
     gap: 0.75rem;
}
/* Remove company label from individual cards since it's in the group header */
.company-jobs .job-card {
     border-left: 3px solid var(--color-primary);
     background: var(--color-bg);
}


.job-details,
.application-preview {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.job-actions,
.application-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.batch-log {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius-md);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    display: none;
}

.batch-log.visible {
    display: block;
}

.log-entry {
    margin-bottom: 0.25rem;
}

.log-entry.log-error {
    color: #fca5a5;
}

.log-entry.log-success {
    color: #86efac;
}

.log-entry.log-warning {
    color: #fde047;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-secondary);
}

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

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

.btn-icon {
    padding: 0.5rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Status Messages */
.status-msg {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.status-msg.success {
    color: var(--color-success);
}

.status-msg.error {
    color: var(--color-danger);
}

.status-msg.warning {
    color: var(--color-warning);
}

.status-badge {
    padding: 0.25rem 0.5rem;
    background: var(--color-success);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

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

.modal-content {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Usage Modal */
.usage-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.usage-stat {
    padding: 1rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    text-align: center;
}

.usage-stat.highlight {
    background: var(--color-primary);
    color: white;
}

.usage-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    opacity: 0.8;
}

.usage-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

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

.usage-table th,
.usage-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.usage-table th {
    font-weight: 600;
    background: var(--color-bg-tertiary);
}

.usage-number-cell,
.usage-cost-cell {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
}

.usage-totals-row {
    font-weight: 600;
    background: var(--color-bg-tertiary);
}

/* Git Modal */
.git-status-box {
    padding: 1rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.git-status-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.git-status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.git-status-indicator.clean {
    background: #d1fae5;
    color: #065f46;
}

.git-status-indicator.dirty {
    background: #fef3c7;
    color: #92400e;
}

.git-status-indicator.uninit {
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
}

.git-branch-badge {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.git-changes-list {
    list-style: none;
    font-size: 0.875rem;
}

.git-changes-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.git-change-badge {
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.git-change-badge.modified {
    background: #fef3c7;
    color: #92400e;
}

.git-change-badge.added {
    background: #d1fae5;
    color: #065f46;
}

.git-change-badge.deleted {
    background: #fee2e2;
    color: #991b1b;
}

.git-change-badge.untracked {
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
}

.git-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.git-message-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

/* Help Modal */
.help-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.help-content h3:first-child {
    margin-top: 0;
}

.help-content ol,
.help-content ul {
    margin-left: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.75;
}

.help-content li {
    margin-bottom: 0.25rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s;
}

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

.toast.removing {
    transform: translateX(400px);
}

.toast-success {
    background: var(--color-success);
    color: white;
}

.toast-error {
    background: var(--color-danger);
    color: white;
}

.toast-warning {
    background: var(--color-warning);
    color: white;
}

.toast-info {
    background: var(--color-info);
    color: white;
}

/* Session Links */
.session-link-container {
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.session-monitor-link,
.session-completed-link,
.session-error-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
}

.monitor-pulse {
    color: var(--color-warning);
    animation: pulse 1.5s infinite;
}

.monitor-link {
    color: var(--color-primary);
    text-decoration: none;
}

.monitor-link:hover {
    text-decoration: underline;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Placeholder */
.placeholder {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .modal {
        padding: 1rem;
    }
}
/* Large Modal */
.modal-content-large {
     max-width: 900px;
     width: 95vw;
     max-height: 90vh;
}
.modal-title-group {
     display: flex;
     flex-direction: column;
     gap: 0.25rem;
}
.modal-subtitle {
     font-size: 0.8rem;
     color: var(--color-text-muted);
     font-weight: 400;
}
/* Modal Tabs */
.modal-tabs {
     display: flex;
     gap: 0;
     border-bottom: 1px solid var(--color-border);
     padding: 0 1.5rem;
     background: var(--color-bg-tertiary);
}
.modal-tab-btn {
     padding: 0.6rem 1.25rem;
     background: none;
     border: none;
     border-bottom: 2px solid transparent;
     font-size: 0.875rem;
     font-weight: 500;
     color: var(--color-text-muted);
     cursor: pointer;
     transition: all 0.2s;
     margin-bottom: -1px;
}
.modal-tab-btn:hover {
     color: var(--color-text);
}
.modal-tab-btn.active {
     color: var(--color-primary);
     border-bottom-color: var(--color-primary);
     background: var(--color-bg);
}
.modal-tab-pane {
     display: none;
}
.modal-tab-pane.active {
     display: block;
}
.modal-body-scroll {
     overflow-y: auto;
     flex: 1;
     padding: 1.5rem;
}
/* Raw editor */
.raw-toolbar {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     margin-bottom: 0.75rem;
}
.raw-editor {
     width: 100%;
     height: 500px;
     padding: 1rem;
     border: 1px solid var(--color-border);
     border-radius: var(--radius-md);
     font-family: 'Consolas', 'Monaco', monospace;
     font-size: 0.8rem;
     line-height: 1.6;
     resize: vertical;
     background: var(--color-bg-tertiary);
     color: var(--color-text);
}
/* Markdown body rendering */
.markdown-body {
     line-height: 1.7;
     color: var(--color-text);
}
.markdown-body h1 {
     font-size: 1.6rem;
     font-weight: 700;
     margin: 0 0 1rem 0;
     padding-bottom: 0.5rem;
     border-bottom: 2px solid var(--color-border);
     color: var(--color-text);
}
.markdown-body h2 {
     font-size: 1.25rem;
     font-weight: 600;
     margin: 1.5rem 0 0.75rem 0;
     padding-bottom: 0.25rem;
     border-bottom: 1px solid var(--color-border);
     color: var(--color-text);
}
.markdown-body h3 {
     font-size: 1.05rem;
     font-weight: 600;
     margin: 1.25rem 0 0.5rem 0;
     color: var(--color-text);
}
.markdown-body h4 {
     font-size: 0.95rem;
     font-weight: 600;
     margin: 1rem 0 0.4rem 0;
     color: var(--color-text-muted);
     text-transform: uppercase;
     letter-spacing: 0.04em;
}
.markdown-body p {
     margin: 0 0 0.85rem 0;
}
.markdown-body ul,
.markdown-body ol {
     margin: 0 0 0.85rem 1.5rem;
}
.markdown-body li {
     margin-bottom: 0.3rem;
}
.markdown-body strong {
     font-weight: 600;
     color: var(--color-text);
}
.markdown-body em {
     font-style: italic;
     color: var(--color-text-muted);
}
.markdown-body code {
     font-family: 'Consolas', 'Monaco', monospace;
     font-size: 0.85em;
     background: var(--color-bg-tertiary);
     border: 1px solid var(--color-border);
     border-radius: var(--radius-sm);
     padding: 0.1em 0.4em;
}
.markdown-body pre {
     background: #1e293b;
     color: #e2e8f0;
     border-radius: var(--radius-md);
     padding: 1rem;
     overflow-x: auto;
     margin: 0 0 1rem 0;
}
.markdown-body pre code {
     background: none;
     border: none;
     padding: 0;
     font-size: 0.875rem;
     color: inherit;
}
.markdown-body blockquote {
     border-left: 4px solid var(--color-primary);
     margin: 0 0 1rem 0;
     padding: 0.5rem 1rem;
     background: var(--color-bg-tertiary);
     border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
     color: var(--color-text-muted);
}
.markdown-body hr {
     border: none;
     border-top: 1px solid var(--color-border);
     margin: 1.5rem 0;
}
.markdown-body a {
     color: var(--color-primary);
     text-decoration: none;
}
.markdown-body a:hover {
     text-decoration: underline;
}
.markdown-body table {
     width: 100%;
     border-collapse: collapse;
     margin: 0 0 1rem 0;
     font-size: 0.875rem;
}
.markdown-body th,
.markdown-body td {
     padding: 0.5rem 0.75rem;
     border: 1px solid var(--color-border);
     text-align: left;
}
.markdown-body th {
     background: var(--color-bg-tertiary);
     font-weight: 600;
}
.markdown-body tr:nth-child(even) td {
     background: var(--color-bg-secondary);
}
/* Job details loading state */
.job-details-loading {
     display: flex;
     align-items: center;
     justify-content: center;
     padding: 3rem;
     color: var(--color-text-muted);
     font-size: 1rem;
     gap: 0.75rem;
}
.spinner {
     width: 1.25rem;
     height: 1.25rem;
     border: 2px solid var(--color-border);
     border-top-color: var(--color-primary);
     border-radius: 50%;
     animation: spin 0.7s linear infinite;
}
@keyframes spin {
     to { transform: rotate(360deg); }
}