/* ===== CSS VARIABLES (THEME) - Same as before ===== */
:root {
    --bg-darkest: #1a1a1a;
    --bg-dark: #2a2a2a;
    --bg-light: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --text-disabled: #5f5e5e;
    --accent-primary: #007bff;
    --accent-hover: #0056b3;
    
    --status-online: #2ecc71; /* Green */
    --status-standby: #f39c12; /* Orange */
    --status-offline: #e74c3c; /* Red */
    --status-ok: var(--text-primary);
    
    --border-color: #444;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================
   Modern Minimalist Scrollbars
   ========================================== */

/* 1. Standard Property (Firefox) */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb, rgba(255, 255, 255, 0.18)) transparent;
}

/* 2. WebKit / Chromium / Tauri / Electron */
::-webkit-scrollbar {
    width: 8px;  /* Width for vertical scrollbars */
    height: 8px; /* Height for horizontal scrollbars */
}

/* Scrollbar Track (The background) */
::-webkit-scrollbar-track {
    background: transparent;
}

/* Scrollbar Thumb (The draggable pill) */
::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb, rgba(255, 255, 255, 0.15));
    border-radius: 9999px; /* Pill shape */
    transition: background-color 0.2s ease;
}

/* Hover effect on thumb */
::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover, rgba(255, 255, 255, 0.3));
}

/* Active / Dragging state */
::-webkit-scrollbar-thumb:active {
    background-color: var(--scrollbar-thumb-active, rgba(255, 255, 255, 0.45));
}

/* Optional: Hide scrollbar buttons (arrows) if browsers render them */
::-webkit-scrollbar-button {
    display: none;
}

.admin-only {
    display: none !important;
}

/* ===== GLOBAL & SIDEBAR (Same as before) ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    font-family: var(--font-family);
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    font-size: 15px; /* Slightly smaller for density */
    line-height: 1.5;
}
.app-container { 
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.sidebar {
    width: 240px;
    height: 100vh;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
    position: static;
}
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border-color); }
.sidebar-header h3 {
    float: left;
    font-size: 1.25rem;
}
.sidebar-header i {
    float: right;
    margin-top: 5px;
    font-size: 1.25rem;
    color: var(--text-disabled);
    cursor: pointer;
    transition: color 0.2s ease;
}
.sidebar-header i:hover {
    color: var(--text-primary);
}
.nav-list { list-style: none; flex-grow: 1; padding-top: 1rem; display: flex; flex-direction: column; }
.nav-bottom { margin-top: auto; }
.nav-item { display: flex; align-items: center; padding: 0.9rem 1.5rem; color: var(--text-secondary); cursor: pointer; font-weight: 500; border-left: 4px solid transparent; transition: all 0.2s ease; }
.nav-item i { font-size: 1.4rem; margin-right: 1rem; }
.nav-item:hover { background-color: var(--bg-light); color: var(--text-primary); }
.nav-item.active { color: var(--text-primary); background-color: var(--bg-darkest); border-left-color: var(--accent-primary); }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border-color); }
.server-status { display: flex; align-items: center; font-size: 0.9rem; }

/* ===== STATUS DOT - Renamed ===== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0; /* Prevents dot from shrinking */
}
.status-dot.online { background-color: var(--status-online); }
.status-dot.standby { background-color: var(--status-standby); }
.status-dot.offline { background-color: var(--status-offline); }
.status-dot.ok { background-color: var(--text-secondary); }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
}
.page { display: none; }
.page.active { display: block; }
h1 { font-size: 2rem; margin-bottom: 1.5rem; }

