/* ============================
   地质勘探打孔水印系统 - 样式
   ============================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --bg: #f5f7fa;
  --card-bg: #fff;
  --border: #dde1e6;
  --text: #333;
  --text-secondary: #666;
  --text-hint: #999;
  --danger: #d93025;
  --success: #188038;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: #fff;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header h1 { font-size: 22px; font-weight: 600; }
.version {
  background: rgba(255,255,255,.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* ---- Section header actions ---- */
.section-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header-actions select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  background: #fff;
  cursor: pointer;
}
.section-header-actions select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ---- Workspace ---- */
.workspace {
  display: flex;
  gap: 16px;
  margin: 16px 32px;
  min-height: 420px;
}
.workspace-left {
  flex: 5;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.workspace-center {
  flex: 4;
  min-width: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workspace-right {
  flex: 5;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  padding: 0;
  border: none;
}
.btn-mini {
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  transition: all .15s;
  line-height: 1;
}
.btn-mini:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

/* ---- Form ---- */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 12px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.required { color: var(--danger); }
.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}
.form-group input::placeholder { color: #c0c4cc; }

/* ---- Custom stage input ---- */
.custom-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}
.custom-input-wrapper input {
  flex: 1;
  padding-right: 32px;
}
.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: #c0c4cc;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  border-radius: 50%;
  transition: color .2s, background .2s;
}
.clear-btn:hover {
  color: #fff;
  background: var(--primary);
}
.clear-btn.hidden {
  display: none;
}

/* ---- 勘探单位下拉按钮 + 面板 ---- */
.company-dropdown-btn {
  position: absolute;
  right: 32px;            /* 清空按钮(right:8px,宽20px)左侧 */
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: #909399;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  border-radius: 4px;
  transition: color .2s, background .2s;
}
.company-dropdown-btn:hover {
  color: var(--primary);
  background: #f0f2f5;
}
/* 有下拉按钮时输入框右侧留两个按钮的空间 */
.custom-input-wrapper:has(.company-dropdown-btn:not([style*="display:none"])) input {
  padding-right: 64px;
}
.company-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  z-index: 100;
  padding: 4px 0;
}
.company-dropdown-panel .dropdown-item {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-dropdown-panel .dropdown-item:hover {
  background: var(--primary);
  color: #fff;
}
.company-dropdown-panel .dropdown-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: #999;
}

