/* Import IBM Plex Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Color Palette */
:root {
    --gray-3: #929292;
    --gray-2: #D5D5D5;
    --gray-1: #EBEBEB;

    --bg: #F7F7F7;
    --fg: #2F3338;
    --accent: #434D5F;

    --blue: #37A5BE;
    --green: #26A671;
    --yellow: #EAEDAD;
    --yellow-accent: #DCE279;
    --yellow-fg: #84876C;
    --orange: #F27200;
    --red: #FF3900;

    /* Border radius - NO rounded corners */
    --radius: 2px;

    /* Spacing */
    --spacing-xs: 3px;
    --spacing-sm: 6px;
    --spacing-md: 10px;
    --spacing-lg: 14px;
    --spacing-xl: 20px;
    --spacing-2xl: 30px;
}

/* Base Reset and Typography */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.4;
    min-height: 100vh;
}

/* Typography Scale */
h1 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    color: var(--fg);
}

h2 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
    color: var(--fg);
}

h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
    color: var(--fg);
}

p {
    margin-bottom: var(--spacing-md);
    line-height: 1.4;
}

.text-small {
    font-size: 12px;
}

.text-xs {
    font-size: 11px;
}

.text-2xs {
    font-size: 10px;
}

.text-mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* Links */
a {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.1s ease;
}

a:hover {
    color: var(--accent);
}

a.no-style, a.plain {
    color: inherit;
    text-decoration: none;
}

a.no-style:hover, a.plain:hover {
    color: inherit;
    text-decoration: none;
}

/* Minimal navigation styles removed - using inline styles in template */

/* Main Layout */
.main-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 40px 15px 10px 15px !important;
}

/* Grid System - Responsive with min-width */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

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

/* Responsive breakpoints */
@media (max-width: 1400px) {
    .grid-5 {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 1200px) {
    .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .grid-5 {
        grid-template-columns: 1fr;
    }

    .grid {
        gap: var(--spacing-md);
    }
}

@media (max-width: 480px) {
    .grid {
        gap: var(--spacing-sm);
    }
}

/* Cards and Panels */
.card {
    background: white;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
}

.card-compact {
    padding: var(--spacing-md);
}

.card-header {
    border-bottom: 1px solid var(--gray-2);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

/* Tables - Professional Dense Design */
table {
    width: 100%;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    font-size: 13px;
}

/* Table container for overflow on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

thead {
    background: var(--gray-1);
}

th {
    text-align: left;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 0.5px solid var(--gray-3);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
    color: var(--accent);
}

td {
    text-align: left;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--gray-2);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #FAFAFA;
}

.table-compact td,
.table-compact th {
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* Status Indicators - Dotted Border Style */
.status {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px dotted;
    border-radius: 0;
    background: white;
}

.status-running {
    border-color: #1565C0;
    color: #1565C0;
    background: #E3F2FD;
}

.status-completed {
    border-color: #2E7D32;
    color: #2E7D32;
    background: #E8F5E9;
}

.status-failed {
    border-color: #C62828;
    color: #C62828;
    background: #FFEBEE;
}

.status-pending, .status-preempted {
    border-color: var(--orange);
    color: var(--orange);
    background: var(--yellow);
}

.status-cancelled, .status-unknown {
    border-color: var(--gray-3);
    color: var(--gray-3);
    background: var(--gray-1);
}

/* Statistics Cards - Compact Professional Style */
.stat-card {
    background: white;
    border: 1px solid var(--gray-3);
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.stat-card-header {
    background: var(--gray-1);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-bottom: 1px solid var(--gray-3);
}

.stat-label {
    font-size: 10px;
    letter-spacing: 0.3px;
    color: var(--accent);
    font-weight: 600;
}

.stat-card-body {
    padding: var(--spacing-sm);
    background: white;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--fg);
    font-family: 'IBM Plex Mono', monospace;
    line-height: 1;
}

.stat-value.small {
    font-size: 20px;
}

.stat-change {
    font-size: 11px;
    color: var(--gray-3);
    margin-top: var(--spacing-xs);
}

.stat-change.positive {
    color: var(--green);
}

.stat-change.negative {
    color: var(--red);
}

/* Forms and Inputs */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="password"],
textarea {
    width: 100%;
    background: white;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--fg);
    transition: border-color 0.1s ease;
    height: 32px;
    line-height: 1;
    box-sizing: border-box;
}

