/*
 * 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.
 */
/* ============================================
   GLOBAL LAYOUT & TYPOGRAPHY
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 0 20px 50px 20px;
}

h1, h2, h3, h4 {
    color: #2c3e50;
    margin-bottom: 0.5em;
}

h1 { font-size: 1.8em; }
h2 { font-size: 1.4em; border-bottom: 2px solid #e0e0e0; padding-bottom: 5px; }
h3 { font-size: 1.2em; }
h4 { font-size: 1.0em; margin: 1.2em 0 0.5em 0; }

ul {
    padding-left: 20px;
    line-height: 1.6;
}

li { margin-bottom: 5px; }

/* ============================================
   HEADER
   ============================================ */
.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px solid #007bff;
    margin-bottom: 20px;
}

/* ============================================
   DROP ZONE
   ============================================ */
.drop-zone {
    border: 2px dashed #007bff;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    background-color: #ffffff;
    transition: background-color 0.2s, border-color 0.2s;
}

.drop-zone.dragover {
    background-color: #e6f7ff;
    border-color: #0056b3;
}

.drop-zone p {
    margin: 0;
    font-size: 1.1em;
    color: #555;
}

.processing-status {
    display: none;
    background: #f0f7ff;
    border: 1px solid #cfe2ff;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 0 0 15px;
    font-size: 0.95em;
    color: #084298;
}
.processing-status.busy { border-color: #0d6efd; color: #052c65; }
.processing-status.done { border-color: #198754; color: #0f5132; background: #e8f5e9; }
.processing-status.error { border-color: #dc3545; color: #a71d2a; background: #f8d7da; }

/* ============================================
   PROCESS BUTTON
   ============================================ */
#process-btn {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    color: white;
    background-color: #28a745;
    border: none;
    border-radius: 5px;
    margin: 15px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

#process-btn:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

#process-btn:not(:disabled):hover {
    background-color: #218838;
}

/* ============================================
   FILE TABS
   ============================================ */
#file-selection-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin: 15px 0;
}

.file-tab-btn {
    padding: 8px 12px;
    font-size: 0.9em;
    font-weight: 500;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.file-tab-btn:hover {
    background-color: #e0e0e0;
}

.file-tab-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}

/* ============================================
   FILTER + EXPORT PANEL
   ============================================ */
#export-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

#export-controls.hidden { display: none; }

#export-controls h2 {
    grid-column: 1 / -1;
    margin: 0 0 10px 0;
    padding: 0;
    border: none;
}

#export-controls label {
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.9em;
}

#export-controls input[type="text"],
#export-controls select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
}

.button-group {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
}

.button-group button {
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
}

.button-primary {
    background-color: #007bff !important;
    color: white;
    border-color: #007bff;
}

.button-primary:hover {
    background-color: #0069d9 !important;
}

#suffix-quick-select {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

/* Quick suffix buttons */
.suffix-btn {
    padding: 8px 10px;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: #f7f7f7;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
}

.suffix-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* ============================================
   SPINNER
   ============================================ */
#spinner-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #007bff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   OUTPUT & SUMMARY
   ============================================ */
#output {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    min-height: 100px;
}

.program-container {
    margin-bottom: 30px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 20px;
}

.program-header {
    color: #007bff;
}

.tag-column-wrapper {
    column-count: 2;
    column-gap: 25px;
}

.summary-item {
    border-bottom: 1px solid #eee;
    padding: 5px 0;
    break-inside: avoid-column;
}

summary {
    cursor: pointer;
    font-size: 1.1em;
    padding: 5px 0;
}

summary strong:hover { color: #0056b3; text-decoration: underline; }

/* ============================================
   TAG LIST (CLEANED & CONSOLIDATED)
   ============================================ */
.tag-list {
    list-style-type: none;
    font-size: 0.9em;
    /* Responsive columns — follows window width */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 16px;
    column-count: unset;
}
.tag-list li {
    break-inside: avoid;
    margin-bottom: 4px;
    min-width: 0;
}

.tag-list a {
    display: inline-block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    color: inherit;
}

.tag-list a:hover {
    text-decoration: underline;
    color: #0056b3;
    white-space: normal;
    overflow: visible;
}

/* ============================================
   MEMBER LIST (CLEANED)
   ============================================ */
.member-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
}

.member-list-item {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background-color: #f9f9f9;
    font-size: 0.8em;
    position: relative;
    max-width: 22rem;
    line-height: 1.35;
}

.member-list-item:hover {
    background-color: #f0f0f0;
}

/* Always show member descriptions inline (hover tooltips were dark-on-dark / empty-looking). */
.member-description {
    display: block;
    position: static;
    transform: none;
    margin-top: 3px;
    padding: 0;
    background: transparent;
    color: #555;
    font-size: 0.92em;
    max-width: none;
    white-space: normal;
    line-height: 1.3;
}

