/* ——— CSS VARIABLES (light defaults) ——— */
:root {
    --bg: #fff;
    --bg-alt: #f8f8f8;
    --bg-tab-bar: #f0f0f0;
    --bg-row-even: #dce3ef;
    --text: #000;
    --text-muted: #666;
    --border: #ddd;
    --border-dark: #000;
    --border-cell: lightgray;
    --th-bg: lightgrey;
    --modal-bg: #fff;
    --shadow: rgba(0,0,0,0.15);
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #888;
    --link: blue;
    --tab-bg: #d8d8d8;
    --tab-active-bg: #fff;
    --reset-btn-bg: #faddd0;
    --chart-card-bg: #fff;
}
body.dark {
    --bg: #111827;
    --bg-alt: #1f2937;
    --bg-tab-bar: #1f2937;
    --bg-row-even: #243344;
    --text: #e5e7eb;
    --text-muted: #d1d5db;
    --border: #374151;
    --border-dark: #4b5563;
    --border-cell: #374151;
    --th-bg: #334155;
    --modal-bg: #1f2937;
    --shadow: rgba(0,0,0,0.4);
    --scrollbar-track: #1f2937;
    --scrollbar-thumb: #4b5563;
    --link: #93c5fd;
    --tab-bg: #1f2937;
    --tab-active-bg: #111827;
    --reset-btn-bg: #374151;
    --chart-card-bg: #1f2937;
}

/* GLOBAL PAGE PADDING */
body {
    margin: 0;
    padding: 0 10px;
    height: 100vh;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    font-family: Arial, sans-serif;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* REMOVE GAP BETWEEN HEADER AND TABS */
.header-stats-wrapper {
    position: relative;
    background: var(--bg-alt);
    border-bottom: 2px solid var(--border);
    margin: 0 !important;
}
.header-stats {
    padding: 10px 0;
    font-weight: bold;
    margin: 0 !important;
}
.tab-buttons-container {
    padding: 8px 0 0 0 !important;
    margin: 0 !important;
    background: var(--bg-tab-bar);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    position: relative;
}
.exec-view-btn {
    position: absolute;
    right: 120px;
    top: 10px;
    padding: 4px 14px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}
.exec-view-btn:hover { background: #357abd; }

/* TABLE WRAPPER */
.table-wrapper {
    display: none;
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    box-sizing: border-box;
}
.table-wrapper.active {
	display: block !important;
	flex: 1;
	min-height: 0;
}


/* Inner wrapper must expand to table width for scroll to work */
.table-container {
    width: max-content;
    min-width: 100%;
}

/* FORCE HORIZONTAL SCROLL — nowrap prevents cells from shrinking to fit viewport */
.table-wrapper td,
.table-wrapper th {
    white-space: nowrap;
}

#greenlights-table table {
    min-width: 1600px !important;
    width: 100%;
    table-layout: auto;
}

#servers-table table,
#gordon table,
#doc-stats table,
#admin-users table,
#scheduler-status table,
#hl7-gen table,
#network-charts table,
#network-monitor table {
    width: max-content;
    table-layout: auto;
}

/* NAME & LAST UPDATED — NEVER WRAP */
.fixed-width-col-name,
.fixed-width-col-lastupdated {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ONLY THE STATUS/ERROR CELLS WRAP — BUTTONS ARE SAFE */
.combined-column-right,
td[colspan="3"],
td[colspan="2"] {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    line-height: 1.2;
    padding: 10px 8px !important;
}

/* CRITICAL: Keep Reset/Rerun buttons horizontal */
.combined-column-left {
    white-space: nowrap !important;
    text-align: right;
    width: 1%;
    border-left-style: none !important;
}

/* Scrollbar styling */
.table-wrapper::-webkit-scrollbar { width: 12px; height: 24px; }
.table-wrapper::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 6px; }
.table-wrapper::-webkit-scrollbar-thumb { background-color: var(--scrollbar-thumb); border-radius: 6px; border: 2px solid var(--scrollbar-track); }
.table-wrapper { scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }

/* ——— ALL YOUR ORIGINAL STYLES BELOW (unchanged) ——— */
.reset-button {
    box-shadow: none;
    background-color: var(--reset-btn-bg);
    border-radius: 6px;
    border: 1px solid var(--border);
    display: inline-block;
    cursor: pointer;
    color: var(--text-muted);
    font-family: Arial;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 24px;
    text-decoration: none;
    position: relative;
    z-index: 1;
}
.reset-button:hover {
	background-color: var(--bg-row-even);
}
.reset-button:active { 
	position: relative; top: 1px; 
}

