@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,300;0,400;0,600;0,700;1,300&family=Nunito+Sans:wght@300;400;600&family=Share+Tech+Mono&display=swap');
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ─── Design Tokens ─────────────────────────────── */
:root {
    --bg-base:          #eef2f8;
    --bg-surface:       #f7f9fc;
    --bg-card:          #ffffff;
    --bg-elevated:      #edf1f8;
    --bg-hover:         #e4ecf7;

    --blue:             #0366d6;
    --blue-deep:        #0450a8;
    --blue-light:       #dbeafe;
    --blue-glow:        rgba(3, 102, 214, 0.18);

    --red:              #b91c1c;
    --red-bright:       #dc2626;
    --red-light:        #fee2e2;
    --red-glow:         rgba(185, 28, 28, 0.15);

    --green:            #059669;
    --green-bright:     #10b981;
    --green-light:      #d1fae5;
    --green-glow:       rgba(16, 185, 129, 0.22);

    --yellow:           #d97706;
    --yellow-bright:    #f59e0b;

    --text:             #1e3a5c;
    --text-body:        #344e6e;
    --text-muted:       #6383a0;
    --text-dim:         #94afc7;

    --border:           #cddaea;
    --border-mid:       #bed0e4;
    --border-strong:    #9ab4cc;

    --font-ui:          'Exo 2', 'Trebuchet MS', sans-serif;
    --font-body:        'Nunito Sans', 'Gill Sans', Calibri, sans-serif;
    --font-mono:        'Share Tech Mono', 'Courier New', monospace;

    --radius-sm:        4px;
    --radius:           8px;
    --radius-lg:        12px;
    --ease:             0.18s ease;

    --shadow-sm:        0 1px 4px rgba(30, 58, 92, 0.08), 0 1px 2px rgba(30, 58, 92, 0.06);
    --shadow:           0 4px 16px rgba(30, 58, 92, 0.1), 0 1px 4px rgba(30, 58, 92, 0.06);
    --shadow-lg:        0 12px 40px rgba(30, 58, 92, 0.14), 0 2px 8px rgba(30, 58, 92, 0.08);
}

/* ─── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-body);
    margin: 0;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a, .btn-link {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--ease);
}
a:hover { color: var(--blue-deep); }

/* ─── App Shell ─────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 70% 45% at 0% 0%, rgba(3, 102, 214, 0.05) 0%, transparent 55%),
        radial-gradient(ellipse 55% 40% at 100% 100%, rgba(185, 28, 28, 0.04) 0%, transparent 55%),
        var(--bg-base);
}

/* ─── App Header ────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    height: 58px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    flex-shrink: 0;
    z-index: 10;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--red)  0%,
        transparent 16%,
        var(--blue) 32%,
        var(--blue) 50%,
        var(--blue) 68%,
        transparent 84%,
        var(--red)  100%
    );
    opacity: 0.55;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-name {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--blue);
}

.brand-sub {
    font-family: var(--font-ui);
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.header-live {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.07);
}

.live-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green-glow);
    animation: pulse-live 2.2s ease-in-out infinite;
    flex-shrink: 0;
}

.live-text {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--green);
    line-height: 1;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%       { opacity: 0.35; transform: scale(0.8); }
}

/* ─── Main & Content ────────────────────────────── */
.app-main { flex: 1; overflow-x: hidden; }

