/*
 * 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 (matches ACE suite)
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 0 20px 60px 20px;
}

h1 { font-size: 1.8em; color: #2c3e50; }

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

.home-link {
    display: inline-block;
    padding: 8px 16px;
    background: #0056b3;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
}

.page-intro {
    color: #555;
    max-width: 900px;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

/* ============================================
   DROP ZONE (fallback)
   ============================================ */
.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;
    margin-bottom: 15px;
}
.drop-zone.dragover { background-color: #e6f7ff; border-color: #0056b3; }
.drop-zone p { margin: 0; font-size: 1.1em; color: #555; }

#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;
}
#process-btn:hover { background-color: #218838; }
.hidden { display: none !important; }

/* ============================================
   STATUS / PROGRESS
   ============================================ */
.index-status {
    display: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 15px;
    font-size: 0.95em;
    color: #444;
}
.index-status.busy { border-color: #007bff; color: #0056b3; }
.index-status .progress-bar-track {
    width: 100%;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}
.index-status .progress-bar-fill {
    height: 100%;
    background: #007bff;
    width: 0%;
    transition: width 0.2s ease;
}
.index-status.error { border-color: #dc3545; color: #a71d2a; }

/* ============================================
   SEARCH & FILTER PANEL
   ============================================ */
.search-panel {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

#search-input {
    flex: 1;
    padding: 12px 14px;
    font-size: 1.1em;
    border: 1px solid #ccc;
    border-radius: 6px;
}
#search-input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.15); }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 18px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    font-size: 0.85em;
}
.filter-field label { font-weight: 500; margin-bottom: 4px; color: #444; }
.filter-field select {
    padding: 7px 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.95em;
    min-width: 150px;
}
.filter-checkbox label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin-bottom: 0; padding-bottom: 7px; }
.filter-checkbox input { width: 16px; height: 16px; }

.filter-actions { margin-left: auto; display: flex; gap: 8px; }

.btn-secondary {
    padding: 8px 14px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-secondary:hover { background: #e2e2e2; }

.btn-primary {
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid #007bff;
    background: #007bff;
    color: #fff;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
}
.btn-primary:hover { background: #0069d9; }

/* ============================================
   RESULTS
   ============================================ */
.results-count {
    color: #666;
    font-size: 0.9em;
    margin: 6px 2px 12px 2px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.placeholder-tile {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 40px 20px;
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 10px;
    font-size: 1.05em;
}

/* ============================================
   TAG TILE
   ============================================ */
.tag-tile {
    background: #fff;
    border: 1px solid #ddd;
    border-left: 4px solid #007bff;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.tag-tile[data-kind="udt"] { border-left-color: #17a2b8; }
.tag-tile[data-kind="aoi"] { border-left-color: #6f42c1; }
.tag-tile[data-kind="atomic"] { border-left-color: #999; }

.tile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.tile-name {
    font-weight: 700;
    font-size: 1.02em;
    color: #2c3e50;
    word-break: break-word;
}

.tile-badge {
    flex-shrink: 0;
    font-size: 0.72em;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    background: #eee;
    color: #555;
}
.badge-udt { background: #e6f8fb; color: #0f7285; }
.badge-aoi { background: #f0eaf9; color: #5a32a3; }
.badge-atomic { background: #f0f0f0; color: #666; }

.tile-meta {
    font-size: 0.78em;
    color: #888;
}

.tile-desc {
    font-size: 0.88em;
    color: #444;
    line-height: 1.35;
}
.tile-desc-empty { color: #aaa; font-style: italic; }

.tile-row {
    font-size: 0.82em;
    color: #333;
    background: #f7f9fb;
    border-radius: 5px;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.tile-scaling { background: #fff8e6; }
.tile-io {
    background: #eef6ff;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
}
.io-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 0.82em;
    line-height: 1.35;
}
.io-badges {
    margin-left: auto;
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}
.io-source-badge {
    display: inline-block;
    font-size: 0.68em;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: #dbe9f7;
    color: #1e5b98;
    white-space: nowrap;
}
.io-raw-count {
    font-size: 0.7em;
    color: #666;
    background: #e8eef4;
    border-radius: 6px;
    padding: 0 6px;
    cursor: help;
}
.io-type-badge {
    display: inline-block;
    font-size: 0.7em;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: #cfe2ff;
    color: #084298;
    margin-right: 4px;
}
.io-type-O { background: #f8d7da; color: #842029; }
.io-type-I { background: #d1e7dd; color: #0f5132; }
.io-type-C { background: #fff3cd; color: #664d03; }
.io-hidden-note {
    font-size: 0.72em;
    color: #777;
    padding: 4px 2px 0 2px;
    font-style: italic;
}
.io-hidden-note em { font-style: normal; font-weight: 600; color: #555; }
.badge-src-alias   { background: #d1e7dd; color: #0f5132; }
.badge-src-mov     { background: #fdd9b5; color: #7a4207; }
.badge-src-bit     { background: #f8d7da; color: #842029; }
.badge-src-aoi     { background: #e2d9f3; color: #4b2d92; }
.badge-src-st      { background: #d1ecf1; color: #0c5460; }
.badge-src-generic { background: #e5e5e5; color: #555; }
.tile-icon { font-size: 0.95em; }
.tile-subtle { color: #888; font-size: 0.92em; }

.subtag-toggle {
    align-self: flex-start;
    margin-top: 2px;
    background: none;
    border: none;
    color: #0056b3;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
}
.subtag-toggle:hover { text-decoration: underline; }
.subtag-toggle.open .toggle-arrow { transform: rotate(90deg); }
.toggle-arrow { display: inline-block; transition: transform 0.15s ease; }

.subtag-list {
    border-top: 1px solid #eee;
    padding-top: 6px;
    margin-top: 2px;
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.subtag-row {
    font-size: 0.78em;
    display: grid;
    grid-template-columns: minmax(80px, auto) minmax(50px, auto) minmax(0, 1fr);
    gap: 8px;
    padding: 3px 4px;
    border-radius: 4px;
    align-items: baseline;
}
.subtag-row:nth-child(odd) { background: #fafafa; }
.subtag-row.subtag-match { background: #fff3cd; }
.subtag-name { font-weight: 600; color: #2c3e50; word-break: break-word; }
.subtag-type { color: #888; font-family: "Consolas", "Courier New", monospace; }
.subtag-desc { color: #555; grid-column: 1 / -1; margin-top: -2px; }
.subtag-value { color: #0b63ff; font-weight: 600; grid-column: 1 / -1; margin-top: -2px; }

.tile-footer {
    margin-top: 4px;
    font-size: 0.7em;
    color: #aaa;
    border-top: 1px solid #f0f0f0;
    padding-top: 5px;
}

mark {
    background: #fff3a0;
    padding: 0 1px;
    border-radius: 2px;
}

.load-more-wrap { text-align: center; margin: 24px 0; }

#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; }