.combined-column-left {
    border-left: 0;
    position: relative;
    z-index: 1;
}
.combined-column-right {
    border-right: 0;
    max-width: 70%;
    border-right-style: none !important;
}
.combined-column:last-child {
	border-right: 1px solid var(--border-cell);
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 100%;
    box-shadow: 0 0 20px var(--shadow);
    table-layout: auto;
}
td {
    border: 1px solid var(--border-cell);
    padding: 3px;
    position: relative;
}
th {
    border: 1px solid var(--border-dark);
    padding: 4px;
    background-color: var(--th-bg);
    color: var(--text);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}
tr:nth-child(even) {
	background-color: var(--bg-row-even);
}
/* Explicit striping for dense tables (belt-and-suspenders) */
#doc-stats tbody tr:nth-child(even),
#admin-users tbody tr:nth-child(even),
#network-monitor tbody tr:nth-child(even) {
	background-color: var(--bg-row-even) !important;
}
#doc-stats tbody tr:nth-child(odd),
#admin-users tbody tr:nth-child(odd),
#network-monitor tbody tr:nth-child(odd) {
	background-color: var(--bg);
}

.green { 
	background-color: green; 
	color: white; 
}

.yellow { 
	background-color: yellow; 
}
.red { 
	background-color: red; 
	color: white; 
}

.fixed-width-col-name { 
	width: 300px; 
	min-width: 300px; 
}
/* .fixed-width-col-status { width: 50px; } */
.fixed-width-col-lastupdated { 
	width: 140px; 
	min-width: 140px; 
}

.center-text { 
	text-align: center; 
}

.tab-button {
    padding: 8px 16px;
    background-color: var(--tab-bg);
    color: var(--text);
    border: 1px solid var(--border-dark);
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    white-space: nowrap;
    opacity: 0.6;
}
.tab-button:hover {
    opacity: 0.85;
}
.tab-button.active {
    background-color: var(--tab-active-bg);
    border-top: 4px solid #3b82f6;
    border-bottom: 1px solid var(--tab-active-bg);
    font-weight: bold;
    opacity: 1;
    position: relative;
    margin-bottom: -1px;
    z-index: 1;
}

.modal-link {
	cursor: pointer;
	color: var(--link);
	text-decoration: underline;
	position: relative;
	z-index: 10;
}

.w3-modal { 
	z-index: 3; 
	display: none; 
	padding-top: 20px; 
	position: fixed; 
	left: 0; 
	top: 0; 
	width: 100%; 
	height: 100%; 
	overflow: auto; 
	background-color: rgba(0,0,0,0.4); 
	z-index: 10;
}

.w3-modal-content {
	margin: 5% auto;
	background-color: var(--modal-bg);
	position: relative; 
	padding: 10px; 
	outline: 0; 
	width: 1000px; 
	max-width: 90%; 
	max-height: 90vh; 
	overflow: auto;
	z-index: 10; 
}

.w3-display-topright {
	position: absolute;
	right: 0;
	top: 0;
	z-index: 10;
	padding: 8px 16px;
	background-color: var(--modal-bg);
	border-radius: 0 0 0 8px; 
	box-shadow: 0 0 5px rgba(0,0,0,0.1); 
}

.loading-spinner {
    	position: fixed; 
	top: 20px; 
	right: 20px; 
	z-index: 9999; 
	display: none; 
	flex-direction: column; 
	align-items: center;
    	background: rgba(0,0,0,0.7); 
	color: white; 
	padding: 15px 25px; 
	border-radius: 8px;
}

.spinner { 
	width: 40px; 
	height: 40px; 
	border: 4px solid #f3f3f3; 
	border-top: 4px solid #3498db; 
	border-radius: 50%; 
	animation: spin 1s linear infinite; 
	margin-bottom: 10px; 
}

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

/* YELLOW HIGHLIGHT FOR LOG EXCEPTIONS ROW — alternating gold */
tr.highlight-yellow:nth-child(odd) td {
    background-color: #d4a017 !important;
    color: #000;
}
tr.highlight-yellow:nth-child(even) td {
    background-color: #f0c040 !important;
    color: #000;
}

/* YELLOW BACKGROUND IN THE MODAL WHEN VIEWING LOG EXCEPTIONS */
#modal-content .highlight-yellow {
    background-color: #fffacd !important;
    padding: 8px;
    border-radius: 4px;
}

/* HIGHLIGHT THE WORD "Exception" IN RED/YELLOW ROWS AND MODALS */
.highlight-exception {
    background-color: #ffff00 !important;   /* Bright yellow */
    color: #000000 !important;             /* Black text */
/*    font-weight: bold !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    box-shadow: 0 0 4px rgba(0,0,0,0.3) !important;*/
    display: inline-block;
}

