/* =====================================================================
   modern.css  -  Xeams UI modernization layer
   ---------------------------------------------------------------------
   Loaded AFTER newStyleSheet.css and AFTER the active theme CSS, so it can
   add modern STRUCTURE (radius, spacing, shadow, typography) on top of the
   theme. All COLOR here comes from the per-theme design tokens
   (--xeams-* defined in each *theme*.css :root), so every color theme and
   custom-theme keep their identity. Do not hard-code brand colors here.
   ===================================================================== */

:root{
	/* Structural tokens (same for every theme) */
	--xeams-radius: 0.6rem;
	--xeams-radius-sm: 0.4rem;
	--xeams-shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
	--xeams-shadow-hover: 0 6px 18px rgba(0,0,0,.12);
	--xeams-border: rgba(0,0,0,.10);
	--xeams-muted: #6c757d;
	--xeams-transition: 0.15s ease;
	--xeams-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
	/* Derived hover shade of the theme primary (graceful no-op if unsupported) */
	--xeams-primary-hover: color-mix(in srgb, var(--xeams-primary) 82%, #000);
	--xeams-primary-tint: color-mix(in srgb, var(--xeams-primary) 10%, #fff);
}

/* ------------------------------------------------------------------ *
 * 1. Base / typography
 * ------------------------------------------------------------------ */
body{
	background-color: var(--xeams-body-bg, #eef1f5);
	font-family: var(--xeams-font-sans);
	font-size: 15px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6{
	font-family: var(--xeams-font-sans);
	letter-spacing: -0.01em;
}
h1{ font-weight: 600; }

a{ transition: color var(--xeams-transition); }

/* Keyboard focus visibility (accessibility) */
a:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible{
	outline: 2px solid var(--xeams-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * 2. Legacy panel bridge: make .well-info-wrap look like a modern card.
 *    ~194 pages use this pattern, so this single block modernizes them
 *    without editing each page. Theme colors still drive the header.
 * ------------------------------------------------------------------ */
.well-info-wrap{
	background: var(--xeams-surface, #fff);
	border: 1px solid var(--xeams-border);
	border-radius: var(--xeams-radius);
	box-shadow: var(--xeams-shadow);
	overflow: hidden;
	margin-bottom: 1rem;
	transition: box-shadow var(--xeams-transition);
}
.well-info-wrap:hover{
	box-shadow: var(--xeams-shadow-hover);   /* replaces the heavy dark glow */
}

.well-info-header,
.well-info-footer{
	background: var(--xeams-primary);
	color: var(--xeams-on-primary, #fff);
	border: 0 !important;
	text-align: left;
	padding: 0.55rem 1rem;
	font-weight: 600;
	font-size: 0.95rem;
	letter-spacing: 0.01em;
}
.well-info-header a,
.well-info-footer a{ color: var(--xeams-on-primary, #fff); }

/* When .well-info-header is used on a table header row (<tr class="well-info-header">
   with <th>), Bootstrap sets the cell color directly, overriding the light color
   inherited from the row. Re-assert a readable light color on those cells. */
tr.well-info-header > th,
tr.well-info-header > td,
.well-info-header th,
.well-info-header td{
	color: var(--xeams-on-primary, #fff);
}

.well-info-body{
	background: var(--xeams-surface, #fff);
	border: 0 !important;
	padding: 1rem 1.1rem;
}
.well-info-additional{
	border: 0;
	border-bottom: 1px solid var(--xeams-border);
}

/* ------------------------------------------------------------------ *
 * 3. Bootstrap cards (pages already migrated) - subtle polish
 * ------------------------------------------------------------------ */
.card{
	border-color: var(--xeams-border);
	border-radius: var(--xeams-radius);
	box-shadow: var(--xeams-shadow);
}
.card > .card-header{
	background: var(--xeams-surface, #fff);
	border-bottom: 1px solid var(--xeams-border);
	font-weight: 600;
}

/* Optional dashboard KPI card + grid helpers (opt-in via classes) */
.stat-card{
	background: var(--xeams-surface, #fff);
	border: 1px solid var(--xeams-border);
	border-left: 4px solid var(--xeams-primary);
	border-radius: var(--xeams-radius);
	box-shadow: var(--xeams-shadow);
	padding: 1rem 1.1rem;
}
.stat-card .stat-value{ font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label{ color: var(--xeams-muted); font-size: 0.85rem; }

/* Horizontal KPI tile: large tinted icon on the left, text (label/value) on the right,
   vertically centered. Matches the StatusPanels.png reference format. */
.kpi-card{
	display: flex;
	align-items: center;
	gap: 0.9rem;
	background: var(--xeams-surface, #fff);
	border: 1px solid var(--xeams-border);
	border-radius: var(--xeams-radius);
	box-shadow: var(--xeams-shadow);
	padding: 1rem 1.1rem;
}
.kpi-card .kpi-icon{
	flex: 0 0 auto;
	width: 52px;
	height: 52px;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
}
.kpi-card .kpi-text{ flex: 1 1 auto; min-width: 0; }
.kpi-card .kpi-label{ color: var(--xeams-muted); font-size: 0.85rem; }
.kpi-card .kpi-value{ font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.kpi-icon-success{ background: rgba(40,167,69,.14); color: #1e7e34; }
.kpi-icon-warning{ background: rgba(255,193,7,.20); color: #b8860b; }
.kpi-icon-danger{ background: rgba(220,53,69,.14); color: #c82333; }
.kpi-icon-info{ background: rgba(13,110,253,.12); color: #0d6efd; }

/* Server status cards on the dashboard (PanelXxxStatus.jsp) */
.status-card{ position: relative; }
.status-card .card-body{ padding: 1rem 1.1rem; }
.status-label{ color: var(--xeams-muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; }
.status-value{ font-size: 1.45rem; font-weight: 700; line-height: 1.15; color: #1f2733; margin-top: 0.1rem; }
.status-value .conn{ font-size: 1rem; font-weight: 600; color: var(--xeams-muted); }
.status-value.down{ color: #dc3545; }
.status-value.unknown{ color: #6c757d; }
.status-sub{ color: var(--xeams-muted); font-size: 0.82rem; margin-top: 0.4rem; }
.status-dot{ width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.status-up{ background: #28a745; box-shadow: 0 0 0 3px rgba(40,167,69,.18); }
.status-down{ background: #dc3545; box-shadow: 0 0 0 3px rgba(220,53,69,.18); }
.status-unknown{ background: #adb5bd; box-shadow: 0 0 0 3px rgba(173,181,189,.18); }
.status-card .cfg-link{ position: absolute; top: 0.55rem; right: 0.7rem; color: var(--xeams-muted); font-size: 0.95rem; z-index: 2; }
.status-card .cfg-link:hover{ color: var(--xeams-primary); }
.starttls-badge{ display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; padding: 0.05rem 0.45rem; border-radius: 1rem; vertical-align: middle; }
.starttls-badge.on{ background: rgba(40,167,69,.14); color: #1e7e34; }
.starttls-badge.off{ background: rgba(108,117,125,.15); color: #6c757d; }

/* Dashboard card headers: accent icon + clean title */
.card > .card-header .bi{ color: var(--xeams-primary); margin-right: 0.35rem; }
.card > .card-header a .bi{ color: var(--xeams-muted); }

/* Label/value rows replacing the small stat tables inside panels */
.stat-row{ display: flex; justify-content: space-between; align-items: center; padding: 0.45rem 0.15rem; border-top: 1px solid var(--xeams-border); }
.stat-row:first-child{ border-top: 0; }
.stat-row .stat-k{ color: var(--xeams-muted); }
.stat-row .stat-v{ font-weight: 600; }

/* ------------------------------------------------------------------ *
 * 4. Buttons - unify shape/spacing/focus; keep theme colors
 * ------------------------------------------------------------------ */
.btn{ border-radius: var(--xeams-radius-sm); }
.btn-submit,
.btn-menu,
.btn-wide,
.btn-wide-submit,
.btn-wide-menu{
	border: 0;
	border-radius: var(--xeams-radius-sm);
	padding: 0.45rem 1.1rem;
	font-weight: 500;
	transition: filter var(--xeams-transition), box-shadow var(--xeams-transition);
}
.btn-submit:hover,
.btn-menu:hover,
.btn-wide-submit:hover,
.btn-wide-menu:hover{
	filter: brightness(0.94);
}
.btn-submit:active,
.btn-menu:active{ filter: brightness(0.88); }

/* ------------------------------------------------------------------ *
 * 5. Tables - light modern header, subtle zebra, comfortable cells
 * ------------------------------------------------------------------ */
.table{
	--bs-table-bg: transparent;
	margin-bottom: 1rem;
	vertical-align: middle;
}
.table > :not(caption) > * > *{
	padding: 0.55rem 0.75rem;
}
.table > thead th,
.table > thead td{
	background: #f1f3f5;
	color: var(--xeams-primary);
	border-bottom: 2px solid var(--xeams-primary);
	font-weight: 600;
	white-space: nowrap;
}
.table > tbody > tr:nth-of-type(odd) > *{
	background-color: rgba(0,0,0,.02);
}
.table > tbody > tr:hover > *{
	background-color: rgba(0,0,0,.045);
}

/* Rounded, scrollable container for wide tables (opt-in) */
.table-card{
	background: var(--xeams-surface, #fff);
	border: 1px solid var(--xeams-border);
	border-radius: var(--xeams-radius);
	box-shadow: var(--xeams-shadow);
	overflow: hidden;
}

/* ------------------------------------------------------------------ *
 * 6. Forms - themed focus ring, consistent radius
 * ------------------------------------------------------------------ */
.form-control,
.form-select{
	border-radius: var(--xeams-radius-sm);
}
.form-control:focus,
.form-select:focus{
	border-color: var(--xeams-accent);
	box-shadow: 0 0 0 0.2rem rgba(13,110,253,.20);
	box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--xeams-accent) 25%, transparent);
}
.form-check-input:checked{
	background-color: var(--xeams-accent);
	border-color: var(--xeams-accent);
}

/* ------------------------------------------------------------------ *
 * 7. Alerts - flatter, accent stripe
 * ------------------------------------------------------------------ */
.alert{
	border: 0;
	border-left: 4px solid currentColor;
	border-radius: var(--xeams-radius-sm);
}

/* ------------------------------------------------------------------ *
 * 8. Page title helper (opt-in include target)
 * ------------------------------------------------------------------ */
.xeams-page-title{
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.25rem 0 1rem;
}
.xeams-page-title .subtitle{
	color: var(--xeams-muted);
	font-size: 0.9rem;
}

/* ------------------------------------------------------------------ *
 * 9. Footer - compact and lighter
 * ------------------------------------------------------------------ */
.footer{
	padding: 0.6rem 0;
	font-size: 0.82rem;
}
.red{
	padding: 0.4rem 0.85rem;
	font-size: 0.85rem;
}

/* ------------------------------------------------------------------ *
 * 10. Misc modern touches
 * ------------------------------------------------------------------ */
code, pre, kbd{ border-radius: var(--xeams-radius-sm); }
hr{ opacity: 0.12; }
.modal-content{ border: 0; border-radius: var(--xeams-radius); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dropdown-menu{ border-color: var(--xeams-border); border-radius: var(--xeams-radius-sm); box-shadow: var(--xeams-shadow); }

/* ------------------------------------------------------------------ *
 * 11. Dark mode
 * ---------------------------------------------------------------------
 * Activated by data-bs-theme="dark" on <html>. Bootstrap 5.3 handles its
 * own components; here we (a) flip the neutral/surface --xeams-* tokens to
 * dark so all custom components adapt, (b) override the few LIGHT surfaces
 * that the theme files hard-code (.bodyback, table header, etc.), and
 * (c) lighten headings/links (derived from each theme's accent) for
 * contrast. Brand chrome (header, menu, buttons, .well-info-header) stays
 * the theme colour in both modes, so each color theme keeps its identity.
 * ------------------------------------------------------------------ */
[data-bs-theme="dark"]{
	--xeams-surface: #1f232b;
	--xeams-body-bg: #15181e;
	--xeams-border: rgba(255,255,255,.12);
	--xeams-muted: #9aa4b2;
	--xeams-shadow: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
	--xeams-shadow-hover: 0 6px 18px rgba(0,0,0,.55);
	color-scheme: dark;
}
[data-bs-theme="dark"] body{ background-color: var(--xeams-body-bg) !important; color: #dfe3ea; }
[data-bs-theme="dark"] .footer{ color: var(--xeams-muted); }
[data-bs-theme="dark"] .footer a{ color: color-mix(in srgb, var(--xeams-accent) 55%, #ffffff); }
[data-bs-theme="dark"] .bodyback{ background: var(--xeams-body-bg) !important; color: #dfe3ea; }
[data-bs-theme="dark"] .well-info-body{ color: #dfe3ea; }
[data-bs-theme="dark"] .well-info-additional,
[data-bs-theme="dark"] .form-text{ background-color: rgba(255,255,255,.06); color: #cfd4dc; }

/* Headings and content links: lighten each theme's accent for readability.
 * Exclude anchors that are styled as buttons ([class*="btn"]) so their theme
 * button text colour (usually white on a coloured gradient) is preserved. */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4{ color: color-mix(in srgb, var(--xeams-accent) 60%, #ffffff); }
[data-bs-theme="dark"] .bodyback a:not([class*="btn"]){ color: color-mix(in srgb, var(--xeams-accent) 55%, #ffffff); }

/* Tables: our light thead/zebra tuning needs dark equivalents */
[data-bs-theme="dark"] .table > thead th,
[data-bs-theme="dark"] .table > thead td{
	background: rgba(255,255,255,.06);
	color: color-mix(in srgb, var(--xeams-accent) 62%, #ffffff);
	border-bottom-color: rgba(255,255,255,.22);
}
[data-bs-theme="dark"] .table > tbody > tr:nth-of-type(odd) > *{ background-color: rgba(255,255,255,.03); }
[data-bs-theme="dark"] .table > tbody > tr:hover > *{ background-color: rgba(255,255,255,.06); }

/* Custom cards that hard-code dark text on light surfaces */
[data-bs-theme="dark"] .status-value,
[data-bs-theme="dark"] .kpi-card .kpi-value{ color: #eef1f6; }

/* Hover pop-ups (mouse-over balloons). Their containers hard-code a white
 * background in the theme/GWT stylesheets, while the embedded Bootstrap table
 * text turns light in dark mode -> white-on-white. Flip the container to the
 * dark surface so the table (which Bootstrap already darkens) stays readable.
 * Covers: Message Repository (.popup_info), Live Monitor GWT balloon
 * (.gwt-PopupPanel), and the field help balloons (.balloonstyle). */
[data-bs-theme="dark"] .popup_info,
[data-bs-theme="dark"] .balloonstyle,
[data-bs-theme="dark"] .gwt-PopupPanel,
[data-bs-theme="dark"] .gwt-DecoratedPopupPanel{
	background-color: var(--xeams-surface) !important;
	color: #dfe3ea;
	border: 1px solid var(--xeams-border) !important;
	border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0,0,0,.6) !important;
}
/* DecoratedPopupPanel (Live Monitor reason balloon) builds its rounded frame
 * from a 3x3 grid of cells with light backgrounds / border images; flatten them
 * all to the dark surface so nothing shows white. */
[data-bs-theme="dark"] .gwt-DecoratedPopupPanel td{
	background-color: var(--xeams-surface) !important;
	background-image: none !important;
}
[data-bs-theme="dark"] .popup_info table,
[data-bs-theme="dark"] .balloonstyle table,
[data-bs-theme="dark"] .gwt-PopupPanel table,
[data-bs-theme="dark"] .gwt-DecoratedPopupPanel table{ color: #dfe3ea; }
[data-bs-theme="dark"] .popup_info th,
[data-bs-theme="dark"] .balloonstyle th,
[data-bs-theme="dark"] .gwt-PopupPanel th,
[data-bs-theme="dark"] .gwt-DecoratedPopupPanel th{ color: #eef1f6; }

/* Live Monitor (GWT app inside #liveMonitorData). The GWT CellTable and clean
 * theme hard-code white/light row backgrounds; in dark mode the inherited text
 * turns light -> light-on-white (unreadable). GWT's CSS class names are
 * obfuscated per compile, so scope generic overrides to the stable container id
 * and win with !important. (The reason balloon lives on <body>, not here.) */
[data-bs-theme="dark"] #liveMonitorData table td{
	background-color: var(--xeams-surface) !important;
	background-image: none !important;
	color: #dfe3ea !important;
	border-color: var(--xeams-border) !important;
}
/* Belt-and-suspenders: GWT sets even/odd/hover/keyboard/selected backgrounds on
 * the <tr> (#fff / #f3f7fb / #eee / #ffc / #628cd5). Force both the row and its
 * cells dark so no light state (hover or selection) leaks through. */
[data-bs-theme="dark"] #liveMonitorData table tbody tr{
	background-color: var(--xeams-surface) !important;
}
[data-bs-theme="dark"] #liveMonitorData table tbody tr:nth-child(even),
[data-bs-theme="dark"] #liveMonitorData table tbody tr:nth-child(even) td{
	background-color: #262b34 !important;
}
[data-bs-theme="dark"] #liveMonitorData table tbody tr:hover,
[data-bs-theme="dark"] #liveMonitorData table tbody tr:hover td{
	background-color: #2b313b !important;
}
[data-bs-theme="dark"] #liveMonitorData table th{
	background-color: #2b313b !important;
	background-image: none !important;
	color: #eef1f6 !important;
	border-color: var(--xeams-border) !important;
}
/* GWT controls: refresh-rate box and Apply/Pause buttons */
[data-bs-theme="dark"] #liveMonitorData .gwt-TextBox{
	background-color: var(--xeams-surface);
	color: #dfe3ea;
	border: 1px solid var(--xeams-border);
}
[data-bs-theme="dark"] #liveMonitorData .gwt-Button{
	background: #2b313b;
	color: #dfe3ea;
	border: 1px solid var(--xeams-border);
}
[data-bs-theme="dark"] #liveMonitorData .gwt-Button:hover{ background: #353c48; }

/* Header dark/light mode toggle button (sits in the top header bar) */
.xeams-mode-toggle{
	border: 0;
	background: transparent;
	color: var(--xeams-on-primary, #fff);
	font-size: 1.1rem;
	line-height: 1;
	padding: 0 0.35rem;
	margin-top: 4px;
	cursor: pointer;
	opacity: 0.85;
}
.xeams-mode-toggle:hover{ opacity: 1; }