/* OPC UA Browser Styles */

.opcua-tree {
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.tree-node {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
}

.tree-node-container {
    width: 100%;
}

.tree-children {
    display: block;
    width: 100%;
}

.tree-node:hover {
    background-color: #f5f5f5;
}

.tree-node.selected {
    background-color: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.tree-node.has-children {
    font-weight: 500;
}

.tree-node.variable {
    color: #1976d2;
}

.tree-node.variable::before {
    content: "📊 ";
    margin-right: 4px;
}

.tree-expand-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 4px;
    font-size: 12px;
    color: #666;
}

.tree-expand-icon.expanded::before {
    content: "▼";
}

.tree-expand-icon.collapsed::before {
    content: "▶";
}

.tree-expand-icon.loading::before {
    content: "⟳";
    animation: spin 1s linear infinite;
}

.tree-node-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-node-type {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

.tree-loading {
    color: #999;
    font-style: italic;
    padding: 12px;
    text-align: center;
}

.tree-error {
    color: #d32f2f;
    padding: 12px;
    text-align: center;
}

.realtime-panel-header {
    background-color: #f5f5f5;
    padding: 10px 16px;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.realtime-grid-container {
    width: 100%;
    height: 100%;
}

/* Quality status indicators */
.quality-good {
    color: #4caf50;
    font-weight: 600;
}

.quality-bad {
    color: #f44336;
    font-weight: 600;
}

.quality-uncertain {
    color: #ff9800;
    font-weight: 600;
}

/* Remove button in grid */
.remove-tag-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}

.remove-tag-btn:hover {
    background-color: #d32f2f;
}

.remove-tag-btn i {
    font-size: 14px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-message {
    font-size: 14px;
}

/* Value update animation */
.tag-value-cell {
    transition: background-color 0.3s ease;
}

.tag-value-cell.value-updated {
    background-color: #fff3cd;
    animation: valueFlash 0.5s ease;
}

@keyframes valueFlash {
    0% {
        background-color: #fff3cd;
    }
    50% {
        background-color: #ffc107;
    }
    100% {
        background-color: transparent;
    }
}

/* Center align ag-grid headers */
.ag-header-cell-center {
    text-align: center !important;
}

.ag-header-cell-center .ag-header-cell-label {
    justify-content: center !important;
}

/* Search input styles */
.tree-search-container {
    background: #fafafa;
}

.tree-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    height: 42px;
}

.tree-search-icon {
    position: absolute;
    left: 14px;
    color: #888;
    font-size: 16px;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
}

.tree-search-input {
    width: 100%;
    height: 42px;
    padding: 0 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.tree-search-input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.tree-search-input::placeholder {
    color: #aaa;
}

.tree-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 16px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.tree-search-clear:hover {
    background-color: #e0e0e0;
    color: #666;
}

/* Search match highlight */
.tree-node.search-match {
    background-color: #fff8e1;
}

.tree-node.search-match:hover {
    background-color: #ffecb3;
}

.search-highlight {
    background-color: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Variable node styling with search match */
.tree-node-label.variable {
    color: #1976d2;
}

/* =============================================
   Tag Groups Styles
   ============================================= */

/* Groups Toolbar */
.groups-toolbar {
    background-color: #fafafa;
    border-bottom: 1px solid #ddd;
    padding: 8px 12px;
}

.groups-toolbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.groups-label {
    font-weight: 500;
    color: #555;
    font-size: 13px;
    margin-right: 4px;
}

.groups-dropdown {
    flex: 1;
    min-width: 180px;
    max-width: 300px;
    height: 34px;
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
}

.groups-dropdown:focus {
    border-color: #1976d2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* Groups Buttons */
.groups-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    min-width: 110px;
}

.groups-btn i {
    font-size: 12px;
}

.groups-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.groups-btn-primary {
    background-color: #1976d2;
    color: white;
}

.groups-btn-primary:hover:not(:disabled) {
    background-color: #1565c0;
}

.groups-btn-success {
    background-color: #4caf50;
    color: white;
}

.groups-btn-success:hover:not(:disabled) {
    background-color: #43a047;
}

.groups-btn-secondary {
    background-color: #757575;
    color: white;
}

.groups-btn-secondary:hover:not(:disabled) {
    background-color: #616161;
}

.groups-btn-danger {
    background-color: #f44336;
    color: white;
}

.groups-btn-danger:hover:not(:disabled) {
    background-color: #e53935;
}

.groups-btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Modal Styles */
.groups-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.groups-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.groups-modal-content {
    position: relative;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.2s ease;
}

.groups-modal-large {
    max-width: 600px;
}

.groups-modal-xlarge {
    max-width: 900px;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.groups-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.groups-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.groups-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.groups-modal-close:hover {
    color: #333;
}

.groups-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.groups-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fafafa;
    border-radius: 0 0 8px 8px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group .required {
    color: #f44336;
}

.form-input {
    width: 100% !important;
    height: 46px !important;
    padding: 10px 12px !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

input[type="text"].form-input {
    height: 46px !important;
    padding: 10px 12px !important;
    line-height: normal !important;
}

.form-input:focus {
    border-color: #1976d2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

textarea.form-input {
    height: auto;
    resize: vertical;
    min-height: 80px;
}

.tag-count-badge {
    display: inline-block;
    background-color: #1976d2;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Groups List (Manage Modal) */
.groups-list {
    max-height: 400px;
    overflow-y: auto;
}

.groups-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    background-color: #fafafa;
    transition: background-color 0.2s;
}

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

.groups-list-item:last-child {
    margin-bottom: 0;
}

.groups-list-info {
    flex: 1;
    min-width: 0;
}

.groups-list-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.groups-list-meta {
    font-size: 12px;
    color: #777;
}

.groups-list-meta span {
    margin-right: 12px;
}

.groups-list-description {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

.groups-list-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 12px;
}

.groups-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.groups-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.groups-empty p {
    margin: 0;
    font-size: 14px;
}

/* Load Options */
.load-options {
    margin-top: 16px;
}

.load-option {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.load-option:hover {
    background-color: #f5f5f5;
}

.load-option:last-child {
    margin-bottom: 0;
}

.load-option input[type="radio"] {
    margin-top: 3px;
    margin-right: 12px;
    flex-shrink: 0;
}

.load-option-text {
    display: flex;
    flex-direction: column;
}

.load-option-text strong {
    color: #333;
    font-size: 14px;
}

.load-option-text small {
    color: #777;
    font-size: 12px;
    margin-top: 2px;
}

.load-option input[type="radio"]:checked + .load-option-text strong {
    color: #1976d2;
}

/* Loading state */
.groups-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

.groups-loading i {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

/* Display Name Tooltip */
.display-name-cell {
    cursor: default;
}

#display-name-tooltip {
    position: fixed;
    z-index: 9999;
    background-color: #e3f2fd;
    color: #1565c0;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #90caf9;
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
    pointer-events: none;
    display: none;
}

#display-name-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #90caf9;
}

#display-name-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #e3f2fd;
    margin-top: -1px;
    z-index: 1;
}

/* Tree Context Menu */
#tree-context-menu {
    position: fixed;
    z-index: 2000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    padding: 4px 0;
    display: none;
}

#tree-context-menu .ctx-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

#tree-context-menu .ctx-menu-item:hover {
    background-color: #f0f0f0;
}

#tree-context-menu .ctx-menu-item i {
    width: 16px;
    text-align: center;
    color: #666;
}

#tree-context-menu .ctx-menu-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

/* =============================================
   Predefined Groups Styles
   ============================================= */

/* Two-column layout for groups */
.groups-columns {
    display: flex;
    gap: 20px;
    min-height: 300px;
}

.groups-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.groups-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}

.groups-column-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.groups-column-header h4 i {
    color: #1976d2;
}

.predefined-column .groups-column-header h4 i {
    color: #ff9800;
}

.predefined-hint {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Predefined group item styling */
.predefined-group-item {
    background-color: #fff8e1;
    border-color: #ffe082;
}

.predefined-group-item:hover {
    background-color: #fff3cd;
}

.predefined-lock-icon {
    color: #ff9800;
    font-size: 12px;
    margin-right: 4px;
}

/* Clone button (info style) */
.groups-btn-info {
    background-color: #17a2b8;
    color: white;
}

.groups-btn-info:hover:not(:disabled) {
    background-color: #138496;
}

/* Toolbar separator */
.groups-separator {
    width: 1px;
    height: 28px;
    background-color: #ccc;
}

/* Predefined dropdown styling */
.predefined-label {
    color: #ff9800 !important;
}

.predefined-label i {
    margin-right: 4px;
}

.predefined-dropdown {
    border-color: #ffe082;
    background-color: #fffde7;
}

.predefined-dropdown:focus {
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.2);
}

/* Predefined view indicator */
.predefined-view-banner {
    background-color: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.predefined-view-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e65100;
    font-size: 13px;
    font-weight: 500;
}

.predefined-view-banner-text i {
    color: #ff9800;
}

.predefined-view-banner .btn-exit-predefined {
    background: none;
    border: 1px solid #ff9800;
    color: #ff9800;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.predefined-view-banner .btn-exit-predefined:hover {
    background-color: #ff9800;
    color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .groups-columns {
        flex-direction: column;
    }

    .groups-modal-xlarge {
        max-width: 95%;
    }
}
