/* Premium admin visual layer. UI only, no business behavior. */
/* v2 — refined for professional clarity */
:root {
  --adm-bg: #f5f6f8;
  --adm-surface: #ffffff;
  --adm-surface-soft: #f9fafb;
  --adm-text: #1a1d23;
  --adm-muted: #6b7280;
  --adm-line: #e5e7eb;
  --adm-line-soft: #f0f1f3;
  --adm-primary: #0f766e;
  --adm-primary-hover: #0d6b63;
  --adm-primary-soft: rgba(15, 118, 110, 0.08);
  --adm-accent: #d97706;
  --adm-accent-hover: #b95f05;
  --adm-accent-soft: rgba(217, 119, 6, 0.08);
  --adm-danger: #dc2626;
  --adm-sidebar: #0c1524;
  --adm-sidebar-soft: #132240;
  --adm-radius-sm: 8px;
  --adm-radius: 12px;
  --adm-radius-lg: 16px;
  --adm-shadow: 0 1px 3px rgba(16, 24, 40, 0.04), 0 1px 2px rgba(16, 24, 40, 0.03);
  --adm-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --adm-header-h: 54px;
  --adm-content-x: 24px;
  --adm-content-y: 20px;
}

html,
body {
  background: var(--adm-bg) !important;
  color: var(--adm-text);
  font-family: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.layui-layout-body,
.layui-native-shell,
.layui-standard-main,
.layui-native-body,
.layui-body,
main {
  background: transparent !important;
}

/* ── Scroll lock: body fixed to viewport, main scrolls internally ── */
body:not(.admin-embed-page) {
  background: #e2e6ea !important;
  height: 100vh;
  overflow: hidden;
}

body:not(.admin-embed-page) aside.layui-native-sidebar {
  height: 100vh !important;
}

body:not(.admin-embed-page) main,
body:not(.admin-embed-page) .layui-body,
body:not(.admin-embed-page) .layui-native-body {
  height: 100vh !important;
  min-height: 0 !important;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 0 !important;
}

body:not(.admin-embed-page) .layui-native-body > header {
  flex: 0 0 auto;
}

body:not(.admin-embed-page) .layui-native-body > section,
body:not(.admin-embed-page) .layui-native-body > div:not(.quote-fixed-header) {
  flex: 0 0 auto;
}

/* ── Sidebar ── */
.layui-native-sidebar,
aside {
  background: linear-gradient(175deg, var(--adm-sidebar-soft) 0%, var(--adm-sidebar) 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
  box-shadow: none !important;
}

.layui-native-sidebar .layui-side-scroll {
  border-right: 0 !important;
}

.layui-native-sidebar .p-6.flex.items-center {
  min-height: 56px !important;
  padding: 12px 16px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent !important;
}

.layui-native-sidebar .p-6.flex.items-center .iconify {
  filter: none !important;
}

.layui-native-sidebar .brand-text,
.layui-native-sidebar .p-6.flex.items-center .text-xl.font-bold {
  font-size: 16px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
}

#sidebar-nav-host .layui-nav {
  padding: 8px 10px 10px !important;
}

#sidebar-nav-host .layui-nav-item-group {
  padding: 16px 12px 6px !important;
  color: #5a6988 !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase;
}

#sidebar-nav-host .layui-nav-item {
  padding: 0 !important;
  margin: 1px 0 !important;
}

#sidebar-nav-host .layui-nav-item > a {
  height: 38px !important;
  line-height: 38px !important;
  border-radius: 9px !important;
  padding: 0 12px !important;
  gap: 10px !important;
  color: #b4c0d4 !important;
  font-weight: 500 !important;
  border: 1px solid transparent !important;
  transition: background-color .14s ease, color .14s ease, border-color .14s ease !important;
}

#sidebar-nav-host .layui-nav-item > a:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #e2e8f0 !important;
  transform: none !important;
}

#sidebar-nav-host .layui-nav-item.layui-this > a,
#sidebar-nav-host .layui-nav-item.layui-this > a:hover {
  background: rgba(15, 118, 110, 0.18) !important;
  border-color: rgba(15, 118, 110, 0.3) !important;
  color: #5eeadb !important;
  box-shadow: none !important;
}

