/* ==========================================================================
   HỆ THỐNG KỸ THUẬT RƠ LE BẢO VỆ & TỰ ĐỘNG HÓA TRẠM BIẾN ÁP (P&C / SAS)
   Giao diện Sáng Chuẩn Kỹ Thuật Công Nghiệp (Light Engineering Theme)
   ========================================================================== */

:root {
    --bg-app: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-input: #ffffff;
    --border-subtle: #e2e8f0;
    --border-default: #cbd5e1;
    --border-active: #0284c7;
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --accent-blue: #0284c7;
    --accent-emerald: #059669;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    --accent-purple: #6d28d9;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Be Vietnam Pro', 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.font-mono-tech, .font-mono {
    font-family: 'Be Vietnam Pro', 'Segoe UI', 'Inter', Roboto, Arial, sans-serif !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.005em;
}

svg text {
    font-family: 'Be Vietnam Pro', 'Segoe UI', 'Inter', Roboto, Arial, sans-serif !important;
    font-variant-numeric: tabular-nums;
}

/* Custom Clean Scrollbars */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tree Sidebar Navigation */
.tree-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    font-size: 0.76rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    border-radius: 0.45rem;
    transition: all 0.15s ease;
    user-select: none;
}

.tree-group-header:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.tree-sublist {
    margin-left: 0.85rem;
    padding-left: 0.65rem;
    border-left: 2px solid #e2e8f0;
    margin-top: 0.15rem;
    margin-bottom: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.tree-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.45rem;
    font-size: 0.83rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    user-select: none;
}

.tree-link:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.tree-link.active {
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
    border-color: #bae6fd;
}

/* Panels & Cards */
.scada-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.scada-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 0.6rem;
    transition: all 0.18s ease;
}

.scada-card:hover {
    border-color: #7dd3fc;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}

/* Status Indicators */
.led-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.led-normal {
    background-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.led-amber {
    background-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}
.led-trip {
    background-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* File Dropzone */
.dropzone-area {
    border: 2px dashed #94a3b8;
    background: #f8fafc;
    border-radius: 0.65rem;
    transition: all 0.2s ease;
    cursor: pointer;
}
.dropzone-area:hover,
.dropzone-area.drag-over {
    border-color: #0284c7;
    background: #f0f9ff;
}

/* Technical Data Tables */
.tech-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.tech-table th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 10;
    text-align: left;
}
.tech-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.tech-table tbody tr:hover {
    background-color: #f8fafc;
}
.tech-table tbody tr.selected-row {
    background-color: #e0f2fe;
}

/* ===================================================================
   CHỐNG CHE KHUẤT SỐ & TỐI ƯU Ô NHẬP LIỆU BẢNG KỸ THUẬT SCADA
   =================================================================== */
.tech-table th {
    white-space: nowrap;
}
.tech-table td {
    white-space: nowrap;
}
.tech-table .tech-input {
    padding: 0.28rem 0.35rem !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
    font-size: 0.82rem !important;
    text-align: center;
    box-sizing: border-box;
    flex-shrink: 0 !important;
    min-width: 60px;
}

/* Ẩn triệt để spinner up/down của trình duyệt trên toàn bộ ứng dụng */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button,
.tech-table input[type=number]::-webkit-inner-spin-button,
.tech-table input[type=number]::-webkit-outer-spin-button,
#setting-sim-panel input[type=number]::-webkit-inner-spin-button,
#setting-sim-panel input[type=number]::-webkit-outer-spin-button,
.scada-panel input[type=number]::-webkit-inner-spin-button,
.scada-panel input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    display: none !important;
    margin: 0 !important;
    width: 0 !important;
    height: 0 !important;
}
input[type=number],
.tech-table input[type=number],
#setting-sim-panel input[type=number],
.scada-panel input[type=number] {
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

/* Inputs & Selects */
.tech-input, .tech-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-default);
    color: var(--text-main);
    border-radius: 0.42rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.83rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tech-input:focus, .tech-select:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Buttons */
.btn-scada {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.48rem 0.95rem;
    border-radius: 0.45rem;
    font-weight: 600;
    font-size: 0.81rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    user-select: none;
}
.btn-scada-primary {
    background-color: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}
.btn-scada-primary:hover {
    background-color: #0369a1;
}
.btn-scada-emerald {
    background-color: #059669;
    color: #ffffff;
    border-color: #047857;
}
.btn-scada-emerald:hover {
    background-color: #047857;
}
.btn-scada-amber {
    background-color: #d97706;
    color: #ffffff;
    border-color: #b45309;
}
.btn-scada-amber:hover {
    background-color: #b45309;
}
.btn-scada-rose {
    background-color: #e11d48;
    color: #ffffff;
    border-color: #be123c;
}
.btn-scada-rose:hover {
    background-color: #be123c;
}
.btn-scada-purple {
    background-color: #6d28d9;
    color: #ffffff;
    border-color: #5b21b6;
}
.btn-scada-purple:hover {
    background-color: #5b21b6;
}
.btn-scada-outline {
    background-color: #ffffff;
    color: #334155;
    border-color: #cbd5e1;
}
.btn-scada-outline:hover {
    background-color: #f8fafc;
    color: #0284c7;
    border-color: #0284c7;
}

/* ANSI Badges */
.ansi-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.8rem;
    padding: 0.18rem 0.55rem;
    border-radius: 0.35rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.79rem;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}
