/* ================================================================
   EKOMSPACE ADMIN SHELL — Design System
   All classes prefixed ek- to avoid Tailwind/Avo conflicts
   ================================================================ */

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --ek-bg:        #fbfaf9;
  --ek-surface:   #ffffff;
  --ek-surface-2: #f5f4f3;
  --ek-line:      #e7e5e4;
  --ek-ink:       #0c0a09;
  --ek-ink-2:     #44403c;
  --ek-ink-3:     #78716c;
  --ek-ink-4:     #a8a29e;
  --ek-purple:    #5b3df5;
  --ek-purple-bg: #efeafe;
  --ek-purple-dk: #3b22c2;
  --ek-r:         8px;
  --ek-font:      "Inter", ui-sans-serif, system-ui, sans-serif;
  --ek-mono:      "Geist Mono", "SF Mono", ui-monospace, monospace;
  --ek-shadow:    0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.07);
}

/* ================================================================
   TOPBAR
   ================================================================ */
.ek-topbar {
  position: fixed !important;
  top: 0; left: 0; right: 0;
  height: 64px;
  z-index: 10020;
  display: flex !important;
  align-items: center;
  background: var(--ek-surface) !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  font-family: var(--ek-font);
}

/* Keep divider only under center/right area (not under left store switcher) */
.ek-topbar::after {
  content: "";
  position: absolute;
  left: 256px;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ek-line);
}

/* Left: store picker slot — 256px, matches sidebar width */
.ek-topbar-left {
  width: 256px;
  flex: none;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid var(--ek-line);
}

/* Center: search — fills remaining space */
.ek-topbar-center {
  flex: 1;
  min-width: 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* Keep search compact like admin_new_design instead of full-width */
.ek-topbar-center > * {
  width: 100%;
  max-width: 360px;
  flex: none;
}

/* Right: user */
.ek-topbar-right {
  flex: none;
  padding: 0 16px;
  display: flex;
  align-items: center;
}

/* ── Store Picker ───────────────────────────────────────────────── */
.ek-store-picker {
  position: relative;
  width: 100%;
}
.ek-store-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  background: var(--ek-surface-2);
  border: 1px solid var(--ek-line);
  border-radius: var(--ek-r);
  cursor: pointer;
  font-family: var(--ek-font);
  text-align: left;
  transition: background .12s, border-color .12s;
}
.ek-store-btn:hover {
  background: var(--ek-surface);
  border-color: #ddd9d7;
}
.ek-store-picker:not([data-controller]) .ek-store-btn {
  cursor: default;
}
.ek-store-picker:not([data-controller]) .ek-store-chev {
  opacity: .55;
}
.ek-store-favicon {
  width: 26px; height: 26px;
  border-radius: 6px;
  object-fit: cover;
  flex: none;
}
.ek-store-badge {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #5b3df5, #7c5cf7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex: none;
}
.ek-store-info { flex: 1; min-width: 0; }
.ek-store-name {
  font-size: 12.5px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ek-ink);
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ek-store-domain {
  font-size: 10.5px; color: var(--ek-ink-3);
  font-family: var(--ek-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ek-store-chev { color: var(--ek-ink-3); flex: none; }

.ek-store-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  min-width: 220px;
  background: var(--ek-surface);
  border: 1px solid var(--ek-line);
  border-radius: var(--ek-r);
  box-shadow: var(--ek-shadow);
  padding: 6px;
  z-index: 10030;
}
.ek-store-menu.hidden { display: none !important; }
.ek-store-menu-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ek-ink-4);
  padding: 4px 8px 6px;
}
.ek-store-menu-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  transition: background .10s;
  cursor: pointer;
}
.ek-store-menu-row:hover { background: var(--ek-surface-2); }
.ek-store-menu-row.ek-active { background: var(--ek-purple-bg); }
.ek-store-check { color: var(--ek-purple); flex: none; }
.ek-store-menu-sep {
  height: 1px;
  background: var(--ek-line);
  margin: 6px 0;
}
.ek-store-menu-row.ek-create-store .ek-store-name {
  color: var(--ek-purple);
}
.ek-store-badge.ek-store-badge-create {
  background: #fafafa;
  color: var(--ek-ink-3);
  border: 1px dashed var(--ek-line);
}

/* ── Search (override Avo GlobalSearchComponent) ────────────────── */
.ek-topbar-center .global-search {
  width: 100% !important;
  max-width: 360px !important;
  min-width: 0 !important;
  background: var(--ek-surface-2) !important;
  border: 1px solid var(--ek-line) !important;
  border-radius: var(--ek-r) !important;
  height: 34px !important;
  padding: 0 12px !important;
  display: flex !important;
  align-items: center !important;
  transition: border-color .12s, background .12s, box-shadow .12s !important;
}
.ek-topbar-center .global-search:focus-within {
  background: var(--ek-surface) !important;
  border-color: var(--ek-purple) !important;
  box-shadow: 0 0 0 3px rgba(91,61,245,.12) !important;
}