.content {
    padding: 1.5rem 2rem;
    animation: fade-up 0.3s ease both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Dashboard Section Header ──────────────────── */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    gap: 0.75rem;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-bar {
    width: 3px;
    height: 22px;
    background: linear-gradient(180deg, var(--blue) 0%, var(--red) 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

.section-title {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
}

.section-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 9px;
    border-radius: 12px;
    border: 1px solid var(--border-mid);
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* ─── Buttons ────────────────────────────────────── */
.e-btn, .btn-primary {
    font-family: var(--font-ui) !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    letter-spacing: 0.07em !important;
    text-transform: uppercase !important;
    color: #fff !important;
    background: var(--blue) !important;
    border: 1px solid var(--blue-deep) !important;
    border-radius: var(--radius-sm) !important;
    padding: 7px 16px !important;
    transition: background var(--ease), box-shadow var(--ease) !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

.e-btn:hover, .btn-primary:hover, a.button:hover {
    background: var(--red) !important;
    border-color: var(--red-bright) !important;
    box-shadow: 0 2px 10px var(--red-glow) !important;
}

/* ─── Status Dots ───────────────────────────────── */
.status-dot {
    font-size: 16px;
    text-align: center;
    line-height: 1.4;
    filter: drop-shadow(0 0 4px currentColor);
}

/* ─── Metric Values ──────────────────────────────── */
.metric-value {
    font-family: var(--font-mono);
    font-size: 13px;
    text-align: center;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* ─── No-data message ────────────────────────────── */
.no-data-msg {
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-ui);
    padding: 2rem;
}

/* ─── Grid Wrapper (mobile scroll) ──────────────── */
.grid-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

/* ─── Syncfusion Grid ────────────────────────────── */
.e-grid {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-mid) !important;
    border-radius: var(--radius) !important;
    overflow: hidden !important;
    font-family: var(--font-body) !important;
    box-shadow: var(--shadow) !important;
}

.e-headercell {
    background: var(--bg-elevated) !important;
    color: var(--blue-deep) !important;
    font-family: var(--font-ui) !important;
    font-weight: 700 !important;
    font-size: 10.5px !important;
    letter-spacing: 0.09em !important;
    text-transform: uppercase !important;
    border-left: 1px solid var(--border) !important;
    border-bottom: 2px solid var(--red) !important;
}

.e-headercelldiv {
    vertical-align: middle !important;
    display: table-cell !important;
    line-height: 100% !important;
    white-space: normal !important;
}

.e-grid .e-row td, .e-grid td.e-rowcell {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-body) !important;
    font-family: var(--font-body) !important;
    transition: background var(--ease) !important;
}

.e-grid .e-altrow td, .e-grid .e-altrow td.e-rowcell {
    background: var(--bg-surface) !important;
}

.e-grid .e-row:hover td, .e-grid .e-row:hover td.e-rowcell {
    background: var(--bg-hover) !important;
}

.e-grid .e-selectionbackground,
.e-grid .e-selectionbackground td,
.e-grid .e-selectionbackground td.e-rowcell {
    background: var(--blue-light) !important;
    border-color: rgba(3, 102, 214, 0.2) !important;
}

.e-grid th.e-headercell[aria-sort="ascending"] .e-headertext,
.e-grid th.e-headercell[aria-sort="descending"] .e-headertext,
.e-grid th.e-headercell[aria-sort="ascending"] .e-sortfilterdiv,
.e-grid th.e-headercell[aria-sort="descending"] .e-sortfilterdiv {
    color: var(--blue) !important;
    opacity: 1;
}

.e-grid .e-gridcontent .e-groupcaption {
    background: var(--blue-light) !important;
    color: var(--blue-deep) !important;
}

/* Grid Toolbar */
.e-toolbar {
    background: var(--bg-elevated) !important;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
}

.e-toolbar .e-btn {
    background: transparent !important;
    border: 1px solid var(--border-mid) !important;
    color: var(--text-body) !important;
    text-transform: uppercase !important;
    font-size: 11px !important;
    letter-spacing: 0.06em !important;
}

.e-toolbar .e-btn:hover {
    background: var(--blue) !important;
    border-color: var(--blue) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px var(--blue-glow) !important;
}

/* ─── Syncfusion Tabs ────────────────────────────── */
.e-tab .e-tab-header .e-tab-text {
    color: var(--text-muted) !important;
    font-family: var(--font-ui) !important;
}

.e-tab .e-tab-header .e-toolbar-item.e-active .e-tab-text,
.e-tab .e-tab-header .e-toolbar-item.e-active .e-tab-icon {
    color: var(--red) !important;
    font-size: 1.1em !important;
}

.e-tab .e-tab-header .e-toolbar-item .e-tab-wrap:hover {
    background: var(--red-light) !important;
}

/* ─── Syncfusion Toast ───────────────────────────── */
.e-toast-container .e-toast {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-mid) !important;
    border-left: 3px solid var(--blue) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
}

.e-toast-container .e-toast .e-toast-message .e-toast-title {
    color: var(--blue-deep) !important;
    font-family: var(--font-ui) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}

.e-toast-container .e-toast .e-toast-message .e-toast-content {
    color: var(--text-body) !important;
    font-size: 13px !important;
}

.e-toast-container .e-toast .e-toast-icon {
    color: var(--red) !important;
    font-size: 1.5em !important;
}

/* ─── Syncfusion Dialog ──────────────────────────── */
.e-dialog {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
}

.e-dialog .e-dlg-header-content {
    background: var(--bg-elevated) !important;
    border-bottom: 1px solid var(--border-mid) !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

.e-dialog .e-dlg-header {
    color: var(--text) !important;
    font-family: var(--font-ui) !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
}

.e-dialog .e-dlg-content { color: var(--text-body) !important; }

.e-footer-content {
    background: var(--bg-elevated) !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
}

/* ─── Form Elements ──────────────────────────────── */
.e-input-group, .e-input-group.e-control-wrapper {
    background: var(--bg-card) !important;
    border-color: var(--border-mid) !important;
    border-radius: var(--radius-sm) !important;
}

.e-input, .e-textbox {
    background: var(--bg-card) !important;
    color: var(--text) !important;
    font-family: var(--font-body) !important;
}

.e-input-group:not(.e-float-icon-left):not(.e-float-input)::before,
.e-input-group:not(.e-float-icon-left):not(.e-float-input)::after {
    background: var(--blue) !important;
}

label.e-label-top, .e-float-text {
    color: var(--text-muted) !important;
    font-family: var(--font-ui) !important;
    font-size: 11px !important;
    letter-spacing: 0.07em !important;
    text-transform: uppercase !important;
}

/* ─── Subtitle (legacy) ─────────────────────────── */
.subtitle {
    color: var(--text);
    background: var(--bg-elevated);
    border-left: 3px solid var(--red);
    padding: 8px 14px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ─── Headings (legacy) ─────────────────────────── */
h1, h2, h3 {
    color: var(--blue) !important;
    font-family: var(--font-ui) !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em !important;
    padding-bottom: 0.75rem;
}

/* ─── Table (tg) ────────────────────────────────── */
.tg {
    border-collapse: collapse;
    border-color: var(--border-mid);
    border-spacing: 0;
}

.tg td {
    background: var(--bg-card);
    border-color: var(--border-mid);
    border-style: solid;
    border-width: 1px;
    color: var(--text-body);
    overflow: hidden;
    padding: 10px 5px;
    word-break: normal;
}

.tg th {
    background: var(--blue);
    border-color: var(--border-mid);
    border-style: solid;
    border-width: 1px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #fff;
    overflow: hidden;
    padding: 10px 5px;
    word-break: normal;
    width: 30%;
}

.tg .tg-0lax { text-align: left; vertical-align: top; }

/* ─── Utilities ─────────────────────────────────── */
.outer { display: grid; grid-template: 1fr / 1fr; }
.outer > * { grid-column: 1/1; grid-row: 1/1; }
.outer .stack-bottom { top: 0; left: 0; z-index: 8; }
.outer .stack-top { margin-top: 20px; margin-left: 10px; width: 50px; height: 50px; z-index: 9; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--green); }
.invalid { outline: 1px solid var(--red); }
.validation-message { color: var(--red); }

/* ─── Blazor Error UI ────────────────────────────── */
#blazor-error-ui {
    background: #fffbeb;
    bottom: 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 2px solid var(--yellow);
    color: var(--yellow);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    color: var(--yellow);
}

/* ─── Header Actions ────────────────────────────── */
.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ─── Server Tile Grid ───────────────────────────── */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
    padding-bottom: 1.5rem;
}