select {
    width: 100%;
    padding-left: 10px !important;
    background: white;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--fg);
    transition: border-color 0.1s ease;
    height: 32px;
    line-height: 1;
    box-sizing: border-box;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23929292' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

textarea {
    height: auto;
    line-height: 1.4;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--gray-3);
}

input::placeholder {
    color: var(--gray-3);
    opacity: 1;
    font-size: 11px;
    letter-spacing: 0.3px;
}

select option {
    padding: 4px 8px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.3px;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    background: white;
    color: var(--fg);
    cursor: pointer;
    transition: all 0.1s ease;
    height: 32px;
    line-height: 1;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background: var(--gray-1);
    border-color: var(--gray-3);
}

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

.btn-primary:hover {
    background: var(--fg);
    border-color: var(--fg);
}

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

.btn-danger:hover {
    background: #CC2E00;
    border-color: #CC2E00;
}

.btn-small {
    padding: 4px 8px;
    font-size: 10px;
    height: 24px;
}

/* Job Cards - Compact Order Slip Style */
.job-card {
    background: white;
    border: 1px solid var(--gray-3);
    border-radius: 0;
    overflow: hidden;
    position: relative;
    transition: border-color 0.1s ease;
    cursor: pointer;
    min-width: 320px;
    width: 100%;
}

.job-card:hover {
    border-color: var(--fg);
}

.job-card-link {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.job-card-row {
    display: flex;
    border-bottom: 1px solid var(--gray-2);
    min-height: 32px;
    align-items: stretch;
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.job-card-row a {
    pointer-events: auto;
    position: relative;
    z-index: 3;
}

.job-card-row:last-child {
    border-bottom: none;
}

.job-card-cell {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-right: 1px solid var(--gray-2);
    display: flex;
    align-items: center;
    min-height: 26px;
}

.job-card-cell:last-child {
    border-right: none;
}

.job-card-label {
    min-width: 80px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-3);
    letter-spacing: 0.3px;
}

.job-card-value {
    flex: 1;
    font-size: 13px;
    color: var(--fg);
}

.job-card-value.bold {
    font-weight: 600;
}

.job-card-id {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    padding: 2px 6px;
    border: 1px dotted var(--gray-3);
    background: var(--gray-1);
    color: var(--accent);
    display: inline-block;
    margin-right: var(--spacing-sm);
    flex-shrink: 0;
}

.job-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-card-metadata {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--gray-3);
}

/* Log Viewer */
.log-viewer {
    background: #1A1B1E;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    overflow-x: auto;
}

.log-content {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: #C5C8C6;
}

.log-line {
    display: block;
    padding: 1px 0;
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Utility Classes */
.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.text-muted { color: var(--gray-3); }
.text-accent { color: var(--accent); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--orange); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }

/* Loading States */
.loading-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--gray-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
}

/* Job Detail Page Responsive Layout */
.info-grid-responsive {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

.job-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-detail-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.job-detail-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
}

.log-viewer-section {
    min-width: 0;
}

