/* ============================================================================
   VUBEX SiteOps - Shared Component Library
   ----------------------------------------------------------------------------
   Single source of truth for reusable UI primitives (cards, buttons, status
   pills, empty states, toasts). All classes are prefixed `vx-` so they never
   collide with, override, or alter existing page-specific styles.

   Built on the design tokens declared in styles.css :root
   (--primary, --surface, --text-primary, --success, --error, --warning, ...).
   Pages should <link> this file and use these classes for new/consistent UI.
   ============================================================================ */

:root {
  --vx-radius: 14px;
  --vx-radius-sm: 10px;
  --vx-gap: 16px;
  --vx-shadow: 0 10px 30px rgba(5, 8, 20, 0.45);
  --vx-ring: 0 0 0 3px rgba(64, 224, 208, 0.25);
}

/* ----------------------------- Layout helpers ---------------------------- */
.vx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--vx-gap);
}
.vx-stack {
  display: flex;
  flex-direction: column;
  gap: var(--vx-gap);
}
.vx-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.vx-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.vx-muted { color: var(--text-secondary); }
.vx-divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 14px 0;
}

/* -------------------------------- Cards ---------------------------------- */
.vx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--vx-radius);
  padding: 18px;
  box-shadow: var(--vx-shadow);
  color: var(--text-primary);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.vx-card:hover {
  border-color: rgba(64, 224, 208, 0.4);
  transform: translateY(-2px);
}
.vx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.vx-card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 0;
}
.vx-card-body { color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; }
.vx-card.accent { border-color: rgba(108, 92, 231, 0.45); }
.vx-card.ok { border-color: rgba(0, 212, 170, 0.45); }
.vx-card.warn { border-color: rgba(255, 165, 2, 0.45); }
.vx-card.bad { border-color: rgba(255, 107, 107, 0.45); }

/* ------------------------------- Buttons -------------------------------- */
.vx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--vx-radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  color: var(--text-primary);
  background: var(--surface-light);
}
.vx-btn:hover { filter: brightness(1.08); }
.vx-btn:active { transform: translateY(1px); }
.vx-btn:focus-visible { outline: none; box-shadow: var(--vx-ring); }
.vx-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.vx-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #04121a;
  border-color: transparent;
}
.vx-btn.secondary {
  background: var(--surface-light);
  border-color: var(--border);
  color: var(--text-primary);
}
.vx-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.vx-btn.ghost:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.vx-btn.danger { background: var(--error); color: #1a0606; border-color: transparent; }
.vx-btn.sm { padding: 6px 10px; font-size: 12px; }
.vx-btn.lg { padding: 13px 22px; font-size: 15px; }

/* ----------------------------- Status pills ----------------------------- */
.vx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
}
.vx-pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.vx-pill.ok   { color: var(--success); background: rgba(0, 212, 170, 0.12); border-color: rgba(0, 212, 170, 0.35); }
.vx-pill.warn { color: var(--warning); background: rgba(255, 165, 2, 0.12); border-color: rgba(255, 165, 2, 0.35); }
.vx-pill.bad  { color: var(--error);   background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.35); }
.vx-pill.info { color: var(--primary); background: rgba(64, 224, 208, 0.12); border-color: rgba(64, 224, 208, 0.35); }
.vx-pill.muted { color: var(--text-secondary); background: rgba(168, 175, 196, 0.10); border-color: rgba(168, 175, 196, 0.25); }

/* ----------------------------- Empty states ----------------------------- */
.vx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--vx-radius);
  background: rgba(20, 26, 46, 0.4);
  color: var(--text-secondary);
}
.vx-empty-icon {
  font-size: 40px;
  color: var(--primary);
  opacity: 0.85;
}
.vx-empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 0; }
.vx-empty-text { font-size: 13.5px; max-width: 420px; margin: 0; line-height: 1.5; }
.vx-empty-action { margin-top: 6px; }