/* ---- Watermark position row ---- */
.position-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  margin-top: 8px;
}
.position-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
  text-align: center;
}
.position-hint {
  font-size: 11px;
  color: #c0c4cc;
  margin-left: auto;
}
.position-row.disabled .position-grid {
  opacity: 0.5;
  pointer-events: none;
}
.position-row.disabled .position-hint {
  display: inline;
}
.position-row:not(.disabled) .position-hint {
  display: none;
}
.position-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 68px;
}
.position-grid input[type="radio"] {
  display: none;
}
.pos-cell {
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f5f7fa;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.pos-cell:hover {
  border-color: var(--primary);
}
.position-grid input[type="radio"]:checked + .pos-cell {
  border-color: var(--primary);
  background: rgba(26, 115, 232, 0.08);
}
/* 角标指示器：小方块表示水印位置 */
.pos-indicator {
  position: absolute;
  width: 10px;
  height: 7px;
  background: #c0c4cc;
  border-radius: 1px;
  transition: background .2s;
}
.position-grid input[type="radio"]:checked + .pos-cell .pos-indicator {
  background: var(--primary);
}
.pos-tl { top: 4px; left: 4px; }
.pos-tr { top: 4px; right: 4px; }
.pos-bl { bottom: 4px; left: 4px; }
.pos-br { bottom: 4px; right: 4px; }

/* ---- Upload ---- */
.workspace-right .single-zone,
.workspace-right .multi-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.drop-area {
  padding: 48px 24px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.drop-area:hover, .drop-area.drag-over {
  border-color: var(--primary);
  background: rgba(26,115,232,.04);
}
.drop-icon { font-size: 40px; margin-bottom: 8px; }
.drop-area p { font-size: 14px; color: var(--text-secondary); }
.drop-area .link { color: var(--primary); text-decoration: underline; }
.drop-area .hint { font-size: 12px; color: var(--text-hint); margin-top: 4px; }

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #e8f0fe;
  border-radius: 6px;
  margin: 8px 0;
}
.file-name { font-size: 13px; color: var(--primary); }
.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-remove:hover { background: rgba(217,48,37,.1); }

/* ---- Multi Slot Grid ---- */
.multi-zone {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.multi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.multi-slot {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .2s;
}
.multi-slot:hover { border-color: var(--primary); }
.multi-slot.filled { border-style: solid; border-color: #34a853; }

.slot-label {
  text-align: center;
  padding: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.slot-drop {
  cursor: pointer;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-placeholder {
  text-align: center;
  padding: 10px;
  color: var(--text-hint);
}
.slot-icon { font-size: 22px; margin-bottom: 4px; }
.slot-placeholder span { font-size: 11px; }

.slot-preview {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.slot-remove {
  position: absolute;
  top: 30px;
  right: 4px;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.slot-remove:hover { background: var(--danger); }

.multi-status {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.multi-status.ready { color: var(--success); font-weight: 600; }

/* ---- Preview ---- */
.preview-section {
  padding: 20px 32px;
  margin: 16px 32px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.preview-header h2 { font-size: 16px; }
.preview-actions {
  display: flex;
  gap: 12px;
}
.preview-divider {
  height: 1px;
  background: #dde1e6;
  margin-bottom: 12px;
}

.watermark-info-lines {
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
  flex: 2;
  min-width: 0;
  font-size: 20px;
  line-height: 1;
}
.wm-section {
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.wm-section-dark {
  background: #6091D2;
  flex: 2;
}
.wm-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}
.wm-section-gray {
  background: #dadada;
  flex: 3;
}
.wm-section-dark .wm-line {
  color: #000;
}
.wm-section-gray .wm-line {
  color: #000;
}
.wm-line {
  display: flex;
  align-items: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wm-line-title {
  white-space: nowrap;
  text-align: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-pair {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
}
.preview-card {
  flex: 1;
  max-width: 480px;
}
.preview-label {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 6px;
  font-weight: 500;
}
.preview-img-wrap {
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-img-wrap img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}
.preview-arrow {
  font-size: 32px;
  color: var(--text-hint);
  flex-shrink: 0;
}

/* Multi preview grid */
.preview-multi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.preview-mini-card {
  text-align: center;
}
.preview-mini-label {
  font-size: 11px;
  color: var(--text-hint);
  margin-bottom: 4px;
}
.preview-mini-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #f0f0f0;
}
.preview-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-hint);
}
.preview-empty p { font-size: 15px; }

/* ---- Buttons ---- */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,115,232,.3);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #333; }

/* ---- Confirm Dialog ---- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px 20px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  text-align: center;
}
.confirm-msg {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 20px;
}
.confirm-msg strong {
  display: block;
  margin-bottom: 6px;
}
.confirm-sub {
  font-size: 13px;
  color: var(--text-secondary);
}
.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ---- Header 右侧（登录态/后台入口） ---- */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-link {
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  opacity: .9;
}
.header-link:hover { opacity: 1; }
.header-user {
  color: #fff;
  font-size: 13px;
  opacity: .85;
}

/* ---- 登录弹层 ---- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px 28px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.login-header h3 { font-size: 18px; font-weight: 600; }
.login-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-hint);
  cursor: pointer;
  padding: 0 4px;
}
.login-close:hover { color: var(--text); }
.login-tip {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.login-row label {
  font-size: 13px;
  color: var(--text-secondary);
}
.login-row input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-row input:focus {
  outline: none;
  border-color: var(--primary);
}
.login-error {
  font-size: 13px;
  color: var(--danger);
  margin: 0;
}
.btn-login-submit { width: 100%; margin-top: 4px; }

/* ---- 场景切换 ---- */
.scene-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.scene-tab {
  padding: 8px 18px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-hint, #6b7280);
  cursor: pointer;
  font-size: 14px;
}
.scene-tab:hover { color: var(--primary, #2563eb); }
.scene-tab.active {
  background: #fff;
  border-color: var(--border, #e5e7eb);
  color: var(--primary, #2563eb);
  font-weight: 600;
}
.scene-panel { min-height: 200px; }

/* ---- 实验室场景 ---- */
.lab-unsupported {
  margin: 24px 16px;
  padding: 24px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius, 8px);
  color: #9a3412;
  text-align: center;
}
.lab-unsupported .hint { color: var(--text-hint, #6b7280); font-size: 13px; }

.lab-workspace { margin-top: 12px; }
.lab-videos .multi-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.lab-videos video.slot-preview {
  height: 110px;
  object-fit: contain;
  background: #000;
}
.preview-badge-hint {
  font-size: 12px;
  color: var(--text-hint, #6b7280);
  padding: 4px 8px;
  text-align: center;
  word-break: break-all;
}
.lab-preview-frame { display: none; border-radius: 4px; }
.lab-preview-loading {
  font-size: 12px;
  color: var(--text-hint, #6b7280);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .workspace { flex-direction: column; margin: 8px 12px; }
  .workspace-left, .workspace-center, .workspace-right { border-radius: var(--radius); }
  .multi-grid { grid-template-columns: repeat(2, 1fr); }
  .preview-pair { flex-direction: column; }
  .preview-multi-grid { grid-template-columns: repeat(2, 1fr); }
  .slot-drop { min-height: 80px; }
  .slot-preview { height: 80px; }
  .preview-section {
    padding-left: 12px; padding-right: 12px; margin-left: 8px; margin-right: 8px;
  }
  .preview-header { flex-direction: column; align-items: flex-start; }
}