/* ——— DOC STATS NUMERIC ALIGNMENT ——— */
#stat-table td:nth-child(n+3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ——— NETWORK CHARTS TAB ——— */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 10px; }
.chart-card-nm { background: var(--chart-card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; color: var(--text); }
.chart-card-nm h4 { margin: 0 0 8px; font-size: 14px; }
.chart-card-nm canvas { width: 100% !important; height: 300px !important; }

/* ——— DARK MODE TOGGLE SWITCH ——— */
.dark-toggle {
    position: absolute;
    right: 10px;
    top: 10px;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}
.dark-toggle input { display: none; }
.dark-toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 20px;
    transition: background 0.3s;
}
.dark-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}
.dark-toggle input:checked + .dark-toggle-slider { background: #60a5fa; }
.dark-toggle input:checked + .dark-toggle-slider::before { transform: translateX(16px); }

/* ——— LOGOUT BUTTON ——— */
.logout-btn {
    position: absolute;
    right: 56px;
    top: 10px;
    padding: 2px 10px;
    font-size: 0.75rem;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    line-height: 20px;
    cursor: pointer;
}
.logout-btn:hover { background: #dc2626; }

/* ——— DARK MODE OVERRIDES ——— */
body.dark .green { background-color: #166534; color: #d1fae5; }
body.dark .red { background-color: #991b1b; color: #fee2e2; }
body.dark .yellow { background-color: #854d0e; color: #fef3c7; }
body.dark a { color: var(--link); }
body.dark .exec-view-btn { color: #fff; }
body.dark .tab-button.active { border-top-color: #93c5fd; background-color: var(--bg); }
body.dark .reset-button { background-color: #4b5563; color: #fff; border: 1.5px solid #60a5fa; }
body.dark .reset-button:hover { background-color: #6b7280; }
body.dark .highlight-exception { background-color: #854d0e !important; color: #fef3c7 !important; }
body.dark tr.highlight-yellow:nth-child(odd) td { background-color: #5c4a0e !important; color: #fef3c7; }
body.dark tr.highlight-yellow:nth-child(even) td { background-color: #7a6312 !important; color: #fef3c7; }
body.dark #modal-content .highlight-yellow { background-color: #3b2f00 !important; }

/* ——— ADMIN USERS SECTION HEADERS ——— */
.admin-users-table {
    background-color: #4a90d9 !important;
    color: #fff !important;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 8px 10px !important;
}
body.dark .admin-users-table {
    background-color: #334155 !important;
    color: #60a5fa !important;
}

/* INACTIVE USERS — DIMMED */
tr.user-inactive td {
    opacity: 0.45;
}

/* ——— LOG EXCEPTION TRUNCATION ——— */
.error-truncated {
    display: inline;
}
.error-truncated .error-overflow {
    display: none;
}
.error-truncated.expanded .error-overflow {
    display: inline;
}
.error-toggle {
    cursor: pointer;
    color: var(--link);
    font-weight: bold;
    font-size: 11px;
    margin-left: 4px;
    text-decoration: underline;
}

/* ——— ALTERNATING YELLOW CELLS (all tables) ——— */
tr:nth-child(odd) td.yellow { background-color: #d4a017 !important; color: #000; }
tr:nth-child(even) td.yellow { background-color: #f0c040 !important; color: #000; }
body.dark tr:nth-child(odd) td.yellow { background-color: #5c4a0e !important; color: #fef3c7; }
body.dark tr:nth-child(even) td.yellow { background-color: #7a6312 !important; color: #fef3c7; }

/* ——— SERVERS INFO TAB ——— */

/* Card grid layout */
.si-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 10px 10px; }
.si-card { padding: 12px 14px; font-size: 13px; }
.si-card-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.si-card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.si-card-detail { line-height: 1.7; }
.si-label { opacity: 0.5; margin-right: 4px; }
.si-card-stale { border: 2px solid #ef4444; background-color: #fef2f2; }
body.dark .si-card-stale { border-color: #f87171; background-color: #450a0a; }

/* Flex container for disk bars */
.si-disk-row { display: flex; flex-wrap: wrap; gap: 10px 24px; }

/* Individual disk: label + bar + pct + size */
.si-disk { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.si-disk-label { font-weight: bold; min-width: 50px; }
.si-disk-bar { width: 100px; height: 12px; border: 1px solid var(--border-dark); border-radius: 3px; overflow: hidden; background: var(--bg); }
.si-disk-fill { height: 100%; border-radius: 2px; }
.si-disk-green { background-color: #22c55e; }
.si-disk-yellow { background-color: #eab308; }
.si-disk-red { background-color: #ef4444; }
.si-disk-pct { min-width: 30px; text-align: right; }
.si-disk-size { opacity: 0.7; }

/* Load average coloring */
.si-load-green { color: #16a34a; font-weight: bold; }
.si-load-yellow { color: #ca8a04; font-weight: bold; }
.si-load-red { color: #dc2626; font-weight: bold; }
body.dark .si-load-green { color: #4ade80; }
body.dark .si-load-yellow { color: #facc15; }
body.dark .si-load-red { color: #f87171; }