.job-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .job-detail-content {
        grid-template-columns: 1fr;
    }

    .info-grid-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }

    /* Job cards full width on mobile */
    .job-card {
        min-width: unset;
        width: 100%;
    }

    /* Stack table columns on mobile */
    table {
        font-size: 11px;
    }

    th, td {
        padding: var(--spacing-xs);
    }

    /* Hide less important columns on mobile */
    .hide-mobile-table {
        display: none;
    }

    /* Cards responsive */
    .stat-card {
        min-width: unset;
    }

    /* Grid spacing adjustments on mobile */
    .grid {
        gap: var(--spacing-sm);
    }

    .grid-5 {
        gap: var(--spacing-sm);
    }

    /* Section spacing on mobile */
    .space-y-5 > * + * {
        margin-top: var(--spacing-lg);
    }

    .mb-5 {
        margin-bottom: var(--spacing-md);
    }

    .mb-6 {
        margin-bottom: var(--spacing-lg);
    }

    /* Job detail page mobile */
    .info-grid-responsive {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
        padding: 0 var(--spacing-md);
    }

    .job-detail-header {
        padding: 0 var(--spacing-md);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .job-detail-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .job-detail-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        padding: 0 var(--spacing-md);
    }

    /* Log viewer full width on mobile */
    .log-viewer-container {
        width: 100%;
    }

    .log-viewer-body {
        height: 400px;
        font-size: 10px;
    }

    /* Sidebar cards stack */
    .job-detail-sidebar {
        order: 2;
    }

    .job-detail-sidebar .card {
        width: 100%;
    }

    .log-viewer-section {
        order: 1;
    }

    /* Breadcrumbs mobile */
    .breadcrumbs {
        padding: 0 var(--spacing-md);
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 16px;
    }

    h2 {
        font-size: 13px;
    }

    /* Filters stack vertically on mobile */
    .flex.gap-2 {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .flex.gap-2 > div {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Full width buttons on mobile */
    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Grid adjustments */
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Table overflow */
    table {
        display: block;
        overflow-x: auto;
    }

    /* Job detail mobile optimizations */
    .info-grid-responsive {
        padding: 0 var(--spacing-sm);
    }

    .job-detail-header {
        padding: 0 var(--spacing-sm);
    }

    .job-detail-content {
        padding: 0 var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .stat-card-body {
        padding: var(--spacing-xs);
    }

    .stat-value {
        font-size: 20px;
    }

    /* Smaller log viewer on small screens */
    .log-viewer-body {
        height: 300px;
        font-size: 9px;
    }

    /* Compact cards on small screens */
    .card {
        padding: var(--spacing-sm);
    }

    /* Breadcrumbs wrap */
    .breadcrumbs {
        padding: 0 var(--spacing-sm);
        flex-wrap: wrap;
        font-size: 10px;
    }
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-1);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--accent);
}

/* Data Display */
.data-label {
    font-size: 11px;
    color: var(--gray-3);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.data-value {
    font-size: 13px;
    color: var(--fg);
    margin-top: 2px;
}

.data-mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--gray-3);
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: var(--spacing-md);
    opacity: 0.3;
}

.empty-state-text {
    font-size: 13px;
}

/* Progress Bars */
.progress-bar {
    height: 4px;
    background: var(--gray-1);
    border-radius: var(--radius);
    overflow: hidden;
    margin: var(--spacing-sm) 0;
}

.progress-fill {
    height: 100%;
    background: var(--blue);
    transition: width 0.3s ease;
}

.progress-fill.success {
    background: var(--green);
}

.progress-fill.danger {
    background: var(--red);
}

/* Dense Information Display */
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--spacing-xs) var(--spacing-md);
    font-size: 12px;
}

.info-label {
    color: var(--gray-3);
    font-weight: 600;
}

.info-value {
    color: var(--fg);
}

/* Tags and Labels */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    background: var(--gray-1);
    color: var(--accent);
    border-radius: var(--radius);
    margin-right: var(--spacing-xs);
    height: 24px;
    line-height: 1;
    box-sizing: border-box;
}

.tag-blue {
    background: #E3F2FD;
    color: #1565C0;
}

.tag-green {
    background: #E8F5E9;
    color: #2E7D32;
}

.tag-yellow {
    background: var(--yellow);
    color: var(--yellow-fg);
}

/* Code Blocks */
.code-block {
    background: #1A1B1E;
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    overflow-x: auto;
}

.code-block code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    line-height: 1.4;
    color: #C5C8C6;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 12px;
    margin-bottom: var(--spacing-md);
}

.breadcrumb-separator {
    color: var(--gray-3);
}

.breadcrumb-item {
    color: var(--gray-3);
}

.breadcrumb-item.active {
    color: var(--fg);
    font-weight: 500;
}
