/* BBJ Sense shared light theme -- matches UI design.png reference.
   Linked from every dashboard page. Do not duplicate these rules
   per-page; add page-specific rules in that page's own <style>. */

:root {

    --bg-page: #f6f6f4;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-input: #f9fafb;
    --bg-pill-active: #f0f0ef;

    --border-color: #e8e8e6;
    --border-color-strong: #d4d4d2;

    --text-primary: #18181b;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-label: #9ca3af;

    --accent: #18181b;
    --accent-hover: #27272a;
    --accent-text: #ffffff;

    --link: #2563eb;

    --success-bg: #dcfce7;
    --success-text: #16a34a;
    --warning-bg: #fef9c3;
    --warning-text: #ca8a04;
    --danger-bg: #fee2e2;
    --danger-text: #dc2626;
    --info-bg: #dbeafe;
    --info-text: #2563eb;
    --neutral-bg: #f1f5f9;
    --neutral-text: #475569;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --shadow-card: 0 1px 2px rgba(0,0,0,0.03), 0 1px 8px rgba(0,0,0,0.04);
    --shadow-popover: 0 8px 24px rgba(0,0,0,0.12);

    --sidebar-width: 240px;
    --topbar-height: 64px;

    /* Compatibility aliases -- several pages' inline JS sets
       style.background/color directly to these short names
       (var(--success), var(--danger), etc.), a convention carried
       over from the old dark theme. Keep them resolving correctly
       rather than hunting down every JS reference across every
       page. */
    --primary: var(--accent);
    --success: var(--success-text);
    --warning: var(--warning-text);
    --danger: var(--danger-text);
    --muted: var(--text-muted);
    --text: var(--text-primary);
    --border: var(--border-color);
    --panel: var(--bg-card);
    --panel-light: var(--bg-hover);
    --bg: var(--bg-page);

}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Shell: sidebar + topbar (admin.html) ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .gateway-text {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.brand-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
}

.menu-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-label);
    padding: 16px 8px 6px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 2px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--bg-pill-active);
    color: var(--text-primary);
    font-weight: 600;
}

.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
    font-size: 14px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: 12px;
}

.gateway-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success-text);
}

.status-dot.offline {
    background: var(--danger-text);
}

.gateway-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.gateway-status {
    font-size: 11px;
    color: var(--text-muted);
}

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

.topbar {
    height: var(--topbar-height);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.toggle-button {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: var(--text-secondary);
}

.page-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.server-status {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-hover);
}

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

#currentUser {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.logout-button {
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
}

.content {
    flex: 1;
    padding: 0;
    background: var(--bg-page);
}

.content iframe {
    width: 100%;
    height: calc(100vh - var(--topbar-height));
    border: none;
    display: block;
}

/* ---------- Shared components for content pages ---------- */

.page-wrap {
    padding: 24px 28px 48px;
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.back-link {
    font-size: 13px;
    color: var(--text-secondary);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 14px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-label);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-trend {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.stat-trend.up {
    color: var(--success-text);
}

.stat-trend.down {
    color: var(--danger-text);
}

/* Tables have no responsive layout of their own -- on a narrow
   screen a wide table would otherwise blow out .card and force the
   whole page to scroll sideways. Scoping overflow to the card lets
   just the table scroll horizontally instead. */
.card:has(table) {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-label);
    background: var(--bg-hover);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

tbody td {
    padding: 11px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.pill-success, .pill.enabled, .pill.online, .pill.sent, .pill.active {
    background: var(--success-bg);
    color: var(--success-text);
}

.pill-warning, .pill.pending, .pill.medium {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.pill-danger, .pill.disabled, .pill.offline, .pill.failed, .pill.critical, .pill.high {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.pill-info, .pill.low {
    background: var(--info-bg);
    color: var(--info-text);
}

.pill-neutral, .pill.closed {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger-text);
    border-color: var(--danger-text);
    color: #ffffff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* :where(...) keeps this whole selector at zero specificity, same
   as a plain `input` tag selector -- so any page's own simple
   `input,select,textarea{...}` override (several pages have one,
   e.g. a fixed width for compact inline forms) still wins, exactly
   like it did before this rule existed. Without :where(), the
   :not()s below add enough specificity to silently beat those
   page-level overrides, which is a real regression (found live:
   alarm-rules.html's fields went full-width while its <select>s
   stayed at the page's intended 220px).
   :not([type=checkbox]):not([type=radio]) rather than an explicit
   input[type=text] list -- a plain <input> with no type attribute
   at all (implicitly type=text) is common across these pages and
   was NOT matched by an input[type=text] attribute selector, since
   attribute selectors require the attribute to actually be present
   in the markup. That silently left untyped inputs at the browser's
   tiny default width next to full-width styled siblings. */
:where(input:not([type=checkbox]):not([type=radio])),
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--text-primary);
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 12px 0 5px;
}

::placeholder {
    color: var(--text-muted);
}