/* Fallback safety when Avo changes internal classnames */
.ek-topbar-center [data-controller*="search"],
.ek-topbar-center form[action*="search"],
.ek-topbar-center .relative.flex {
  width: 100%;
  max-width: 360px;
}
/* Hide the Avo kbd button since we display it ourselves */
.ek-topbar-center .global-search [data-search-target="button"] {
  right: 8px !important;
  font-size: 10px !important;
  color: var(--ek-ink-3) !important;
  background: var(--ek-surface) !important;
  border-color: var(--ek-line) !important;
  border-radius: 4px !important;
  padding: 1px 5px !important;
}
/* The autocomplete input injected by Stimulus */
.ek-topbar-center .global-search input {
  font-family: var(--ek-font) !important;
  font-size: 12.5px !important;
  color: var(--ek-ink) !important;
}
.ek-topbar-center .global-search input::placeholder {
  color: var(--ek-ink-3) !important;
}

/* Fallback search (when GlobalSearchComponent not available) */
.ek-search-fallback {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 34px;
  background: var(--ek-surface-2);
  border: 1px solid transparent;
  border-radius: var(--ek-r);
  padding: 0 12px;
  cursor: text;
  transition: border-color .12s, background .12s;
}
.ek-search-fallback:focus-within {
  background: var(--ek-surface);
  border-color: var(--ek-purple);
  box-shadow: 0 0 0 3px rgba(91,61,245,.12);
}
.ek-search-fallback svg { color: var(--ek-ink-3); flex: none; }
.ek-search-fallback input {
  flex: 1; border: 0 !important; outline: 0 !important; background: transparent !important;
  font-size: 12.5px; color: var(--ek-ink); font-family: var(--ek-font);
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
}
.ek-search-fallback input:focus,
.ek-search-fallback input:active,
.ek-search-fallback input:focus-visible {
  outline: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
.ek-search-fallback input::placeholder { color: var(--ek-ink-3); }
.ek-search-fallback .ek-search-clear {
  display: none;
  border: 0;
  background: transparent;
  color: var(--ek-ink-3);
  width: 20px;
  height: 20px;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 999px;
  transition: background .12s, color .12s;
}
.ek-search-fallback .ek-search-clear svg {
  width: 12px;
  height: 12px;
  display: block;
}
.ek-search-fallback .ek-search-clear:hover {
  background: #e7e5e4;
  color: var(--ek-ink-2);
}
.ek-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--ek-surface);
  border: 1px solid var(--ek-line);
  border-radius: 12px;
  box-shadow: var(--ek-shadow);
  z-index: 135;
  overflow: hidden;
}
.ek-search-dropdown-status {
  font-size: 11px;
  color: var(--ek-ink-3);
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--ek-line);
}
.ek-search-dropdown-results {
  max-height: 360px;
  overflow: auto;
  padding: 8px;
}
.ek-search-group + .ek-search-group {
  margin-top: 10px;
}
.ek-search-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ek-ink-4);
  padding: 0 4px 6px;
}
.ek-search-group-items {
  display: grid;
  gap: 4px;
}
.ek-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background .12s, transform .12s;
}
.ek-search-item:hover,
.ek-search-item.is-selected {
  background: var(--ek-purple-bg);
}
.ek-search-item-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.ek-search-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ek-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ek-search-item-subtitle,
.ek-search-item-meta {
  font-size: 11.5px;
  color: var(--ek-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ek-search-item-meta {
  flex: none;
  padding-left: 8px;
}
.ek-search-dropdown-status:empty {
  display: none;
}
.ek-search-fallback.is-focused .ek-kbd,
.ek-search-fallback:focus-within .ek-kbd,
.ek-search-fallback.has-value .ek-kbd {
  display: none;
}
.ek-search-fallback.has-value .ek-search-clear {
  display: inline-flex;
}
.ek-kbd {
  font-family: var(--ek-mono);
  font-size: 10px; color: var(--ek-ink-3);
  background: var(--ek-surface);
  border: 1px solid var(--ek-line);
  padding: 1px 5px; border-radius: 4px;
  flex: none;
}

/* ── User Dropdown ──────────────────────────────────────────────── */
.ek-user-wrap { position: relative; }
.ek-user-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 0 5px 5px;
  background: transparent;
  border: 0;
  border-radius: var(--ek-r);
  cursor: pointer;
  font-family: var(--ek-font);
  font-size: 12.5px; color: var(--ek-ink); font-weight: 500;
  transition: background .12s;
}
.ek-user-btn:hover { background: transparent; }
.ek-user-btn svg { color: var(--ek-ink-3); }
.ek-user-name { letter-spacing: -0.01em; }
.ek-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ek-purple);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  font-family: var(--ek-font);
  flex: none;
}
.ek-avatar--lg { width: 36px; height: 36px; font-size: 14px; }

.ek-user-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  width: 260px;
  background: var(--ek-surface);
  border: 1px solid var(--ek-line);
  border-radius: var(--ek-r);
  box-shadow: var(--ek-shadow);
  padding: 6px;
  z-index: 130;
}

