/* MBO Smart Home — styling.
   First part (theme variables + .mbo-* component classes) is a 1:1 port of the original Axon Ivy
   project's webContent/resources/css/mbo.css. Second part (below "Utilities & resets") is new:
   the original relied on PrimeFlex (grid/flex/spacing classes) and PrimeFaces component chrome
   (.ui-inputtext, .ui-dialog, native <button>/<a> resets) that came bundled with the Ivy runtime —
   neither exists outside it, so those are reimplemented here as a small utility layer. */

.mbo-app {
  --page-bg: #faf9f6;
  --card-bg: #fefefd;
  --text: #23272b;
  --text-muted: #6b7278;
  --border: #ececea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
  --nav-pill-bg: #f4f3ef;
  --accent: #2e8b4f;
  --tag-on-bg: #e6f4ea;
  --tag-on-fg: #276b3d;

  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.mbo-app.mbo-theme-dark {
  --page-bg: #24262a;
  --card-bg: #2c2f34;
  --text: #f1f2f3;
  --text-muted: #a4a9ae;
  --border: #3c4046;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --nav-pill-bg: #34383e;
  --accent: #55c47f;
  --tag-on-bg: #2c4433;
  --tag-on-fg: #8fdba9;
}

body { margin: 0; background: var(--page-bg, #faf9f6); }

.mbo-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
  box-sizing: border-box;
}

.mbo-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.mbo-logo-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  position: relative;
  flex: none;
  cursor: pointer;
  display: inline-block;
}

.mbo-logo-dot-outer {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  top: 6px;
  left: 6px;
  box-sizing: border-box;
}

.mbo-logo-dot-inner {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  bottom: 6px;
  right: 6px;
}

.mbo-brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  cursor: pointer;
}

.mbo-darkmode-label {
  font-size: 12px;
  color: var(--text-muted);
}

.mbo-toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: transparent;
  flex: none;
  padding: 0;
  font: inherit;
}

.mbo-toggle-track.mbo-on {
  border-color: var(--accent);
  background: var(--tag-on-bg);
}

.mbo-toggle-knob {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  background: var(--text-muted);
  transition: left .15s;
}

.mbo-toggle-track.mbo-on .mbo-toggle-knob {
  left: 18px;
  background: var(--accent);
}

.mbo-breadcrumb {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.mbo-breadcrumb .mbo-crumb-link {
  cursor: pointer;
  color: var(--text-muted);
}

.mbo-breadcrumb .mbo-crumb-current {
  color: var(--text);
  font-weight: 600;
}

.mbo-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
}

.mbo-tile-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--nav-pill-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mbo-tile-icon-wrap.mbo-accent-bg {
  background: var(--tag-on-bg);
}

.mbo-tile-icon-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--text-muted);
  display: inline-block;
}

.mbo-tile-icon-dot.mbo-accent {
  background: var(--accent);
}

.mbo-tile-name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-top: 16px;
}

.mbo-tile-badge {
  display: inline-flex;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--nav-pill-bg);
  color: var(--text-muted);
  margin-top: 12px;
}

.mbo-placeholder-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 56px 40px;
  box-shadow: var(--shadow);
  text-align: center;
}

.mbo-placeholder-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--nav-pill-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.mbo-placeholder-title {
  font-weight: 800;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 8px;
}

.mbo-placeholder-text {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}

.mbo-nav {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 28px;
}

.mbo-nav-item {
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding-bottom: 6px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
}

.mbo-nav-item.mbo-active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.mbo-hub-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.mbo-hub-dot.mbo-hub-off {
  background: #d9534f;
}

.mbo-hub-label {
  font-size: 11px;
  color: var(--text-muted);
}

.mbo-section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--text-muted);
}

.mbo-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  height: 100%;
  box-sizing: border-box;
}

.mbo-card-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.mbo-card-name {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  cursor: pointer;
  color: var(--text);
  display: inline-block;
}

.mbo-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--nav-pill-bg);
  color: var(--text-muted);
}

