/* ============================================
   CVFormatic Portal — Custom Styles
   Phase 1 Internal Dashboard
   Updated: Part 8B — Status, Results, History
   ============================================ */

/* Brand Colors */
:root {
    --cvf-dark: #1a2332;
    --cvf-primary: #2563eb;
    --cvf-primary-hover: #1d4ed8;
    --cvf-accent: #38bdf8;
    --cvf-success: #22c55e;
    --cvf-warning: #f59e0b;
    --cvf-danger: #ef4444;
    --cvf-bg: #f1f5f9;
    --cvf-card-bg: #ffffff;
    --cvf-text: #334155;
    --cvf-text-muted: #94a3b8;
}

body {
    background-color: var(--cvf-bg);
    color: var(--cvf-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navbar */
.bg-cvf-dark { background-color: var(--cvf-dark) !important; }
.text-cvf-accent { color: var(--cvf-accent) !important; }
.bg-cvf-accent { background-color: var(--cvf-accent) !important; }
.bg-cvf-primary { background-color: var(--cvf-primary) !important; }

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: 0.02em;
}

/* Stat Cards */
.stat-card {
    background: var(--cvf-card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--cvf-dark);
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--cvf-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Jobs Table */
.table-jobs {
    font-size: 0.9rem;
}

.table-jobs thead th {
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: var(--cvf-text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem;
}

.table-jobs td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-jobs tbody tr {
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.table-jobs tbody tr:hover {
    background-color: #f0f7ff;
}

/* Status Badges */
.badge-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-queued { background: #f1f5f9; color: #64748b; }
.badge-extracting, .badge-extracted { background: #eff6ff; color: #3b82f6; }
.badge-formatting, .badge-formatted { background: #fefce8; color: #ca8a04; }
.badge-checking, .badge-checked { background: #faf5ff; color: #9333ea; }
.badge-verifying, .badge-verified { background: #fff7ed; color: #ea580c; }
.badge-generating { background: #ecfdf5; color: #16a34a; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-failed { background: #fef2f2; color: #dc2626; }

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cvf-dark) 0%, #0f172a 100%);
}

.login-card {
    background: var(--cvf-card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 420px;
    width: 100%;
    padding: 2.5rem;
}

.login-card .brand-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--cvf-dark);
}

.login-card .brand-subtitle {
    color: var(--cvf-text-muted);
    font-size: 0.9rem;
}

/* Upload Area */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    background: #fafbfc;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--cvf-primary);
    background: #eff6ff;
}

.upload-dropzone.dragover {
    border-style: solid;
    transform: scale(1.01);
}

.upload-dropzone .upload-icon {
    font-size: 3rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.upload-dropzone.dragover .upload-icon {
    color: var(--cvf-primary);
}

.upload-dropzone .upload-text {
    font-size: 1.1rem;
    color: var(--cvf-text);
    margin-bottom: 0.25rem;
}

.upload-dropzone .upload-hint {
    font-size: 0.85rem;
    color: var(--cvf-text-muted);
}

/* File Preview */
.file-preview {
    display: none;
    background: var(--cvf-card-bg);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}

.file-preview.visible {
    display: flex;
    align-items: center;
}

.file-preview .file-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

.file-preview .file-icon.pdf { color: #ef4444; }
.file-preview .file-icon.docx { color: #2563eb; }

/* Section Title */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cvf-dark);
    margin-bottom: 1.25rem;
}

/* Btn Primary Override */
.btn-cvf {
    background-color: var(--cvf-primary);
    border-color: var(--cvf-primary);
    color: #fff;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
}

.btn-cvf:hover {
    background-color: var(--cvf-primary-hover);
    border-color: var(--cvf-primary-hover);
    color: #fff;
}

.btn-cvf-lg {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

/* Quick Upload Button on Dashboard */
.quick-upload-card {
    background: linear-gradient(135deg, var(--cvf-primary) 0%, #1d4ed8 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    display: block;
    padding: 1.5rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quick-upload-card:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}

/* Alert Styles */
.alert-cvf {
    border-radius: 10px;
    border: none;
    font-size: 0.9rem;
}


/* ============================================
   Part 8B — Pipeline Status Page
   ============================================ */

.pipeline-tracker {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem 0;
    position: relative;
}

.pipeline-tracker::before {
    content: '';
    position: absolute;
    top: 2.75rem;
    left: 2rem;
    right: 2rem;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
}

.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    text-align: center;
}

.stage-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    border: 3px solid #e2e8f0;
    background: var(--cvf-card-bg);
    color: var(--cvf-text-muted);
    transition: all 0.3s ease;
}

.pipeline-stage.done .stage-dot {
    background: var(--cvf-success);
    border-color: var(--cvf-success);
    color: #fff;
}

.pipeline-stage.active .stage-dot {
    background: var(--cvf-primary);
    border-color: var(--cvf-primary);
    color: #fff;
    animation: stagePulse 1.5s ease-in-out infinite;
}

.pipeline-stage.failed .stage-dot {
    background: var(--cvf-danger);
    border-color: var(--cvf-danger);
    color: #fff;
}

@keyframes stagePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(37,99,235,0); }
}

.stage-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cvf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pipeline-stage.done .stage-label { color: var(--cvf-success); }
.pipeline-stage.active .stage-label { color: var(--cvf-primary); font-weight: 700; }
.pipeline-stage.failed .stage-label { color: var(--cvf-danger); }

.stage-time {
    font-size: 0.7rem;
    color: var(--cvf-text-muted);
    margin-top: 0.15rem;
}


/* ============================================
   Part 8B — Results Page
   ============================================ */

/* QC Download Buttons */
.btn-download-green {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border: none;
    color: #fff;
    padding: 1rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.2s ease;
}
.btn-download-green:hover {
    background: linear-gradient(135deg, #15803d, #166534);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(22,163,74,0.3);
}

.btn-download-yellow {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #fff;
    padding: 1rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.2s ease;
}
.btn-download-yellow:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(245,158,11,0.3);
}

.btn-download-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: #fff;
    padding: 1rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: not-allowed;
    opacity: 0.8;
}

/* QC Alert Boxes */
.qc-alert-green {
    background: #f0fdf4;
    border-left: 4px solid var(--cvf-success);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #166534;
}

.qc-alert-yellow {
    background: #fffbeb;
    border-left: 4px solid var(--cvf-warning);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #92400e;
}

.qc-alert-red {
    background: #fef2f2;
    border-left: 4px solid var(--cvf-danger);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #991b1b;
}

/* QC Score Badge */
.qc-score {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}
.qc-score.green { color: var(--cvf-success); }
.qc-score.yellow { color: var(--cvf-warning); }
.qc-score.red { color: var(--cvf-danger); }

/* Change Log Table */
.changelog-table {
    font-size: 0.85rem;
}

.changelog-table thead th {
    background: #f8fafc;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cvf-text-muted);
    padding: 0.6rem 0.75rem;
}

.changelog-table td {
    padding: 0.6rem 0.75rem;
    vertical-align: top;
}

.changelog-type {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    display: inline-block;
}

.changelog-type.CONTENT_FIX { background: #fef2f2; color: #dc2626; }
.changelog-type.SPELLING { background: #eff6ff; color: #2563eb; }
.changelog-type.PROPER_CASE { background: #faf5ff; color: #9333ea; }
.changelog-type.DATE_FORMAT { background: #fff7ed; color: #ea580c; }
.changelog-type.STRUCTURE { background: #fefce8; color: #ca8a04; }
.changelog-type.OTHER { background: #f1f5f9; color: #64748b; }

/* Side by Side View */
.side-by-side-panel {
    background: var(--cvf-card-bg);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.side-by-side-panel .panel-header {
    background: #f8fafc;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
    color: var(--cvf-dark);
}

.side-by-side-panel .panel-body {
    padding: 1rem;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* JSON Formatted View */
.json-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.json-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.json-section-heading {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--cvf-dark);
    margin-bottom: 0.4rem;
}


/* ============================================
   Part 8B — History Page
   ============================================ */

.filter-bar {
    background: var(--cvf-card-bg);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 1.25rem;
}

.filter-bar .form-control,
.filter-bar .form-select {
    border-radius: 8px;
    font-size: 0.9rem;
    border-color: #e2e8f0;
}

.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
    border-color: var(--cvf-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Pagination */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    font-size: 0.85rem;
    color: var(--cvf-primary);
    border-color: #e2e8f0;
}

.pagination .page-item.active .page-link {
    background: var(--cvf-primary);
    border-color: var(--cvf-primary);
}

/* Action buttons in table */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    border-radius: 6px;
    font-weight: 500;
}

/* Technical Details Compact */
.tech-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.tech-detail:last-child { border-bottom: none; }
.tech-detail .tech-label { color: var(--cvf-text-muted); font-weight: 500; }
.tech-detail .tech-value { font-weight: 600; color: var(--cvf-dark); }


/* ============================================
   Responsive tweaks
   ============================================ */

@media (max-width: 768px) {
    .stat-card .stat-value { font-size: 1.4rem; }
    .login-card { margin: 1rem; padding: 2rem; }
    main { padding: 1rem !important; }
    
    /* Stack pipeline stages on mobile */
    .pipeline-tracker {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .pipeline-tracker::before { display: none; }
    .pipeline-stage {
        flex-direction: row;
        text-align: left;
        gap: 0.75rem;
    }
    .stage-dot { margin-bottom: 0; }
    
    /* Stack side-by-side on mobile */
    .side-by-side-panel .panel-body {
        max-height: 300px;
    }
    
    .qc-score { font-size: 2rem; }
    .btn-download-green,
    .btn-download-yellow { 
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}