/* ------------------------------- Toasts --------------------------------- */
.vx-toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.vx-toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--vx-radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--text-primary);
  box-shadow: var(--vx-shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  animation: vx-toast-in 0.22s ease;
}
.vx-toast i { margin-top: 2px; }
.vx-toast.ok   { border-left: 3px solid var(--success); }
.vx-toast.warn { border-left: 3px solid var(--warning); }
.vx-toast.bad  { border-left: 3px solid var(--error); }
.vx-toast.info { border-left: 3px solid var(--primary); }
.vx-toast .vx-toast-msg { flex: 1; line-height: 1.4; }
.vx-toast-action {
  flex: 0 0 auto;
  margin-left: 10px;
  padding: 6px 12px;
  border-radius: var(--vx-radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #06121a;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.vx-toast-action:hover { filter: brightness(1.08); }
.vx-toast-action:active { transform: translateY(1px); }

@keyframes vx-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------- Skeleton loaders --------------------------- */
.vx-skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.10) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 400% 100%;
  animation: vx-shimmer 1.3s ease infinite;
  border-radius: var(--vx-radius-sm);
}
.vx-skeleton.line { height: 12px; margin: 8px 0; }
.vx-skeleton.block { height: 120px; }

@keyframes vx-shimmer {
   0%   { background-position: 100% 0; }
   100% { background-position: 0 0; }
}

/* ----------------------------- Command palette ----------------------------- */
.vx-palette {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.vx-palette.hidden { display: none; }
.vx-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 20, 0.55);
    backdrop-filter: blur(2px);
}
.vx-palette-box {
    position: relative;
    width: min(620px, 92vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--surface, #0d1326);
    border: 1px solid rgba(95, 149, 255, 0.25);
    border-radius: var(--vx-radius, 14px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    animation: vx-palette-in 0.16s ease;
}
@keyframes vx-palette-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.99); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.vx-palette-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(95, 149, 255, 0.16);
}
.vx-palette-input-row > i { color: var(--text-secondary, #9aa6c4); }
.vx-palette-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary, #eaf1ff);
    font-size: 15px;
    padding: 4px 0;
}
.vx-palette-kbd {
    font-size: 11px;
    color: var(--text-secondary, #9aa6c4);
    border: 1px solid rgba(159, 179, 217, 0.25);
    border-radius: 6px;
    padding: 2px 7px;
    text-transform: uppercase;
}
.vx-palette-list {
    overflow-y: auto;
    padding: 8px;
}
.vx-palette-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #9aa6c4);
}
.vx-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary, #eaf1ff);
}
.vx-palette-item-icon { width: 18px; text-align: center; color: var(--primary, #40e0d0); }
.vx-palette-item-title { flex: 1; font-size: 14px; }
.vx-palette-item-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary, #40e0d0);
    background: rgba(64, 224, 208, 0.12);
    border: 1px solid rgba(64, 224, 208, 0.3);
    border-radius: 999px;
    padding: 2px 8px;
}
.vx-palette-item.active { background: rgba(64, 224, 208, 0.12); }
.vx-palette-item.active .vx-palette-item-title { color: #fff; }
.vx-palette-empty {
    padding: 22px 14px;
    text-align: center;
    color: var(--text-secondary, #9aa6c4);
    font-size: 13.5px;
}
.vx-palette-help {
    padding: 14px 18px;
    border-top: 1px solid rgba(95, 149, 255, 0.16);
    background: rgba(10, 15, 31, 0.4);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-secondary, #cdd9f2);
    flex-shrink: 0;
    min-height: 0;
}
.vx-palette-help.hidden { display: none; }
.vx-palette-help-title { font-weight: 600; color: var(--text-primary, #eaf1ff); margin-bottom: 4px; }
.vx-palette-foot {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid rgba(95, 149, 255, 0.12);
    font-size: 11.5px;
    color: var(--text-secondary, #9aa6c4);
}
.vx-palette-foot b { color: var(--text-primary, #eaf1ff); }

/* ------------------------------- Nav tooltips ------------------------------- */
.nav-btn, .siteops-nav-btn, .workspace-nav-btn { position: relative; }
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    background: var(--surface-light, #16203c);
    color: var(--text-primary, #eaf1ff);
    border: 1px solid rgba(95, 149, 255, 0.25);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    z-index: 1200;
    animation: vx-toast-in 0.12s ease;
}
.workspace-nav-btn[data-tip]:hover::after,
.siteops-nav-btn[data-tip]:hover::after {
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%);
}
