/* Weio UI primitives — branded dialogs + toasts.
 * Self-contained: every var() has a fallback so this file works on any surface
 * (public product or tenant portal) regardless of which token set is loaded.
 * Pairs with weio-ui.js. */

#weio-ui-root { position: relative; z-index: 10000; }

/* ── Dialogs (alert/confirm/prompt/modal) ── */
.weio-dialog-overlay {
  position: fixed; inset: 0; background: rgba(26,24,20,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .16s ease; z-index: 10000;
}
.weio-dialog-overlay.show { opacity: 1; }
.weio-dialog {
  background: var(--color-surface, var(--surface, #ffffff));
  border: 1px solid var(--color-border, var(--border, #e8e3dc));
  border-radius: var(--radius-lg, 12px);
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  transform: translateY(8px) scale(.98); transition: transform .16s ease;
  overflow: hidden;
  font-family: var(--font-sans, system-ui, -apple-system, 'Segoe UI', sans-serif);
}
.weio-dialog-overlay.show .weio-dialog { transform: none; }
.weio-dialog-head {
  font-size: 1rem; font-weight: 700; padding: 20px 22px 0; letter-spacing: -.2px;
  color: var(--color-text-primary, var(--text, #1a1814));
}
.weio-dialog-body { padding: 14px 22px 4px; }
.weio-dialog-msg {
  font-size: .875rem; line-height: 1.6; margin: 0;
  color: var(--color-text-secondary, var(--text-soft, #6b6560));
}
.weio-dialog-body .form-control,
.weio-dialog-body .weio-prompt-input {
  width: 100%; margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--color-border, var(--border, #e8e3dc));
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface, var(--surface, #fff));
  color: var(--color-text-primary, var(--text, #1a1814));
  font-size: .875rem; outline: none;
}
.weio-dialog-body .weio-prompt-input:focus {
  border-color: var(--color-accent, var(--accent, #c4714a));
  outline: 2px solid rgba(196,113,74,.2);
}
.weio-dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px;
}

/* Buttons inside dialogs — work even if host page lacks .btn styles */
.weio-dialog-foot .btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius-md, 8px); font-size: .875rem;
  font-weight: 500; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s; line-height: 1;
}
.weio-dialog-foot .btn-primary {
  background: var(--color-accent, var(--accent, #c4714a)); color: #fff;
  border-color: var(--color-accent, var(--accent, #c4714a));
}
.weio-dialog-foot .btn-primary:hover {
  background: var(--color-accent-hover, var(--accent-h, #b5623b));
}
.weio-dialog-foot .btn-secondary {
  background: var(--color-surface, #fff);
  color: var(--color-text-secondary, var(--text, #6b6560));
  border-color: var(--color-border, var(--border, #e8e3dc));
}
.weio-dialog-foot .btn-secondary:hover {
  background: var(--color-surface-2, var(--surface2, #f5f3f0));
}
.weio-dialog-foot .btn-danger {
  background: var(--color-error, #c0392b); color: #fff; border-color: var(--color-error, #c0392b);
}
.weio-dialog-foot .btn-danger:hover { filter: brightness(.92); }
@media (max-width: 480px) { .weio-dialog { max-width: 100%; } }

/* ── Toasts ── */
#weio-toast-container, #toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 10001;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.weio-toast, .toast {
  background: var(--color-surface, var(--surface, #fff));
  border: 1px solid var(--color-border, var(--border, #e8e3dc));
  border-left-width: 4px;
  border-radius: var(--radius-md, 8px);
  padding: 12px 18px; font-size: .875rem;
  color: var(--color-text-primary, var(--text, #1a1814));
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.10));
  pointer-events: auto; max-width: 360px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.weio-toast.show, .toast.show { opacity: 1; transform: none; }
.weio-toast-success, .toast-success, .toast.success { border-left-color: var(--color-success, #2d7a4f); }
.weio-toast-error,   .toast-error,   .toast.error   { border-left-color: var(--color-error, #c0392b); }
.weio-toast-info,    .toast-info,    .toast.info    { border-left-color: var(--color-info, #2c6fad); }

/* ── Modern custom select ────────────────────────────────────────────────── */
.weio-select-native { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.weio-select { position: relative; display: inline-block; min-width: 150px; }
.weio-select-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 12px; cursor: pointer;
  background: var(--surface, #fff); color: var(--text, #1a1814);
  border: 1px solid var(--border, #e8e3dc); border-radius: var(--radius-md, 8px);
  font-family: inherit; font-size: 14px; text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.weio-select-btn:hover { border-color: var(--accent, #c8643c); }
.weio-select.open .weio-select-btn { border-color: var(--accent, #c8643c); box-shadow: 0 0 0 3px var(--accent-soft, rgba(200,100,60,.15)); }
.weio-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weio-select-caret { color: var(--text-sec, #6b6560); font-size: 11px; transition: transform .15s; flex-shrink: 0; }
.weio-select.open .weio-select-caret { transform: rotate(180deg); }
.weio-select.disabled { opacity: .55; pointer-events: none; }
.weio-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 400;
  background: var(--surface, #fff); border: 1px solid var(--border, #e8e3dc);
  border-radius: var(--radius-md, 10px); box-shadow: 0 12px 32px rgba(0,0,0,.16);
  padding: 5px; max-height: 280px; overflow-y: auto;
  animation: weioPop .12s ease;
}
/* Drop-up: open the menu above the button when there's no room below */
.weio-select.drop-up .weio-select-menu { top: auto; bottom: calc(100% + 6px); animation: weioPopUp .12s ease; }
@keyframes weioPop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes weioPopUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.weio-select-opt {
  padding: 9px 11px; border-radius: 7px; font-size: 14px; cursor: pointer;
  color: var(--text, #1a1814); display: flex; align-items: center; gap: 8px;
}
.weio-select-opt:hover { background: var(--accent-soft, rgba(200,100,60,.12)); }
.weio-select-opt.selected { color: var(--accent-h, #a44e2c); font-weight: 600; }
.weio-select-opt.selected::after { content: '✓'; margin-left: auto; color: var(--accent, #c8643c); }
.weio-select-opt.disabled { opacity: .45; pointer-events: none; }

/* ── Dropdown / context menu ──────────────────────────────────────────────── */
.weio-menu {
  position: fixed; z-index: 500; min-width: 180px;
  background: var(--surface, #fff); border: 1px solid var(--border, #e8e3dc);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 5px;
  animation: weioPop .12s ease;
}
.weio-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border: none; background: none; cursor: pointer;
  border-radius: 7px; font-family: inherit; font-size: 14px; color: var(--text, #1a1814);
}
.weio-menu-item:hover:not(:disabled) { background: var(--accent-soft, rgba(200,100,60,.12)); }
.weio-menu-item:disabled { opacity: .45; cursor: default; }
.weio-menu-item.danger { color: var(--error, #c0392b); }
.weio-menu-item.danger:hover { background: var(--error, #c0392b); color: #fff; }
.weio-menu-ico { display: inline-flex; width: 16px; justify-content: center; opacity: .8; }
.weio-menu-sep { height: 1px; background: var(--border, #e8e3dc); margin: 5px 6px; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.weio-segmented { display: inline-flex; background: var(--surface2, rgba(0,0,0,.04)); border: 1px solid var(--border, #e8e3dc); border-radius: 9px; padding: 3px; gap: 2px; }
.weio-segmented button {
  border: none; background: none; cursor: pointer; font-family: inherit; font-size: 13px;
  padding: 6px 14px; border-radius: 6px; color: var(--text-sec, #6b6560); transition: all .15s;
}
.weio-segmented button:hover { color: var(--text, #1a1814); }
.weio-segmented button.active { background: var(--surface, #fff); color: var(--accent-h, #a44e2c); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.weio-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.weio-switch input { opacity: 0; width: 0; height: 0; }
.weio-switch-track { position: absolute; inset: 0; background: var(--border, #cfc8be); border-radius: 999px; transition: background .18s; cursor: pointer; }
.weio-switch-track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.weio-switch input:checked + .weio-switch-track { background: var(--accent, #c8643c); }
.weio-switch input:checked + .weio-switch-track::before { transform: translateX(18px); }
