/*
 * ACE (Automation Control Engineering) Suite
 * Copyright (c) 2026 ACE Systems. All rights reserved.
 * Property of ACE Systems - Whakatane, Bay of Plenty, New Zealand.
 *
 * Proprietary and confidential. Unauthorised copying, distribution or
 * modification of this file, in whole or in part, is prohibited.
 */
/* ============================================
   PCS CPU REPORT — styling
   ACE palette (dark blue header, blue accent); purple accents mark
   Online Snapshot data (same convention as the FD Tool's snapshot block).
   ============================================ */
:root {
    --header-bg: linear-gradient(135deg, #2c3e50 0%, #4a6491 100%);
    --main-bg: #eaf2fa;
    --border-color: #ddd;
    --text-dark: #333;
    --text-light: #555;
    --primary-accent: #0056b3;
    --primary-btn: #3498db;
    --secondary-btn: #6c757d;
    --snap-accent: #7a3ea3;
    --snap-bg: #f5edfa;
    --snap-border: #e6d9f0;
    --hi-bg: #f8d7da;  --hi-txt: #842029;
    --mid-bg: #fff3cd; --mid-txt: #664d03;
    --lo-bg: #d1e7dd;  --lo-txt: #0f5132;
}

body, html {
    height: 100%; margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-dark);
    display: flex; flex-direction: column;
}
.header {
    flex-shrink: 0; display: flex; justify-content: space-between; align-items: center;
    background: var(--header-bg); color: white; padding: 12px 30px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.header h1 { margin: 0; font-size: 1.5em; font-weight: 600; }
.header a {
    padding: 8px 16px; border-radius: 5px; font-weight: 500; cursor: pointer;
    color: white; text-decoration: none; display: inline-block; border: none;
    font-size: 0.9em; background-color: var(--secondary-btn);
    transition: background-color 0.2s ease;
}
.header a:hover { background-color: #5a6268; }

.main-container {
    flex-grow: 1; overflow-y: auto; padding: 30px;
    max-width: 96%; margin: 0 auto; width: 100%; box-sizing: border-box;
}
.content-section {
    background: white; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 30px; margin-bottom: 30px;
}
h2 {
    border-bottom: 2px solid var(--primary-accent); padding-bottom: 10px;
    margin-top: 0; font-size: 1.4rem;
}
.page-intro { color: #666; line-height: 1.5; max-width: 1100px; }
.page-intro code { background: #eef1f4; padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }

/* ---- Status ---- */
.processing-status {
    background: #fff; border: 1px solid #ddd; border-radius: 8px;
    padding: 12px 16px; margin: 12px 0 18px 0; font-size: 0.95em; color: #444;
}
.processing-status.busy  { border-color: #007bff; color: #0056b3; }
.processing-status.error { border-color: #dc3545; color: #a71d2a; }
.processing-status.done  { border-color: #198754; color: #0f5132; }
.processing-status .progress-bar-track {
    width: 100%; height: 6px; background: #eee; border-radius: 3px;
    margin-top: 8px; overflow: hidden;
}
.processing-status .progress-bar-fill {
    height: 100%; background: #007bff; width: 0%; transition: width 0.15s ease;
}

/* ---- Controls ---- */
.controls {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 18px; padding: 16px;
    background-color: #f8f9fa; border-radius: 8px; border: 1px solid var(--border-color);
}
.control-group { display: flex; flex-direction: column; }
.control-group label { font-weight: 600; margin-bottom: 6px; color: var(--text-light); font-size: 0.88em; }
.control-group input[type="text"], .control-group select {
    padding: 8px 10px; font-size: 0.95em; border: 1px solid var(--border-color);
    border-radius: 5px; box-sizing: border-box;
}
.control-actions { flex-direction: row; align-items: flex-end; gap: 8px; }
.btn-primary, .btn-secondary {
    padding: 9px 16px; border-radius: 5px; cursor: pointer;
    font-size: 0.95em; font-weight: 500; border: 1px solid transparent;
}
.btn-primary { background: var(--primary-btn); color: white; }
.btn-primary:hover { background: #217bbe; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }

/* ---- Summary tiles ---- */
.summary-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px; margin: 6px 0 20px 0;
}
.summary-tile {
    background: linear-gradient(135deg, #f0f7ff 0%, #dfeeff 100%);
    border: 1px solid #cfe2ff; border-radius: 8px;
    padding: 14px 18px; display: flex; flex-direction: column; gap: 4px;
}
.summary-tile.snap { background: linear-gradient(135deg, #f8f2fc 0%, #efe3f8 100%); border-color: var(--snap-border); }
.summary-tile .st-label { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.04em; color: #446; }
.summary-tile.snap .st-label { color: #5a3a72; }
.summary-tile .st-value { font-size: 1.5em; font-weight: 700; color: var(--primary-accent); }
.summary-tile.snap .st-value { color: var(--snap-accent); }
.summary-tile .st-sub { font-size: 0.78em; color: #555; }

#status-bar { color: #666; font-size: 0.9em; margin: 4px 2px 12px 2px; }

/* ---- Fleet table ---- */
#report-container { overflow-x: auto; }
.fleet-table {
    width: 100%; border-collapse: collapse; font-size: 0.87em; background: white;
}
.fleet-table th, .fleet-table td {
    border: 1px solid #d8d8d8; padding: 6px 10px; text-align: left;
    vertical-align: middle; white-space: nowrap;
}
.fleet-table th {
    background: #f0f0f0; color: #222; font-weight: 700;
    position: sticky; top: 0; z-index: 1;
    cursor: pointer; user-select: none;
}
.fleet-table th.snap-col { background: var(--snap-bg); color: #5a3a72; }
.fleet-table th.sortable::after { content: '\2195'; margin-left: 4px; color: #999; font-weight: normal; font-size: 0.85em; }
.fleet-table th.sorted-asc::after  { content: '\25B2'; color: #333; }
.fleet-table th.sorted-desc::after { content: '\25BC'; color: #333; }
.fleet-table tbody tr.data-row:nth-child(4n+1) { background: #f8fbff; }
.fleet-table tbody tr.data-row:hover { background: #e8f2fd; cursor: pointer; }
.fleet-table td.name { font-family: 'Consolas','Courier New',monospace; font-weight: 700; color: #114; }
.fleet-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.fleet-table td.center { text-align: center; }
.fleet-table td.subtle, .fleet-table .subtle { color: #888; font-size: 0.9em; }

.util-cell {
    display: inline-block; min-width: 52px; text-align: center;
    padding: 2px 8px; border-radius: 4px; font-weight: 700;
}
.util-cell.hi  { background: var(--hi-bg);  color: var(--hi-txt); }
.util-cell.mid { background: var(--mid-bg); color: var(--mid-txt); }
.util-cell.lo  { background: var(--lo-bg);  color: var(--lo-txt); }
.util-cell.unk { background: #ececec; color: #777; font-weight: 500; }

.std-chip {
    display: inline-block; font-size: 0.78em; font-weight: 700;
    padding: 2px 8px; border-radius: 10px;
}
.std-chip.s88 { background: #d1e7dd; color: #0f5132; }
.std-chip.v4  { background: #cfe2ff; color: #084298; }
.std-chip.mix { background: #fff3cd; color: #664d03; }
.std-chip.oem { background: #ececec; color: #555; }

.enc-chip {
    display: inline-block; font-size: 0.78em; font-weight: 600;
    padding: 2px 8px; border-radius: 10px;
}
.enc-chip.clean   { background: #d1e7dd; color: #0f5132; }
.enc-chip.partial { background: #fff3cd; color: #664d03; }
.enc-chip.full    { background: #f8d7da; color: #842029; }

.snap-chip {
    display: inline-block; font-size: 0.76em; font-weight: 700;
    background: var(--snap-bg); color: var(--snap-accent);
    border: 1px solid var(--snap-border); border-radius: 10px; padding: 1px 8px;
}
.snap-chip.none { background: #ececec; color: #888; border-color: #ddd; }

/* ---- Expanded detail row ---- */
.fleet-table tr.detail-row { display: none; }
.fleet-table tr.detail-row.open { display: table-row; }
.fleet-table tr.detail-row > td {
    background: #fbf9fd; padding: 14px 18px; white-space: normal;
    border-top: 2px solid var(--snap-border);
}
.detail-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 18px; align-items: start;
}
/* Contain each sub-table within its own grid cell so wide tables (Task
   Configuration, Memory Detail) scroll internally instead of overflowing
   and overlapping the neighbouring block. min-width:0 lets the grid track
   shrink below the table's intrinsic width so overflow-x can engage. */
.detail-block { min-width: 0; overflow-x: auto; }
.detail-block h4 {
    margin: 0 0 6px 0; font-size: 0.92em; color: var(--snap-accent);
    border-bottom: 1px solid var(--snap-border); padding-bottom: 3px;
}
.detail-block h4.static { color: var(--primary-accent); border-bottom-color: #cfe2ff; }
.detail-block table {
    width: 100%; border-collapse: collapse; font-size: 0.85em;
}
.detail-block th, .detail-block td {
    border: 1px solid #e2e2e2; padding: 3px 8px; text-align: left;
}
.detail-block th { background: #f4f4f4; font-weight: 700; }
.detail-block td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-block .bar-cell { width: 42%; }
.cpu-bar {
    height: 9px; border-radius: 3px; min-width: 2px;
    background: linear-gradient(90deg, #7a3ea3 0%, #a877cb 100%);
}
.detail-block .mem-pct { color: #888; font-size: 0.88em; }
.detail-block .total-row { background: #f0e6ff; }
.task-inhibited { color: #842029; font-weight: 700; }
.task-active { color: #0f5132; font-weight: 600; }

.no-data {
    text-align: center; font-size: 1em; color: var(--text-light);
    padding: 30px; background: #f8f9fa; border-radius: 6px; border: 1px dashed #ccc;
}
