/* ============================================================
   ozon 管理后台 · UI 增强层 v1  (2026-11-28)
   统一承接：移动端适配 / 骨架屏 / Toast / 排序指示 / 深色模式 / 表格易读性
   依赖：dd.css(Tailwind) + shell.css(设计变量)
   ============================================================ */

/* ---------- 1. 骨架屏 ---------- */
@keyframes oz-shimmer { 0%{background-position:-468px 0} 100%{background-position:468px 0} }
.oz-skel{
  background:#eef1f5;
  background-image:linear-gradient(90deg,#eef1f5 0px,#f6f8fb 40px,#eef1f5 80px);
  background-size:468px 100%; background-repeat:no-repeat;
  border-radius:6px; animation:oz-shimmer 1.3s linear infinite;
}
.oz-skel-line{height:12px;margin:9px 0;}
.oz-skel-row{display:flex;gap:12px;align-items:center;padding:11px 13px;border-top:1px solid #f1f3f6;}
.oz-skel-row:first-child{border-top:none;}
.oz-skel-tbl{padding:0;overflow:hidden;}

/* ---------- 2. Toast 提示 ---------- */
#ozToastWrap{position:fixed;top:16px;right:16px;z-index:9999;display:flex;flex-direction:column;gap:10px;
  pointer-events:none;max-width:min(92vw,420px);}
.oz-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;padding:12px 14px;border-radius:10px;
  background:#fff;box-shadow:0 6px 24px rgba(16,24,40,.14),0 2px 6px rgba(16,24,40,.08);
  border-left:4px solid #6b7280;font-size:13px;line-height:1.5;color:#1f2328;
  animation:oz-slide-in .22s cubic-bezier(.2,.8,.3,1);}