.ek-user-menu.hidden { display: none !important; }
.ek-user-menu-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 10px;
}
.ek-user-menu-name { font-size: 13px; font-weight: 600; color: var(--ek-ink); }
.ek-user-menu-email { font-size: 11.5px; color: var(--ek-ink-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ek-sep { height: 1px; background: var(--ek-line); margin: 4px 0; }

.ek-menu-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  font-family: var(--ek-font); font-size: 12.5px; font-weight: 500;
  color: var(--ek-ink); text-decoration: none;
  cursor: pointer; text-align: left;
  transition: background .10s;
  box-shadow: none !important;
}
.ek-menu-row:hover { background: var(--ek-surface-2); }
.ek-menu-row svg { color: var(--ek-ink-3); flex: none; }
.ek-menu-row .ek-menu-hint {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--ek-ink-3);
}
.ek-menu-row--ai svg { color: var(--ek-purple); }
.ek-menu-row--danger { color: #dc2626; }
.ek-menu-row--danger:hover { background: #fee2e2; }
.ek-menu-row--danger svg { color: #dc2626; }
.ek-menu-row-form { display: block; width: 100%; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.ek-side-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--ek-surface);
  border-right: 1px solid var(--ek-line);
  font-family: var(--ek-font);
  overflow: hidden;
}

/* Scrollable nav body */
.ek-side-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--ek-line) transparent;
}

/* Nav group */
.ek-navgroup { margin-bottom: 8px; }
.ek-navlabel {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ek-ink-4);
  padding: 6px 10px 3px;
  user-select: none;
}
.ek-navlabel-action {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: var(--ek-ink-3); text-decoration: none; text-transform: uppercase;
  padding: 2px 5px; border-radius: 4px;
  transition: color .15s, background .15s;
}
.ek-navlabel-action:hover { color: var(--ek-ink-2); background: var(--ek-surface-2); }

/* Nav item */
.ek-nav {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--ek-r);
  background: transparent;
  border: 0;
  color: var(--ek-ink-2);
  font-size: 12.5px; font-weight: 500; letter-spacing: -0.01em;
  cursor: pointer; text-decoration: none; font-family: var(--ek-font);
  text-align: left;
  transition: background .10s, color .10s;
}
.ek-nav-ico { color: var(--ek-ink-3); display: flex; flex: none; }
.ek-nav-grow { flex: 1; }
.ek-nav-badge {
  font-size: 10px; font-weight: 600; padding: 1px 6px;
  border-radius: 999px;
  background: var(--ek-purple-bg); color: var(--ek-purple-dk);
}
.ek-nav:hover {
  background: var(--ek-surface-2);
}
.ek-nav:hover .ek-nav-ico { color: var(--ek-ink-2); }
/* active state — force override any Avo/Tailwind rules */
.ek-nav.active,
.ek-nav[aria-current="page"] {
  background: var(--ek-purple-bg) !important;
  border: 0 !important;
  color: var(--ek-purple-dk) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
.ek-nav.active .ek-nav-ico,
.ek-nav[aria-current="page"] .ek-nav-ico { color: var(--ek-purple) !important; }

/* Sidebar footer */
.ek-side-footer {
  flex: none; padding: 8px 10px 12px;
  border-top: 0;
}
.ek-powered {
  padding: 8px 4px 4px;
  margin-top: 6px;
  border-top: 1px solid var(--ek-line);
  display: flex;
  align-items: center;
  gap: 7px;
}
.ek-powered-label {
  font-size: 10.5px;
  color: var(--ek-ink-3);
  font-weight: 400;
}
.ek-powered img {
  height: 15px;
  width: auto;
  opacity: .82;
}

/* SVG icon helper */
.ek-ico {
  display: block; flex: none;
  fill: none; stroke: currentColor;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ================================================================
   OVERRIDE: cancel old custom.css sidebar gradient/border-left
   ================================================================ */
.avo-sidebar .ek-nav.active,
.avo-sidebar .ek-nav[aria-current="page"] {
  background: var(--ek-purple-bg) !important;
  border: 0 !important;
  border-left: 0 !important;
  color: var(--ek-purple-dk) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
  background-image: none !important;
}
.avo-sidebar .ek-nav.active .ek-nav-ico,
.avo-sidebar .ek-nav[aria-current="page"] .ek-nav-ico {
  color: var(--ek-purple) !important;
}
.avo-sidebar .ek-nav:not(.active):not([aria-current="page"]):hover {
  background: var(--ek-surface-2) !important;
  background-image: none !important;
  border: 0 !important;
  border-left: 0 !important;
  color: var(--ek-ink-2) !important;
}

/* ================================================================
   OVERRIDE: reset button/form styles for ek-menu-row inside forms
   ================================================================ */
.ek-menu-row-form button,
.ek-menu-row-form button:hover,
.ek-menu-row-form button:focus,
.ek-menu-row-form button:active {
  all: unset;
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px;
  border-radius: 6px;
  font-family: var(--ek-font); font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-align: left;
  box-sizing: border-box;
}
.ek-menu-row-form .ek-menu-row--danger { color: #dc2626; }
.ek-menu-row-form .ek-menu-row--danger:hover { background: #fee2e2; }