/* ===== NEW: DASHBOARD CONTROLS (Search) ===== */
.dashboard-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dashboard-controls input[type="search"] {
    flex-grow: 1;
    padding: 0.7rem 1rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1rem;
}
.dashboard-controls input[type="search"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ===== SHARED TABLE BASE ===== */
.table-container {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 0.9rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table thead {
    background-color: var(--bg-light);
}
.data-table th {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:hover {
    background-color: var(--bg-light);
}

/* ===== NEW: Table Cell Styles ===== */
.device-info {
    display: flex;
    flex-direction: column;
}
.device-info .device-name {
    font-weight: 500;
    color: var(--text-primary);
}
.device-info .device-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'Courier New', Courier, monospace;
}
.standby-control {
    display: flex;
    align-items: center;
    gap: 10px;
}
.device-table-dense td i.ph-fill {
    font-size: 1.25rem;
}
.status-online { color: var(--status-online); }
.status-offline { color: var(--status-offline); }

.power-channel-tag {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 1s, border 1s;
}
.power-channel-tag.unmanaged {
    background-color: transparent;
    border-color: var(--bg-light);
    color: var(--text-secondary);
    font-style: italic;
}
.power-channel-tag.on {
    background-color: #1d3622;
    border: 1px solid #307e26;
}
.power-channel-tag.off {
    background-color: #361d1d;
    border: 1px solid #7e2626;
}

/* ===== BUTTONS (Smaller) ===== */
.btn { padding: 0.5rem 1rem; border: none; border-radius: 5px; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background-color: var(--accent-primary); color: white; }
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }
.btn-secondary { background-color: var(--bg-light); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background-color: var(--border-color); }
.btn-danger { background-color: #9f2828; color: var(--text-primary); border: 1px solid #895e5e; }
.btn-danger:hover:not(:disabled) { background-color: #812a2a; }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ── Inline platform selector in runner files table ── */
.inline-select {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    font-size: 0.78rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    -webkit-appearance: auto;
    appearance: auto;
}
.inline-select:hover {
    border-color: var(--border-color);
    color: var(--text-primary);
}
.inline-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    color: var(--text-primary);
}
.inline-select option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}


/* ===== CSS SLIDER TOGGLE (Smaller) ===== */
.switch-toggle-small {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}
.switch-toggle-small input { opacity: 0; width: 0; height: 0; }
.switch-toggle-small .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 20px;
}
.switch-toggle-small .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.switch-toggle-small input:checked + .slider {
    background-color: var(--status-standby); /* Use standby color */
}
.switch-toggle-small input:checked + .slider:before {
    transform: translateX(14px);
}

/* ===== TABLE VARIANTS (extend .data-table) ===== */
/* .device-table-dense, .automation-table, .update-table use .data-table as base */

/* Allow description text to wrap in automation rows */
.automation-table .test-desc {
    white-space: normal;
}

.test-info {
    display: flex;
    flex-direction: column;
}
.test-info .test-name {
    font-weight: 500;
    color: var(--text-primary);
}
.test-info .test-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: normal; /* Allow descriptions to wrap */
}

.status-cell {
    display: flex;
    align-items: center;
    font-weight: 500;
}
.status-cell.running { color: var(--status-online); }
.status-cell.failed { color: var(--status-offline); }

.controls-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== 3-DOT DROPDOWN MENU ===== */
.btn-icon {
    padding: 0.25rem 0.5rem; /* Make it squarer */
}

.dropdown-menu {
    position: relative;
    display: inline-block;
}

/* This is the menu box, hidden by default */
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%; /* Position below the button */
    min-width: 160px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100;
    margin-top: 5px;
    overflow: hidden; /* To get rounded corners on links */
}

/* Show the menu on hover (you can change this to click with JS) */
.dropdown-menu:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 10px 15px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    white-space: nowrap;
}
.dropdown-content a:hover {
    background-color: var(--accent-primary);
    color: white;
}
.dropdown-content a.danger:hover {
    background-color: var(--status-offline);
}