#sidebar-nav-host .menu-icon {
  font-size: 17px !important;
  width: 17px !important;
  min-width: 17px !important;
}

.sidebar-toggle-btn {
  border-radius: 8px !important;
}

body.layui-native-collapsed #sidebar-nav-host .layui-nav-item > a {
  justify-content: center !important;
}

/* ── Top bar ── */
main > header,
.layui-body > header,
.layui-native-body > header {
  min-height: var(--adm-header-h) !important;
  height: auto !important;
  padding: 10px var(--adm-content-x) !important;
  border-bottom: 1px solid var(--adm-line) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(8px);
  box-shadow: none !important;
}

main > header h1,
main > header h2,
.layui-body > header h1,
.layui-body > header h2,
.layui-native-body > header h1,
.layui-native-body > header h2 {
  color: var(--adm-text) !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.01em;
}

body:not(.admin-embed-page) main > section:not(#quote-editor-layout),
body:not(.admin-embed-page) .layui-body > section:not(#quote-editor-layout),
body:not(.admin-embed-page) .layui-native-body > section:not(#quote-editor-layout) {
  margin: 0 !important;
  padding: 12px var(--adm-content-x) 24px !important;
  background: #ffffff !important;
}

body:not(.admin-embed-page) .layui-native-body > header + section:not(#quote-editor-layout),
body:not(.admin-embed-page) .layui-native-body > header + div:not(.quote-fixed-header) {
  margin-top: 0 !important;
}

body:not(.admin-embed-page) main.layui-native-body.p-6,
body:not(.admin-embed-page) main.layui-native-body.p-8,
body:not(.admin-embed-page) main.layui-native-body[class*=" p-6"],
body:not(.admin-embed-page) main.layui-native-body[class*=" p-8"] {
  padding-top: 12px !important;
}

body:not(.admin-embed-page) main > section.max-w-7xl,
body:not(.admin-embed-page) main > section[class*="max-w-"] {
  max-width: none !important;
}

body:not(.admin-embed-page) main > section > :first-child,
body:not(.admin-embed-page) .layui-body > section > :first-child,
body:not(.admin-embed-page) .layui-native-body > section > :first-child {
  margin-top: 0 !important;
}

body:not(.admin-embed-page) main > section:first-of-type,
body:not(.admin-embed-page) .layui-body > section:first-of-type,
body:not(.admin-embed-page) .layui-native-body > section:first-of-type {
  margin-top: 0 !important;
}

body:not(.admin-embed-page) main > section > * + *,
body:not(.admin-embed-page) .layui-body > section > * + *,
body:not(.admin-embed-page) .layui-native-body > section > * + * {
  margin-top: 16px !important;
}

/* ── Embedded workbench pages ── */
body.admin-embed-page {
  background: var(--adm-bg) !important;
}

body.admin-embed-page main,
body.admin-embed-page .layui-body,
body.admin-embed-page .layui-native-body {
  background: var(--adm-bg) !important;
}

body.admin-embed-page:not(.admin-embed-keep-header) main,
body.admin-embed-page:not(.admin-embed-keep-header) .layui-body,
body.admin-embed-page:not(.admin-embed-keep-header) .layui-native-body {
  top: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding-top: 0 !important;
  margin-top: 0 !important;
}

body.admin-embed-page main > section:not(#quote-editor-layout),
body.admin-embed-page .layui-body > section:not(#quote-editor-layout),
body.admin-embed-page .layui-native-body > section:not(#quote-editor-layout) {
  padding: 16px 18px 20px !important;
}

body.admin-embed-page:not(.admin-embed-keep-header) main > section:not(#quote-editor-layout),
body.admin-embed-page:not(.admin-embed-keep-header) .layui-body > section:not(#quote-editor-layout),
body.admin-embed-page:not(.admin-embed-keep-header) .layui-native-body > section:not(#quote-editor-layout) {
  margin-top: 0 !important;
  padding-top: 8px !important;
}

body.admin-embed-page.admin-embed-keep-header main > section#quote-editor-layout {
  padding: calc(var(--adm-header-h) + 12px) 18px 20px !important;
}

body.admin-embed-page:not(.admin-embed-keep-header) main > section > :first-child,
body.admin-embed-page:not(.admin-embed-keep-header) .layui-body > section > :first-child,
body.admin-embed-page:not(.admin-embed-keep-header) .layui-native-body > section > :first-child {
  margin-top: 0 !important;
}

/* ── Cards ── */
main .bg-white.border,
main .bg-white.rounded-2xl,
main .bg-white.rounded-xl,
main .bg-white.rounded-lg,
main .layui-native-card,
main .layui-standard-card,
.layui-body .bg-white.border,
.layui-native-body .bg-white.border {
  background: var(--adm-surface) !important;
  border: 1px solid var(--adm-line) !important;
  border-radius: var(--adm-radius) !important;
  box-shadow: none !important;
}

main .shadow-sm,
main .shadow,
main .shadow-md,
main .shadow-lg,
main .shadow-xl {
  box-shadow: var(--adm-shadow) !important;
}

main .rounded-2xl {
  border-radius: var(--adm-radius-lg) !important;
}

main .rounded-xl {
  border-radius: var(--adm-radius) !important;
}

main .rounded-lg {
  border-radius: var(--adm-radius-sm) !important;
}

main .border-gray-50,
main .border-gray-100,
main .border-slate-100,
main .border-slate-200,
main .border-slate-300 {
  border-color: var(--adm-line) !important;
}

main .bg-slate-50,
main .bg-gray-50 {
  background-color: var(--adm-surface-soft) !important;
}

/* ── Form controls ── */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="tel"],
select,
textarea,
.layui-input,
.layui-select,
.layui-textarea {
  min-height: 36px;
  border: 1px solid var(--adm-line) !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: var(--adm-text) !important;
  box-shadow: none !important;
}

textarea {
  min-height: 74px;
}

input:focus,
select:focus,
textarea:focus,
.layui-input:focus,
.layui-textarea:focus {
  border-color: rgba(15, 118, 110, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1) !important;
  outline: none !important;
}

label,
main .text-slate-500,
main .text-gray-500,
main .text-gray-400,
main .text-slate-400 {
  color: var(--adm-muted) !important;
}

/* ── Buttons ── */
button,
.layui-btn,
a.layui-btn,
main a[class*="px-"][class*="py-"],
main button[class*="px-"][class*="py-"] {
  border-radius: 8px !important;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease !important;
}

button:hover,
main a[class*="px-"][class*="py-"]:hover,
main button[class*="px-"][class*="py-"]:hover {
  transform: none !important;
}

main .bg-orange-500,
main .hover\:bg-orange-600:hover,
.layui-btn,
.layui-btn-normal {
  background-color: var(--adm-accent) !important;
  border-color: var(--adm-accent) !important;
}

main .bg-slate-900,
main .hover\:bg-slate-800:hover {
  background-color: var(--adm-primary) !important;
  border-color: var(--adm-primary) !important;
}

main .text-orange-600,
main .text-orange-700 {
  color: var(--adm-accent) !important;
}

main .bg-orange-50 {
  background-color: var(--adm-accent-soft) !important;
}

main .border-orange-100,
main .border-orange-200,
main .border-orange-300 {
  border-color: rgba(217, 119, 6, 0.2) !important;
}

main .text-emerald-500,
main .text-emerald-600,
main .text-emerald-700 {
  color: var(--adm-primary) !important;
}

main .bg-emerald-50 {
  background-color: var(--adm-primary-soft) !important;
}

/* ── Tables ── */
main table,
.layui-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: var(--adm-surface) !important;
  font-size: 13.5px;
}

main thead,
main thead tr,
.layui-table thead tr {
  background: #f8f9fb !important;
}

main th,
main td,
.layui-table th,
.layui-table td {
  border-bottom: 1px solid var(--adm-line-soft) !important;
  padding: 10px 16px !important;
  color: var(--adm-text);
}

main th,
.layui-table th {
  color: #697586 !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  letter-spacing: 0.02em;
  text-transform: none;
}

main tbody tr:hover td,
.layui-table tbody tr:hover td {
  background: #f9fafb !important;
}

main .overflow-x-auto {
  border-radius: var(--adm-radius);
  border: 1px solid var(--adm-line);
}

/* ── Status tags ── */
.layui-badge,
main [class*="rounded-full"],
main [class*="rounded-md"][class*="text-xs"],
main [class*="rounded-lg"][class*="text-xs"] {
  border-radius: 999px !important;
}

main [class*="text-xs"][class*="font-bold"],
main [class*="text-xs"][class*="font-semibold"] {
  letter-spacing: 0.01em;
  font-weight: 500 !important;
}

/* ── Filter / action bars ── */
main section.bg-white.border,
main div.bg-white.border:has(input),
main div.bg-white.border:has(select),
main div.bg-white.border:has(button) {
  border-radius: var(--adm-radius) !important;
  border-color: var(--adm-line) !important;
}

main section.bg-white.border:has(input),
main section.bg-white.border:has(select),
main div.bg-white.border:has(input),
main div.bg-white.border:has(select) {
  background: var(--adm-surface) !important;
}

/* ── Quote editor ── */
.quote-fixed-header {
  left: 260px !important;
  min-height: var(--adm-header-h) !important;
  height: var(--adm-header-h) !important;
  padding: 8px 18px !important;
}

body.layui-native-collapsed .quote-fixed-header {
  left: 78px !important;
}

body.admin-embed-page .quote-fixed-header {
  left: 0 !important;
}

body:not(.admin-embed-page) .quote-fixed-header + section#quote-editor-layout {
  padding: calc(var(--adm-header-h) + 12px) 18px 20px !important;
}

#product-picker-launcher {
  border: 1px solid rgba(217, 119, 6, 0.2) !important;
  background: #ffffff !important;
  box-shadow: none !important;
}

#quote-product-picker-column > .bg-white {
  border-color: var(--adm-line) !important;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.06) !important;
}