/* ============================================
   BIT ARRAY TABLE
   ============================================ */
.view-bit-array-btn {
    font-size: 0.8em;
    padding: 2px 6px;
    margin-left: 10px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.bit-table-container {
    margin-top: 10px;
    overflow-x: auto;
}

.bit-array-table {
    border-collapse: collapse;
    margin-top: 5px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.9em;
}

.bit-array-table th,
.bit-array-table td {
    border: 1px solid #ccc;
    padding: 4px 6px;
    text-align: center;
}

.bit-array-table .bit-col {
    width: 2.2em;
    min-width: 2.2em;
}

.bit-array-table .bit-one {
    color: #d9534f;
    font-weight: bold;
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
#back-to-top {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 30px;
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 1em;
}

#back-to-top:hover {
    background-color: #0056b3;
}

/* ============================================
   UDT/AOI USAGE MODAL (CLEANED)
   ============================================ */
.usage-modal-backdrop {
    display: none;
    position: fixed;
    z-index: 1001;
    inset: 0;
    background-color: rgba(0,0,0,0.4);
    justify-content: center;
    align-items: center;
}

.usage-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.usage-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
}

.usage-modal-close {
    cursor: pointer;
    font-size: 28px;
    color: #aaa;
}

.usage-modal-close:hover {
    color: #000;
}

.usage-modal-controls {
    padding: 10px 0;
    display: flex;
    gap: 10px;
}

#usage-report-tree {
    flex-grow: 1;
    border: 1px solid #ccc;
    padding: 10px;
    overflow-y: auto;
    column-count: 2;
    column-gap: 15px;
}

#usage-report-tree li {
    break-inside: avoid-column;
    padding: 4px 0;
}

.usage-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #ccc;
    padding-top: 15px;
    margin-top: 20px;
}

.confirm-btn {
    background-color: #28a745;
    color: white;
}

.cancel-btn {
    background-color: #dc3545;
    color: white;
}

#usage-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.usage-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: 1px solid #cce2f5;
    border-radius: 8px;
    font-size: 0.75rem;
    background-color: #e9f3fc;
    min-width: 80px;
    line-height: 1.1;
	
}

.usage-summary-item:hover {
    background: #e0f0ff;
    border-color: #80bfff;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}

.usage-summary-item strong {
    font-size: 0.8rem;
    color: #003b7a;
	
}

.usage-summary-item .usage-type {
    font-size: 0.8rem;
    color: #2c5aa0;
}

.usage-summary-item .usage-count {
    font-size: 0.75rem;
    color: #144a7b;
    margin-top: 4px;
}


/* Highlight for initial values in pills and arrays */
.initial-value { color: #0b63ff; font-weight: 600; }
/* ============================================
   PATCH — Restore Blue Values + Smaller Tag Headers
   ============================================ */

/* 1. Make all values BLUE (REAL, DINT, BOOL, UDT members) */
.value-text,
.value-real,
.value-dint,
.value-number {
    color: #0b63ff !important;
    font-weight: 600 !important;
}

/* 2. Reduce tag header font size */
summary {
    font-size: 0.8em !important;
}
/* ============================================
   FIX: Force Value Text Blue + Shrink Inner Values
   ============================================ */

/* Make ALL array values BLUE */
ul li {
    color: #0b63ff !important;
    font-weight: 600 !important;
}

/* Shrink INNER values (REAL/DINT/UDT members) */
ul ul li {
    font-size: 0.8em !important;
}

/* Restore non-value items back to normal color */
summary,
strong {
    color: #333 !important;
    font-weight: normal !important;
}


/* ============================================
   FINAL PATCH — Shrink ALL Description Text (UDT + REAL/DINT)
   ============================================ */

/* UDT / tag member descriptions (inline under each pill) */
.member-description {
    font-size: 0.8em !important;
    color: #555 !important;
    font-weight: normal !important;
}

/* REAL/DINT array descriptions (inline comments) */
.array-description,
.inline-description,
li span.comment,
li span.array-description {
    font-size: 0.8em !important;
    color: #333 !important; /* keep descriptions dark */
}



/* ============================================
   UDT/AOI Usage Summary - Compact Pills (Fixed)
   ============================================ */

#usage-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    justify-content: flex-start;
}

/* Compact pills (Option A) */
.usage-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: 1px solid #cce2f5;
    border-radius: 8px;
    font-size: 0.75rem;
    background-color: #e9f3fc;
    min-width: 80px;
    line-height: 1.1;

    /* Prevent text overlap */
    white-space: normal;
    word-wrap: break-word;
}

.usage-summary-item strong,
.usage-summary-item .usage-type,
.usage-summary-item .usage-count {
    display: block;
    text-align: center;
}

/* Hover effect */
.usage-summary-item:hover {
    background: #e0f0ff;
    border-color: #80bfff;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