/* ===== POWER RACK PAGE ===== */
#power-rack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.power-rack-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.rack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}
.rack-title {
    display: flex;
    align-items: center;
}
.rack-title i {
    font-size: 1.5rem;
    margin-right: 1rem;
    color: var(--accent-primary);
}
.rack-title h2 {
    font-size: 1.1rem;
}
.rack-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* New Readout Styles */
.rack-readouts {
    display: flex;
    justify-content: space-around;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.readout-box {
    text-align: center;
}
.readout-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: block;
}
.readout-value {
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}
.readout-value .unit {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* List of channels on this rack */
.rack-channels {
    padding: 0.5rem 0;
}
.channel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}
.channel-row:not(:last-child) {
    border-bottom: 1px solid var(--bg-light);
}
.channel-label {
    color: var(--text-secondary);
}

/* Use the large toggle switch from your first design */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 28px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--status-online);
}
input:checked + .slider:before {
    transform: translateX(22px);
}
.switch-toggle-small {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    flex-shrink: 0; /* Prevents toggle from shrinking */
}
.switch-toggle-small input { opacity: 0; width: 0; height: 0; }
.switch-toggle-small .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 20px;
}
.switch-toggle-small .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.switch-toggle-small input:checked + .slider {
    background-color: var(--status-online); /* Use online green */
}
.switch-toggle-small input:checked + .slider:before {
    transform: translateX(14px);
}
/* ================================
   AUTOMATION DASHBOARD STYLES
   ================================ */

/* --- Header --- */
.dashboard-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.header-title {
    flex-grow: 1;
}
.header-title h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.header-title h1 i {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.header-title h1 i:hover {
    color: var(--text-primary);
}
.header-title .status-cell {
    font-size: 0.9rem;
    margin-top: 5px;
}
.header-main-controls {
    display: flex;
    gap: 0.5rem;
}

/* --- Sub-Navigation (Tabs) --- */
.sub-nav {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.sub-nav-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transform: translateY(1px); /* Aligns with border */
}
.sub-nav-item.active,
.sub-nav-item:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent-primary);
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* --- Dashboard Widgets --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 2/3 for log, 1/3 for params */
    gap: 1.5rem;
}
.widget-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.widget-card.full-width {
    grid-column: 1 / -1; /* Makes log span full width */
}
.widget-card h2 {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.realtime-log-widget {
    height: 400px;
    overflow-y: auto;
    background-color: var(--bg-darkest);
    color: var(--text-secondary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    padding: 1rem;
    margin: 0;
}

/* --- Code Editor --- */
.code-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#code-editor-container {
    height: 60vh;
    background-color: #1e1e1e; /* VS Code dark color */
    color: #d4d4d4;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    padding: 1rem;
    overflow: auto;
    white-space: pre;
}

/* --- History/Settings Forms --- */
.log-history-table {
    width: 100%;
}
.form-container {
    padding: 1.5rem;
}
.form-container label,
.form-grid label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}
.form-container input[type="text"],
.form-container textarea,
.form-grid input, .form-grid select {
    width: 100%;
    padding: 0.7rem 1rem;
    background-color: var(--bg-darkest);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-family);
}
.form-container textarea {
    resize: vertical;
    min-height: 80px;
}
.form-container button,
.form-grid button {
    margin-top: 1.5rem;
}
.form-grid {
    padding: 1.5rem;
}

.danger-zone {
    border-color: var(--status-offline);
}
.danger-zone h2 {
    background-color: var(--status-offline);
    border-bottom-color: var(--status-offline);
    color: white;
}
.danger-zone-content {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.danger-zone-content p {
    color: var(--text-secondary);
    max-width: 70%;
}

/* ================================
   CODEMIRROR STYLES
   ================================ */

/* This is the <div> you are creating in your function */
#code-editor-container {
    border-top: 1px solid var(--border-color);
}

/* These are the classes CodeMirror *creates* */
.CodeMirror {
    height: 100% !important;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
}
/* This makes the theme match your dark mode */
.cm-s-material-darker {
    background-color: var(--bg-darkest);
}
.cm-s-material-darker .CodeMirror-gutters {
    background-color: var(--bg-darkest);
    border-right: 1px solid var(--border-color);
}
.cm-s-material-darker .CodeMirror-linenumbers {
    color: #666; /* Fainter line numbers */
}
.cm-s-material-darker .CodeMirror-cursor {
    border-left: 1px solid #e0e0e0; /* Brighter cursor */
}
.cm-s-material-darker .cm-variable{
    color: #00ceff !important;
}
.cm-s-material-darker .cm-property {
    color: #ddc64a !important;
}
.cm-s-material-darker .cm-comment {
    color: #529d5c !important;
}