#quote-product-picker-column .quote-product-card {
  border: 1px solid var(--adm-line-soft) !important;
  box-shadow: none !important;
}

#quote-product-picker-column .quote-product-card:hover {
  border-color: rgba(15, 118, 110, 0.3) !important;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.08) !important;
}

#quote-product-picker-column .quote-product-price {
  color: var(--adm-primary) !important;
}

@media (max-width: 1024px) {
  .quote-fixed-header,
  body.layui-native-collapsed .quote-fixed-header {
    left: 0 !important;
  }

  body:not(.admin-embed-page) main > section:not(#quote-editor-layout),
  body:not(.admin-embed-page) .layui-body > section:not(#quote-editor-layout),
  body:not(.admin-embed-page) .layui-native-body > section:not(#quote-editor-layout) {
    padding: 12px 12px 18px !important;
  }
}

/* ── Workbench tabs ── */
.workbench-tabbar {
  height: 42px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border-bottom: 1px solid var(--adm-line) !important;
  box-shadow: none !important;
}

#workbench-tabs {
  padding-left: 12px !important;
}

#workbench-tabs .wb-tab {
  height: 38px !important;
  margin-top: 4px;
  padding: 0 14px !important;
  border-right: 0 !important;
  border-radius: 10px 10px 0 0 !important;
  background: transparent !important;
  font-size: 13px !important;
}

#workbench-tabs .wb-tab.active {
  color: var(--adm-text) !important;
  background: #ffffff !important;
  border-bottom: 2px solid var(--adm-primary) !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}

#workbench-frames > iframe {
  background: var(--adm-bg) !important;
}

/* ── Login ── */
body:has(#login-form) {
  background:
    linear-gradient(150deg, #f0f5f4 0%, #f8fafb 50%, #f3f6f8 100%) !important;
}

body:has(#login-form)::before {
  display: none;
}

body:has(#login-form) .max-w-md > .bg-white {
  border: 1px solid var(--adm-line) !important;
  box-shadow: 0 4px 24px rgba(16, 24, 40, 0.06) !important;
  border-radius: 20px !important;
}

body:has(#login-form) input {
  min-height: 44px;
}

body:has(#login-form) button[type="submit"] {
  background: var(--adm-primary) !important;
  box-shadow: none !important;
}

/* ── Page entrance animation ── */
@keyframes adminFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main > section:not(#quote-editor-layout) > *,
body:has(#login-form) .max-w-md > .bg-white {
  animation: adminFadeIn .18s ease both;
}

#quote-editor-layout > * {
  animation: none !important;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
