/* ===========================================================
 * UWCSEA Admin —— 仅在 ?edit=KEY 时通过 body.uwc-admin 启用
 * =========================================================== */

/* ---- 主入口：给 admin 页面让出顶部空间 ---- */
body.uwc-admin { padding-top: 60px; }
body.uwc-admin.uwc-side-open { padding-right: 380px; }

/* ---- 顶部 toolbar ---- */
.uwc-tb {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: #1F1F1F; color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; z-index: 9999;
  box-shadow: 0 1px 0 rgba(0,0,0,0.3);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
}
.uwc-tb-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; letter-spacing: 0.3px;
  padding-right: 16px; border-right: 1px solid #444;
}
.uwc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34A853;
  box-shadow: 0 0 6px #34A853;
  animation: uwc-pulse 1.6s ease-in-out infinite;
}
@keyframes uwc-pulse { 50% { opacity: 0.4; } }

.uwc-tb-actions { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.uwc-tb-status {
  font-size: 12px; padding: 4px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  max-width: 360px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.uwc-status-ok { color: #34A853; }
.uwc-status-warn { color: #FBBC04; }
.uwc-status-err { color: #EA4335; }

/* ---- 按钮 ---- */
.uwc-btn {
  background: transparent; border: 1px solid #444;
  color: inherit; padding: 6px 14px;
  border-radius: 6px; cursor: pointer;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.uwc-tb .uwc-btn { color: #fff; }
.uwc-modal .uwc-btn { color: #1F1F1F; border-color: #DADCE0; }
.uwc-btn:hover { background: rgba(255,255,255,0.08); border-color: #888; }
.uwc-btn-primary { background: #4285F4; border-color: #4285F4; color: #fff; }
.uwc-btn-primary:hover { background: #3367D6; border-color: #3367D6; }
.uwc-btn-primary.uwc-save-dirty {
  animation: uwc-save-pulse 1.2s ease-in-out infinite;
}
@keyframes uwc-save-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(66,133,244, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(66,133,244, 0); }
}
.uwc-btn-ghost { background: transparent; }
.uwc-btn-active { background: rgba(66,133,244, 0.25); border-color: #4285F4; color: #fff; }
.uwc-block { display: block; width: 100%; padding: 10px; margin-top: 12px; }

/* ---- 侧边栏 ---- */
.uwc-side {
  position: fixed; top: 56px; right: 0; bottom: 0;
  width: 380px; background: #fff;
  border-left: 1px solid #E0E0E0;
  transform: translateX(100%); transition: transform 0.25s ease;
  z-index: 9998; overflow-y: auto;
  padding: 20px;
}
body.uwc-side-open .uwc-side { transform: translateX(0); }
.uwc-side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid #E0E0E0;
}
.uwc-side-head h3 { margin: 0; font-size: 16px; font-weight: 500; }
.uwc-side-hint {
  font-size: 12px; color: #5F6368;
  margin: 12px 0 16px; line-height: 1.5;
}
.uwc-side-body { font-size: 13px; }
.uwc-side-sec { margin-bottom: 20px; }
.uwc-side-sec h4 {
  margin: 0 0 10px; font-size: 11px; font-weight: 500;
  color: #4285F4; text-transform: uppercase; letter-spacing: 0.05em;
}
.uwc-side-item { margin-bottom: 10px; }
.uwc-side-meta { font-size: 11px; color: #5F6368; margin-bottom: 4px; font-family: monospace; }
.uwc-side-item textarea {
  width: 100%; padding: 6px 8px;
  border: 1px solid #E0E0E0; border-radius: 4px;
  font: inherit; font-size: 13px;
  resize: vertical;
}
.uwc-side-item textarea:focus {
  outline: none; border-color: #4285F4; box-shadow: 0 0 0 2px rgba(66,133,244,0.15);
}

/* ---- inline edit mode ---- */
body.uwc-edit [data-page-node-id]:not(nav):not(.uwc-tb):not(.uwc-side):not(.uwc-modal) {
  cursor: text;
  position: relative;
  transition: background 0.1s;
}
body.uwc-edit [data-page-node-id]:hover {
  background: rgba(66,133,244,0.07);
  outline: 1px dashed #4285F4;
  outline-offset: 2px;
}
.uwc-inline-editor {
  width: 100%; min-height: 24px;
  padding: 4px 6px;
  border: 2px solid #4285F4;
  border-radius: 3px;
  font: inherit; color: inherit;
  background: rgba(255,255,255,0.95);
  outline: none;
}
.uwc-dirty { background: rgba(251,188,4,0.12) !important; }

/* ---- modal ---- */
.uwc-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 10000;
}
.uwc-modal-open { display: flex; }
.uwc-modal-card {
  background: #fff; border-radius: 12px;
  width: 520px; max-width: 92vw; max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.uwc-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #E0E0E0;
}
.uwc-modal-head h3 { margin: 0; font-size: 16px; font-weight: 500; }
.uwc-modal-body { padding: 20px; }
.uwc-field { display: block; margin-bottom: 16px; font-size: 13px; }
.uwc-field > span {
  display: block; font-size: 12px; color: #5F6368;
  margin-bottom: 6px; font-weight: 500;
}
.uwc-field select {
  width: 100%; padding: 8px 10px;
  border: 1px solid #E0E0E0; border-radius: 4px;
  background: #fff; font: inherit;
}
.uwc-field select:focus { outline: none; border-color: #4285F4; }

.uwc-drop {
  border: 2px dashed #DADCE0;
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  color: #5F6368;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.uwc-drop:hover, .uwc-drop-hot {
  border-color: #4285F4;
  background: rgba(66,133,244,0.04);
}
.uwc-drop p { margin: 0; font-size: 14px; line-height: 1.6; }
.uwc-drop small { color: #9AA0A6; }

.uwc-file-list { margin-top: 12px; }
.uwc-file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: #F8F9FA; border-radius: 4px;
  font-size: 12px; margin-bottom: 4px;
}
.uwc-file-row small { color: #5F6368; }
.uwc-file-row .uwc-file-del {
  margin-left: auto; cursor: pointer; color: #EA4335;
  font-weight: bold;
}
.uwc-file-row .uwc-file-del:hover { color: #C5221F; }

/* ---- 媒体管理面板 ---- */
.uwc-media-card {
  width: min(1080px, 94vw);
  height: min(680px, 88vh);
  display: flex; flex-direction: column;
}
.uwc-media-card .uwc-modal-head { flex: none; }
.uwc-media-body { flex: 1; display: flex; min-height: 0; }
.uwc-media-side {
  width: 230px; flex: none; overflow-y: auto;
  border-right: 1px solid #E0E0E0; padding: 10px;
}
.uwc-mfolder {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 4px;
  background: transparent; border: none; border-radius: 6px;
  font: inherit; font-size: 12.5px; color: #1F1F1F; cursor: pointer;
}
.uwc-mfolder:hover { background: #F1F3F4; }
.uwc-mfolder.active { background: #E8F0FE; color: #174EA6; font-weight: 500; }
.uwc-mfolder-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.uwc-mfolder-cnt {
  flex: none; margin-left: 8px; font-size: 11px;
  background: #E0E0E0; color: #3C4043;
  border-radius: 10px; padding: 1px 7px;
}
.uwc-mfolder.active .uwc-mfolder-cnt { background: #C6DAFC; color: #174EA6; }
.uwc-media-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.uwc-media-toolbar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; border-bottom: 1px solid #E0E0E0;
  font-size: 12px; color: #5F6368;
}
.uwc-media-grid {
  flex: 1; overflow-y: auto; padding: 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; align-content: start;
}
.uwc-mtile {
  position: relative; border-radius: 8px; overflow: hidden;
  background: #F1F3F4; aspect-ratio: 1 / 1; cursor: grab;
  border: 2px solid transparent;
}
.uwc-mtile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.uwc-mtile.is-video { background: #202124; }
.uwc-mtile.is-video::after {
  content: '▶'; position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.85); color: #1A73E8;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; pointer-events: none;
}
.uwc-mtile .uwc-mname {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 6px 4px; font-size: 9.5px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.uwc-mtile .uwc-mdel {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: rgba(234,67,53,0.92); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.uwc-mtile .uwc-mdel:hover { background: #C5221F; }
.uwc-mtile.dragging { opacity: 0.45; }
.uwc-mtile.drag-over { border-color: #4285F4; }
.uwc-media-hint {
  flex: none; margin: 0; padding: 10px 20px;
  border-top: 1px solid #E0E0E0;
  font-size: 11.5px; color: #5F6368; line-height: 1.5;
}
.uwc-media-hint code {
  background: #F1F3F4; border-radius: 3px; padding: 1px 5px; font-size: 11px;
}

/* ---- 响应式：手机 ---- */
@media (max-width: 700px) {
  .uwc-tb { padding: 0 12px; gap: 6px; height: 52px; }
  .uwc-tb-brand { display: none; }
  .uwc-tb-actions .uwc-btn { padding: 5px 10px; font-size: 12px; }
  .uwc-tb-status { display: none; }
  body.uwc-admin { padding-top: 52px; }
  body.uwc-admin.uwc-side-open { padding-right: 0; }
  .uwc-side { width: 100%; top: 52px; }
  .uwc-modal-card { width: 100%; max-width: 100vw; max-height: 100vh; height: 100%; border-radius: 0; }
  .uwc-media-card { height: 100%; }
  .uwc-media-body { flex-direction: column; }
  .uwc-media-side {
    width: 100%; max-height: 140px;
    border-right: none; border-bottom: 1px solid #E0E0E0;
    display: flex; flex-wrap: wrap; gap: 4px;
  }
  .uwc-mfolder { width: auto; }
}