/* Single shared backdrop behind the topmost modal dialog in the stack
   (DialogStack reuses one .modal-overlay-backdrop element for every dialog) */
.modal-overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    opacity: 0;
    animation: fadeIn 0.2s ease forwards;
}

/* Base chrome shared by every dialog built on BaseDialog (prompts and hover boxes alike).
   Each dialog positions/centers itself since it is no longer wrapped by a flex overlay. */
.dialog-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    opacity: 0;
    animation: zoomIn 0.2s 0.05s ease forwards;
}

.dialog-box.fullscreen {
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: none;
    animation: fadeIn 0.2s ease forwards;
}

/* Prompt dialogs (dynamicPrompt): fixed-width form modal */
.modal-box {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
}

/* Hover/info boxes (addHoverBox): size is set per-instance via inline styles (Box.setStyle) */
.box-container {
    max-width: 95vw;
    max-height: 95vh;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-light);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

.modal-header .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.modal-header .close-btn:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-light) var(--bg-dark);
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}
.modal-content::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 0 0 8px 0;
}
.modal-content::-webkit-scrollbar-thumb {
    background-color: var(--bg-light);
    border-radius: 4px;
    border: 2px solid var(--bg-dark);
}
.modal-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

.modal-validation-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: auto;
    color: var(--text-secondary);
}

.dialog-box[aria-busy="true"] button:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Wrapper generated for compound components (input-label, select-label, textarea-label) */
.modal-content .form-group {
    display: block;
    margin-bottom: 0.25rem;
}

/* Style inputs inside the modal */
.modal-content label,
.modal-content div.text-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background-color: var(--bg-darkest);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-family);
}
.modal-content input[type="checkbox"] {
    width: 16px;
    height: 16px;
    padding: 0;
    flex-shrink: 0;
    accent-color: var(--accent-primary);
    cursor: pointer;
}
.modal-content .modal-checkbox {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}
.modal-content .modal-checkbox label {
    margin: 0;
    cursor: pointer;
}
.modal-content input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}
/* --- Add these styles to your modal CSS --- */

.modal-error-message {
    display: block;
    color: var(--status-offline); /* Your existing red variable */
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 5px;
}

/* Red border for invalid fields */
.modal-content input.invalid,
.modal-content select.invalid,
.modal-content textarea.invalid {
    border-color: var(--status-offline);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.25); /* Faint red glow */
}
.parameter-options {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spinning {
    animation: spin 1s linear infinite;
}

/* ================================
   AUTODISCOVERY PAGE STYLES
   ================================ */

.discovery-container {
    display: flex;
    gap: 1.5rem;
    height: 75vh; /* Set a fixed height for the container */
}

.discovery-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.discovery-sidebar .dashboard-controls {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.discovery-sidebar .dashboard-controls input[type="search"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}

#discovery-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.device-list-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.device-list-item:last-child {
    border-bottom: none;
}
.device-list-item:hover {
    background-color: var(--bg-light);
}
.device-list-item.active {
    background-color: var(--accent-primary);
    color: white;
}
.device-list-item strong {
    display: block;
    font-weight: 500;
}
.device-list-item small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.device-list-item.active small {
    color: rgba(255, 255, 255, 0.7);
}

.discovery-content {
    flex-grow: 1;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.packet-details-container {
    padding: 1.5rem;
    height: 100%;
}
.packet-details-container.hidden {
    display: none !important;
}

/* Placeholder styles */
#packet-details-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
}
#packet-details-placeholder i {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Detail view styles */
.packet-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.packet-header h2 {
    font-size: 1.25rem;
    margin: 0;
}
.packet-header #packet-last-seen {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.json-viewer {
    background-color: var(--bg-darkest);
    border-radius: 5px;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    color: var(--text-primary);
    white-space: pre-wrap; /* Allows long lines to wrap */
    overflow-y: auto;
    height: calc(75vh - 120px); /* Calculate remaining height */
    font-size: 0.9rem;
}