.mbo-tag.mbo-on {
  background: var(--tag-on-bg);
  color: var(--tag-on-fg);
}

.mbo-primary-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
}

.mbo-secondary-label {
  font-size: 13px;
  color: var(--text-muted);
}

.mbo-card-footer {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 10px;
}

.mbo-room-name {
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  display: inline-block;
}

.mbo-button {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  color: #fff !important;
  background: var(--accent) !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 9px 16px !important;
  cursor: pointer;
  text-decoration: none;
}

.mbo-config-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.mbo-config-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.mbo-config-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mbo-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.mbo-status-dot.mbo-off {
  background: #d9534f;
}

.mbo-detail-back {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-bottom: 16px;
  display: inline-block;
}

.mbo-detail-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
  color: var(--text);
}

.mbo-detail-title-input {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  padding: 0 4px;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.mbo-detail-title-input:hover,
.mbo-detail-title-input:focus {
  border-color: var(--border);
  outline: none;
}

.mbo-detail-room {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.mbo-detail-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.mbo-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.mbo-detail-row:last-child {
  border-bottom: none;
}

.mbo-detail-row-label {
  color: var(--text-muted);
}

.mbo-detail-row-value {
  font-weight: 500;
  color: var(--text);
}

.mbo-link-reset {
  display: block;
  text-decoration: none;
  color: inherit;
}

.mbo-edit-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.mbo-icon-link {
  font-size: 15px;
  line-height: 1;
  color: var(--accent);
}

.mbo-dev-diagnostic {
  opacity: 0.6;
}

.mbo-config-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.mbo-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.mbo-lang-switcher {
  position: relative;
}

.mbo-lang-flag {
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  list-style: none;
}
.mbo-lang-flag::-webkit-details-marker { display: none; }

.mbo-lang-menu {
  position: absolute;
  top: 28px;
  right: 0;
  z-index: 10;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.mbo-lang-menu-item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.mbo-lang-menu-item:hover {
  background: var(--nav-pill-bg);
}

/* Modal-style dialogs (add/edit integration, add device) — plain server-rendered blocks (shown
   only when the relevant ?dialog=... query param is present), styled to overlay the page.
   Replaces PrimeFaces' <p:dialog>. */
.mbo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.mbo-dialog {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
}

.mbo-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
}

.mbo-dialog-body {
  padding: 20px;
}

/* Progress bars — native <progress>, replacing <p:progressBar>. */
.mbo-progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--nav-pill-bg);
}
.mbo-progress::-webkit-progress-bar { background: var(--nav-pill-bg); border-radius: 4px; }
.mbo-progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.mbo-progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }

/* Login screen */
.mbo-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.mbo-login-card { width: 100%; max-width: 360px; }

/* ===================== Utilities & resets (new — replace PrimeFlex + PrimeFaces chrome) ===================== */

.mbo-app * { box-sizing: border-box; }
.mbo-app a { color: inherit; text-decoration: none; }
.mbo-app button { cursor: pointer; }

.mbo-inline-form { display: inline-flex; margin: 0; }
.mbo-link-button {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
}

.mbo-app input[type="text"],
.mbo-app input[type="password"],
.mbo-app input[type="number"],
.mbo-app input[type="time"],
.mbo-app select {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page-bg);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.mbo-app input[type="checkbox"] { width: 18px; height: 18px; }

.w-full { width: 100%; }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }

.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }

.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1.5rem; }

/* 12-column grid, mirroring the subset of PrimeFlex's grid used by this app. */
.grid { display: flex; flex-wrap: wrap; margin: 0 -0.5rem; }
.grid > [class*="col-"] { padding: 0.5rem; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 768px) {
  .md\:col-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (min-width: 992px) {
  .lg\:col-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
  .lg\:col-5 { flex: 0 0 41.6667%; max-width: 41.6667%; }
  .lg\:col-7 { flex: 0 0 58.3333%; max-width: 58.3333%; }
  .lg\:col-8 { flex: 0 0 66.6667%; max-width: 66.6667%; }
}