.ansi-badge.diff {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.ansi-badge.dist {
    background: #f3e8ff;
    color: #6d28d9;
    border-color: #d8b4fe;
}
.ansi-badge.volt {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}
.ansi-badge.ctrl {
    background: #d1fae5;
    color: #047857;
    border-color: #6ee7b7;
}

/* Plot Container & Fullscreen Wrapper */
.plot-container {
    width: 100%;
    min-height: 480px;
    background-color: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 0.6rem;
    position: relative;
}

.fullscreen-panel-active {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9000 !important;
    background-color: #ffffff !important;
    padding: 1.25rem !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
}

.fullscreen-panel-active .plot-container {
    flex: 1 1 auto !important;
    min-height: calc(100vh - 110px) !important;
    height: calc(100vh - 110px) !important;
}

/* Graphical Engineering Diagram Box */
.diagram-canvas-box {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    border: 1px solid #cbd5e1;
    border-radius: 0.65rem;
    padding: 1rem;
    overflow-x: auto;
}

/* Range Slider */
input[type="range"].time-cursor-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
}
input[type="range"].time-cursor-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0284c7;
    border: 2px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(2, 132, 199, 0.5);
}

/* Page Transitions */
.view-page {
    display: none;
    animation: fadeInPage 0.16s ease-out;
}
.view-page.active {
    display: block;
}
@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Toast Notification */
#toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.scada-toast {
    background-color: #ffffff;
    border-left: 4px solid #0284c7;
    border-top: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
    color: #0f172a;
    padding: 0.75rem 1rem;
    border-radius: 0.45rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 280px;
    max-width: 440px;
}

/* ============================================================================
   AI ENGINEERING REPORT & TYPOGRAPHY ENHANCEMENTS (PHẦN 3 & PHẦN 4)
   ============================================================================ */
.ai-report-content {
    font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.ai-report-content *:not(i):not([class*="fa-"]):not(svg):not(path) {
    font-family: inherit;
}

/* AI Report SVG Icons - Bulletproof Strict Sizing */
.ai-report-content svg {
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    box-sizing: content-box !important;
}

.ai-report-content .ai-icon-badge {
    width: 11px !important;
    height: 11px !important;
    min-width: 11px !important;
    min-height: 11px !important;
    max-width: 11px !important;
    max-height: 11px !important;
}

.ai-report-content .ai-icon-sm {
    width: 13px !important;
    height: 13px !important;
    min-width: 13px !important;
    min-height: 13px !important;
    max-width: 13px !important;
    max-height: 13px !important;
}

.ai-report-content .ai-icon-md {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
}

.ai-report-content .ai-icon-lg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
}

.ai-report-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    border: 1px solid #cbd5e1 !important;
    background: #ffffff !important;
    color: #475569 !important;
    transition: all 0.15s ease !important;
    user-select: none !important;
    text-decoration: none !important;
}

.ai-report-btn:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

.ai-report-btn-purple {
    border-color: #e9d5ff !important;
    background: #faf5ff !important;
    color: #7e22ce !important;
    font-weight: 600 !important;
}