#discovery-list::-webkit-scrollbar,
.json-viewer::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

/* The "track" (the background of the scrollbar) */
#discovery-list::-webkit-scrollbar-track,
.json-viewer::-webkit-scrollbar-track {
    background: var(--bg-dark); /* Dark background */
    border-radius: 5px;
}

/* The "thumb" (the draggable handle) */
#discovery-list::-webkit-scrollbar-thumb,
.json-viewer::-webkit-scrollbar-thumb {
    background-color: var(--bg-light); /* Lighter grey handle */
    border-radius: 5px;
    border: 2px solid var(--bg-dark); /* Creates a nice padding effect */
}

/* The thumb on hover */
#discovery-list::-webkit-scrollbar-thumb:hover,
.json-viewer::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-primary); /* Blue accent on hover */
}


/* --- 2. For Firefox --- */
/* We target the same elements */
#discovery-list,
.json-viewer {
    scrollbar-width: thin; /* 'thin' or 'auto' */
    scrollbar-color: var(--bg-light) var(--bg-dark); /* thumb track */
}

/* Target links inside the device info widget */
.value-display a {
    color: var(--text-primary); /* Keep text white/grey by default */
    text-decoration: none;      /* Remove the default underline */
    border-bottom: 1px solid var(--text-secondary); /* Add a subtle custom underline */
    transition: all 0.2s ease;
}

.value-display a:hover {
    color: var(--accent-primary); /* Turn blue on hover */
    border-bottom-color: var(--accent-primary);
}