.oz-toast.ok{border-left-color:#16a34a;}
.oz-toast.err{border-left-color:#dc2626;}
.oz-toast.warn{border-left-color:#d97706;}
.oz-toast.info{border-left-color:#005bff;}
.oz-toast .oz-ti{font-size:15px;line-height:1.2;flex:0 0 auto;}
.oz-toast .oz-tt{flex:1;min-width:0;word-break:break-word;}
.oz-toast .oz-tc{cursor:pointer;opacity:.4;font-size:16px;line-height:1;flex:0 0 auto;background:none;border:0;padding:0 2px;color:inherit;}
.oz-toast .oz-tc:hover{opacity:.9;}
.oz-toast.hide{animation:oz-slide-out .2s ease forwards;}
@keyframes oz-slide-in{from{opacity:0;transform:translateX(24px)}to{opacity:1;transform:none}}
@keyframes oz-slide-out{to{opacity:0;transform:translateX(24px)}}

/* ---------- 3. 可排序表头 ---------- */
th.oz-sortable{cursor:pointer;user-select:none;position:relative;padding-right:22px!important;}
th.oz-sortable:hover{background:#eef2f7!important;}
th.oz-sortable::after{content:"⇅";position:absolute;right:7px;top:50%;transform:translateY(-50%);
  opacity:.28;font-size:11px;line-height:1;}
th.oz-sortable.oz-asc::after{content:"▲";opacity:.85;color:#005bff;font-size:9px;}
th.oz-sortable.oz-desc::after{content:"▼";opacity:.85;color:#005bff;font-size:9px;}

/* ---------- 4. 表格移动端可读性 ---------- */
/* 窄屏时冻结关键列，横向滚动也不会丢失上下文 */
#tableScroll table{min-width:0;}
@media (max-width:900px){
  #tableScroll{max-height:none!important;}
  #tableScroll tbody td,#tableScroll thead th{padding:9px 10px!important;font-size:12px!important;}
  #tableScroll thead tr:first-child th{white-space:nowrap;}
  #tableScroll td.oz-freeze,#tableScroll th.oz-freeze{
    position:sticky;left:0;z-index:4;background:#fff;
    box-shadow:2px 0 4px -2px rgba(16,24,40,.12);}
  #tableScroll thead th.oz-freeze{background:#f5f7fa;z-index:7;}
  #tableScroll tbody tr:nth-child(even) td.oz-freeze{background:#fbfcfe;}
  #tableScroll tbody tr:hover td.oz-freeze{background:#fafcff;}
  /* 表格两侧渐隐，提示还能左右滑 */
  #tableScroll{background:
    linear-gradient(90deg,#fff 30%,rgba(255,255,255,0)) left/24px 100% no-repeat,
    linear-gradient(270deg,#fff 30%,rgba(255,255,255,0)) right/24px 100% no-repeat,
    #fff;}
}

/* ---------- 5. 表单/按钮触控友好（手机上不点空） ---------- */
@media (max-width:640px){
  .oz-tap{min-height:40px;}
  input,select,textarea{font-size:16px!important;}   /* 防 iOS 聚焦时自动放大 */
}

/* ---------- 6. 深色模式（跟随系统，可手动覆盖） ---------- */
@media (prefers-color-scheme:dark){
  html.oz-auto-dark,html.oz-auto-dark body{background:#0f1419!important;color:#e6e9ee!important;}
  html.oz-auto-dark .oz-dark-surface,
  html.oz-auto-dark .bg-white{background:#171d24!important;}
  html.oz-auto-dark .border-gray-100,html.oz-auto-dark .border-gray-200{border-color:#262e38!important;}
  html.oz-auto-dark .text-\[\#111827\],html.oz-auto-dark .text-\[\#0f172a\],
  html.oz-auto-dark .text-\[\#152238\]{color:#e6e9ee!important;}
  html.oz-auto-dark .text-gray-400,html.oz-auto-dark .text-gray-500{color:#8b93a1!important;}
  html.oz-auto-dark .bg-gray-50{background:#1c232b!important;}
  html.oz-auto-dark .bg-gray-100{background:#222a33!important;}
  html.oz-auto-dark .oz-skel{background:#1e252d;
    background-image:linear-gradient(90deg,#1e252d 0,#252d37 40px,#1e252d 80px);}
  html.oz-auto-dark .oz-toast{background:#1c232b;color:#e6e9ee;
    box-shadow:0 6px 24px rgba(0,0,0,.5);}
  html.oz-auto-dark #tableScroll thead th{background:#1c232b!important;color:#8b93a1!important;}
  html.oz-auto-dark #tableScroll tbody td{background:transparent!important;color:#e6e9ee!important;}
}
/* 手动切深色 */
html.oz-dark body{background:#0f1419!important;color:#e6e9ee!important;}
html.oz-dark .bg-white{background:#171d24!important;}
html.oz-dark .border-gray-100,html.oz-dark .border-gray-200{border-color:#262e38!important;}
html.oz-dark .text-\[\#111827\],html.oz-dark .text-\[\#0f172a\],html.oz-dark .text-\[\#152238\]{color:#e6e9ee!important;}
html.oz-dark .text-gray-400,html.oz-dark .text-gray-500{color:#8b93a1!important;}
html.oz-dark .bg-gray-50{background:#1c232b!important;}
html.oz-dark .bg-gray-100{background:#222a33!important;}
html.oz-dark #tableScroll thead th{background:#1c232b!important;color:#8b93a1!important;}
html.oz-dark #tableScroll tbody td{background:transparent!important;color:#e6e9ee!important;}
html.oz-dark .oz-toast{background:#1c232b;color:#e6e9ee;}

/* ---------- 7. 打印友好 ---------- */
@media print{
  #appShell,.app-sb,header,#ozToastWrap,.oz-noprint{display:none!important;}
  #tableScroll{max-height:none!important;overflow:visible!important;}
  body{background:#fff!important;}
}

/* ---------- 8. 无障碍：键盘焦点可见 ---------- */
:where(a,button,input,select,textarea,[tabindex]):focus-visible{
  outline:2px solid #005bff;outline-offset:2px;border-radius:6px;}