.ai-report-btn-purple:hover {
    background: #f3e8ff !important;
    color: #581c87 !important;
    border-color: #d8b4fe !important;
}

.ai-report-content code,
.ai-report-content pre code {
    font-family: 'Be Vietnam Pro', 'Segoe UI', Consolas, monospace !important;
}

.ai-report-h1 {
    font-size: 0.9375rem;
    font-weight: 800;
    color: #0f172a;
    padding: 0.45rem 0.75rem;
    background: linear-gradient(90deg, #f1f5f9, #ffffff);
    border-left: 4px solid #7c3aed;
    border-radius: 0.25rem;
    margin-top: 0.85rem;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* AI Engineering Report Accordion (Gấp mở 5 phần chuẩn hóa) */
.ai-report-accordion-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-report-accordion-item details[open] > summary .ai-accordion-arrow,
details[open] > summary .ai-accordion-arrow {
    transform: rotate(180deg);
}
details[open] > summary .ai-status-collapsed {
    display: none !important;
}
details:not([open]) > summary .ai-status-expanded {
    display: none !important;
}
details[open] > summary {
    border-bottom-color: #e2e8f0 !important;
}

.ai-report-accordion-header::-webkit-details-marker,
.ai-report-accordion-header::marker {
    display: none !important;
    content: "" !important;
}

.ai-report-accordion-header {
    list-style: none !important;
}

.ai-report-accordion-header:hover {
    background: linear-gradient(90deg, #f8fafc, #f1f5f9) !important;
}

.ai-report-h2 {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.35rem;
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-report-h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #475569;
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ai-report-table-wrap {
    overflow-x: auto;
    margin: 0.65rem 0;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: #ffffff;
}

.ai-report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    text-align: left;
}

.ai-report-table th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid #cbd5e1;
    border-right: 1px solid #e2e8f0;
    white-space: nowrap;
}

.ai-report-table th:last-child {
    border-right: none;
}

.ai-report-table td {
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f1f5f9;
    color: #1e293b;
}

.ai-report-table td:last-child {
    border-right: none;
}

.ai-report-table tr:nth-child(even) td {
    background-color: #f8fafc;
}

.ai-report-table tr:hover td {
    background-color: #f1f5f9;
}

.ai-callout-info {
    background-color: #f0fdf4;
    border-left: 3px solid #22c55e;
    color: #15803d;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    margin: 0.45rem 0;
    font-size: 0.75rem;
    line-height: 1.55;
}

.ai-callout-warn {
    background-color: #fffbeb;
    border-left: 3px solid #f59e0b;
    color: #b45309;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    margin: 0.45rem 0;
    font-size: 0.75rem;
    line-height: 1.55;
}

.ai-callout-danger {
    background-color: #fef2f2;
    border-left: 3px solid #ef4444;
    color: #b91c1c;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    margin: 0.45rem 0;
    font-size: 0.75rem;
    line-height: 1.55;
}

/* Multi-Relay Cards in Section 4 */
.setting-relay-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}
.setting-relay-card:hover {
    border-color: #a855f7;
    background-color: #faf5ff/40;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.1);
    transform: translateY(-1px);
}
.setting-relay-card.active {
    background: #faf5ff;
    border-color: #7c3aed;
    box-shadow: 0 0 0 1.5px #7c3aed, 0 4px 14px rgba(124, 58, 237, 0.15);
}

/* ============================================================================
   WAVEWIN STUDIO COLLAPSIBLE MEASUREMENT SIDEBAR & ALIGNMENT
   ============================================================================ */
.hide-wavewin-measurement #wavewin-measurement-sidebar {
    display: none !important;
}

.hide-wavewin-measurement .wavewin-measurement-col {
    display: none !important;
}

/* Đồng bộ hoàn hảo chiều cao và mép trên của 2 thanh Header biểu đồ */
.wavewin-studio-header {
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    box-sizing: border-box !important;
}

.self-start {
    align-self: flex-start !important;
}

.sticky-phasor {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 8px !important;
    z-index: 10;
}

@media (min-width: 1280px) {
    .xl\:col-span-12 {
        grid-column: span 12 / span 12 !important;
    }
    .xl\:col-span-9 {
        grid-column: span 9 / span 9 !important;
    }
    .xl\:col-span-3 {
        grid-column: span 3 / span 3 !important;
    }
}