/* ── Update inspection metadata grid ───────────────────────────────────────── */
.inspect-meta-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
    background-color: var(--bg-darkest);
    border-radius: 5px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.inspect-key {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.inspect-val {
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    word-break: break-all;
}

/* Update this class */
.status-cell {
    display: flex;
    align-items: center; /* Vertically center dots and text */
    gap: 8px;            /* Adds space between EVERY span automatically */
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Add a new class for the separator line */
.status-separator {
    color: var(--border-color); /* Make it subtle/darker than text */
    margin: 0 5px;              /* Add extra breathing room around the line */
}

#page-dante { min-width: 0; }
#page-dante h1 { margin: 0; }
#page-dante h2 { font-size: 1.1rem; font-weight: 600; }
#page-dante h3 { font-size: 0.9rem; font-weight: 600; }
.dante-heading, .dante-section-heading, .dante-section-footer, .dante-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dante-heading { margin-bottom: 1.5rem; }
.dante-status { display: inline-flex; align-items: center; color: var(--text-secondary); font-size: 0.85rem; }
.dante-muted { color: var(--text-secondary); font-size: 0.85rem; }
.dante-monospace { font-family: 'Courier New', monospace; overflow-wrap: anywhere; }
.dante-target { display: grid; grid-template-columns: auto minmax(130px, 1fr) minmax(130px, 1fr) minmax(180px, 1fr) auto; gap: 1.25rem; align-items: center; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--border-color); }
.dante-target h2, .dante-section-heading h2 { display: flex; gap: 0.6rem; align-items: center; }
.dante-target h2 i, .dante-section-heading h2 i { color: var(--text-secondary); font-size: 1.35rem; }
.dante-target label, .dante-field { display: flex; flex-direction: column; gap: 0.4rem; color: var(--text-secondary); font-size: 0.85rem; min-width: 0; }
#page-dante input:not([type="checkbox"]):not([type="radio"]), #page-dante select { min-width: 0; width: 100%; padding: 0.6rem 0.75rem; background: var(--bg-dark); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 5px; font: inherit; }
#page-dante input:focus-visible, #page-dante select:focus-visible, #page-dante button:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
#page-dante input[type="checkbox"], #page-dante input[type="radio"] { accent-color: var(--accent-primary); width: 16px; height: 16px; flex-shrink: 0; }
#page-dante select:disabled { color: var(--text-secondary); opacity: 0.7; }
.dante-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 2rem; }
.dante-section { min-width: 0; padding: 1.5rem 0; border-bottom: 1px solid var(--border-color); }
.dante-section-heading { margin-bottom: 1.25rem; }
.dante-wide { grid-column: 1 / -1; }
.dante-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.dante-metrics .dante-current-pool { grid-column: 1 / -1; }
.dante-metrics dt, .dante-run-meta dt { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.3rem; }
.dante-metrics dd { font-size: 1rem; }
.dante-metrics .dante-remaining dd { font-size: 1.5rem; }
.dante-current-pool dd { display: flex; flex-direction: column; gap: 0.3rem; }
#danteConfigList { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1rem; }
.dante-config-card { min-width: 0; padding: 1rem; background: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 5px; }
.dante-config-card h3 { margin: 0 0 0.75rem; font-size: 1rem; overflow-wrap: anywhere; }
.dante-config-field { display: flex; flex-direction: column; gap: 0.3rem; }
.dante-config-field + .dante-config-field { margin-top: 0.75rem; }
.dante-pool-summary { display: flex; flex-direction: column; gap: 0.4rem; border-left: 3px solid var(--accent-primary); padding-left: 1rem; }
.dante-label { font-size: 0.85rem; }
.dante-pool-summary strong { font-size: 0.9rem; font-weight: 500; }
.dante-section-footer { margin-top: 1.25rem; }
.dante-test-list { display: flex; flex-direction: column; }
.dante-test-list label { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; cursor: pointer; border-bottom: 1px solid var(--bg-light); }
.dante-test-list label span:last-child { margin-left: auto; white-space: nowrap; }
.dante-table-scroll { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 5px; }
.dante-used-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.dante-used-toolbar .dante-filter-input { flex: 1 1 auto; width: auto; margin-top: 0; }
.dante-used-toolbar .dante-amount-select { flex: 0 0 auto; width: auto; margin-top: 0; }
.dante-pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.dante-pagination .dante-page-info { color: var(--text-secondary); font-size: 0.85rem; white-space: nowrap; }
.dante-empty { text-align: center; padding: 2rem 1rem; color: var(--text-secondary); white-space: normal; }
.dante-empty i { margin-right: 0.5rem; font-size: 1.25rem; vertical-align: middle; }
.dante-procedure-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
.dante-mode { border: 0; min-width: 0; }
.dante-mode legend { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.dante-segmented { display: flex; border: 1px solid var(--border-color); border-radius: 5px; overflow: hidden; width: fit-content; max-width: 100%; }
.dante-segmented label { position: relative; cursor: pointer; min-width: 0; }
.dante-segmented input { position: absolute; opacity: 0; }
.dante-segmented span { display: block; padding: 0.55rem 1rem; font-size: 0.85rem; text-align: center; }
.dante-segmented input:checked + span { background: var(--accent-primary); color: white; }
.dante-segmented input:focus-visible + span { outline: 2px solid var(--text-primary); outline-offset: -3px; }
.dante-steps { list-style: none; counter-reset: dante-step; margin: 1rem 0; }
.dante-steps li { counter-increment: dante-step; display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0; border-bottom: 1px solid var(--bg-light); }
.dante-steps li::before { content: counter(dante-step, decimal-leading-zero); color: var(--text-secondary); font-size: 0.8rem; width: 1.5rem; flex-shrink: 0; }
.dante-steps label { display: flex; align-items: center; gap: 0.65rem; }
.dante-steps li > span { margin-left: auto; white-space: nowrap; }
.dante-steps li[data-skipped="true"] { opacity: 0.5; }
#page-dante input[type="file"] { font-size: 0.8rem; }
#page-dante input::file-selector-button { background: var(--bg-light); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 3px; padding: 0.3rem 0.6rem; margin-right: 0.6rem; cursor: pointer; }
.dante-run-actions { justify-content: flex-start; margin-top: 1.25rem; }
.dante-monitor { border-left: 1px solid var(--border-color); padding-left: 2rem; min-width: 0; }
.dante-monitor progress { display: block; width: 100%; height: 6px; border: 0; border-radius: 3px; overflow: hidden; background: var(--bg-light); accent-color: var(--accent-primary); }
.dante-monitor progress::-webkit-progress-bar { background: var(--bg-light); }
.dante-monitor progress::-webkit-progress-value { background: var(--accent-primary); }
.dante-monitor progress::-moz-progress-bar { background: var(--accent-primary); }
.dante-run-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.dante-run-meta dd { font-size: 0.9rem; }
.dante-log-heading { margin-bottom: 0.6rem; }
.dante-log { min-height: 175px; max-height: 280px; overflow: auto; padding: 1rem; background: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 5px; font-family: 'Courier New', monospace; overflow-wrap: anywhere; }
.dante-feedback { min-height: 1.5rem; margin-top: 1rem; color: var(--text-secondary); font-size: 0.85rem; }
.dante-dialog { margin: auto; width: min(480px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; padding: 1.5rem; background: var(--bg-dark); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 8px; }
.dante-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.dante-dialog .dante-field { margin-top: 1rem; }
.dante-dialog footer { justify-content: flex-end; margin-top: 1rem; }
.dante-icon-button { width: 32px; height: 32px; padding: 0; justify-content: center; flex-shrink: 0; }
.dante-error { color: var(--status-offline); font-size: 0.85rem; margin-top: 0.75rem; }
.dante-history-dialog { width: min(700px, calc(100% - 2rem)); }

#ssh-terminal-container {
    height: 500px;
    width: 100%;
    background-color: #1e1e1e; /* Standard terminal background */
    border-radius: 4px;
    overflow: hidden; /* Important: Xterm handles scrolling internally */
    position: relative;
}

/* Customize Xterm scrollbar to match your theme */
.xterm-viewport::-webkit-scrollbar {
    width: 10px;
}
.xterm-viewport::-webkit-scrollbar-track {
    background: #1e1e1e;
}
.xterm-viewport::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 5px;
}