/* ─── Server Card ────────────────────────────────── */
.server-card {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--ease), transform var(--ease);
}

.server-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.server-card--online::before  { background: var(--green); }
.server-card--offline::before { background: var(--red); }

.server-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

/* Card header row */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.card-online-dot {
    font-size: 15px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px currentColor);
    line-height: 1;
}

.card-name {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

/* Card icon buttons */
.card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.card-btn {
    background: none;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 8px;
    font-size: 11px;
    line-height: 1;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.card-btn:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.card-btn--danger:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

/* Metrics 2×2 grid */
.card-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

.metric-badge {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 9px;
    text-align: center;
    flex: 1;
    min-width: 58px;
}

/* Inline gauge inside a badge */
.gauge-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.gauge-track {
    flex: 1;
    height: 6px;
    background: var(--bg-base);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
    min-width: 0;
}

.gauge-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.7s ease;
}

.gauge-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    min-width: 34px;
    text-align: right;
    line-height: 1;
}

.metric-lbl {
    font-family: var(--font-ui);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    line-height: 1.2;
}

.metric-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

/* Status text */
.card-status-text {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 0 2px;
}

.status-line {
    display: block;
    line-height: 1.5;
}

/* Card footer */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
    margin-top: auto;
    gap: 0.5rem;
}

.card-host {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.card-updated {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─── Dialog Form ────────────────────────────────── */
.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.25rem 0 0.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.delete-confirm-msg {
    margin: 0;
    color: var(--text-body);
    font-size: 14px;
    line-height: 1.5;
}

.delete-confirm-msg strong {
    color: var(--text);
}

/* ─── Mobile ────────────────────────────────────── */
@media (max-width: 640px) {
    .app-header {
        padding: 0 1rem;
        height: 52px;
    }

    .brand-glyph { font-size: 17px; }
    .brand-name  { font-size: 13px; letter-spacing: 0.05em; }
    .brand-sub   { display: none; }

    .content, article.content {
        padding: 0.85rem 0.75rem !important;
    }

    .dashboard-header {
        flex-wrap: wrap;
        margin-bottom: 0.65rem;
    }

    .section-count { display: none; }
    .section-title { font-size: 12px; }

    .header-actions { gap: 0.4rem; }

    .e-btn, .btn-primary {
        padding: 7px 10px !important;
        font-size: 10px !important;
    }

    /* Single-column tiles on phones */
    .server-grid {
        grid-template-columns: 1fr;
    }

    /* Dialogs: full width on phones */
    .e-dialog {
        width: 94vw !important;
        max-width: 94vw !important;
        left: 3vw !important;
    }
}

/* ─── Tablet tweaks ─────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
    .content, article.content {
        padding: 1.25rem 1.25rem !important;
    }
}