.form-container select,
.dashboard-grid select {
    /* 1. Remove default browser styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* 2. Match your dark theme input styles */
    background-color: var(--bg-darkest);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.7rem 1rem;
    border-radius: 5px;
    font-size: 1rem;
    font-family: var(--font-family);
    cursor: pointer;
    width: 100%; /* or auto, depending on layout */
    
    /* 3. Re-add the dropdown arrow (since we removed it in step 1) */
    /* This uses a simple SVG data URI for a white/grey arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 30px; /* Make space for the arrow so text doesn't overlap */
}

/* Add a focus state for better UX */
.form-container select:focus,
.dashboard-grid select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ================================
   MODAL TABLE SECTIONS
   ================================ */

.table-section {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.table-section .text-label {
    padding: 0.75rem 0.75rem 0.25rem;
}

.table-section .modal-table {
    width: 100%;
    border-collapse: collapse;
}

.table-section .modal-table th,
.table-section .modal-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    white-space: nowrap;
}

.table-section .modal-table thead {
    background-color: var(--bg-darkest);
}

.table-section .modal-table th {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-section .modal-table tbody tr:last-child td {
    border-bottom: none;
}

.table-section .modal-table tbody tr:hover {
    background-color: var(--bg-light);
}

/* Full-width "add row" button visually attached to bottom of table */
.btn-add-row {
    width: 100%;
    border-radius: 0;
    border: none;
    border-top: 1px dashed var(--border-color);
    justify-content: center;
    background-color: var(--bg-darkest);
    color: var(--text-secondary);
    padding: 0.5rem;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-add-row:hover:not(:disabled) {
    background-color: var(--bg-light);
    color: var(--text-primary);
}