/* ============================================
   Web 图片处理工具 - 暗色炫酷风格
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: #0D0D0D; color: #E8E8E8; font-size: 13px;
}
input, select, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2A2A2A; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3A3A3A; }

/* --- Top Bar --- */
#topbar {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: #141414;
  border-bottom: 0.5px solid #2A2A2A; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 28px; height: 28px; border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
}
.logo-img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 6px;
}
.app-title { font-size: 14px; font-weight: 500; color: #E8E8E8; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* --- Buttons --- */
.btn-primary {
  padding: 6px 14px; font-size: 13px; border: none;
  background: linear-gradient(135deg, #00D4FF, #7B2FFF);
  border-radius: 8px; color: #0D0D0D; font-weight: 500;
  box-shadow: 0 0 16px rgba(0,212,255,0.25); transition: box-shadow 0.2s;
}
.btn-primary:hover { box-shadow: 0 0 24px rgba(0,212,255,0.4); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-secondary {
  padding: 6px 14px; font-size: 13px;
  border: 0.5px solid #3A3A3A; background: #1A1A1A;
  border-radius: 8px; color: #AAA; transition: background 0.2s;
}
.btn-secondary:hover { background: #252525; }
.btn-secondary:disabled { opacity: 0.4; cursor: default; }

/* --- Main Layout --- */
#main {
  display: flex; height: calc(100vh - 52px);
}

/* --- Module Nav (72px) --- */
#module-nav {
  width: 72px; background: #141414;
  border-right: 0.5px solid #2A2A2A;
  display: flex; flex-direction: column; align-items: center;
  padding-top: 12px; gap: 4px; flex-shrink: 0;
}
.nav-item {
  width: 56px; height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer;
  border: 0.5px solid transparent; transition: all 0.2s;
}
.nav-item.active {
  background: rgba(0,212,255,0.08);
  border-color: rgba(0,212,255,0.3);
}
.nav-item.active span { color: #00D4FF; font-weight: 500; }
.nav-item.disabled { opacity: 0.35; cursor: default; }
.nav-item span { font-size: 10px; color: #666; margin-top: 2px; }
.nav-item:not(.disabled):hover:not(.active) { background: rgba(255,255,255,0.03); }

/* --- Image List Panel (160px) --- */
#image-list-panel {
  width: 160px; background: #1A1A1A;
  border-right: 0.5px solid #2A2A2A;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.panel-header {
  padding: 12px 12px 8px; display: flex;
  align-items: center; justify-content: space-between;
}
.panel-title { font-size: 13px; font-weight: 500; color: #E8E8E8; }
.panel-actions { display: flex; align-items: center; gap: 6px; }
.panel-btn {
  background: none; border: none; color: #888; font-size: 11px;
  cursor: pointer; padding: 2px 4px; border-radius: 3px;
  transition: all 0.15s;
}
.panel-btn:hover { color: #00D4FF; background: rgba(0,212,255,0.08); }
.panel-count { font-size: 11px; color: #666; }

/* Upload Area */
#upload-area {
  margin: 0 12px 8px; padding: 18px 0;
  border: 1.5px dashed #3A3A3A; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; background: #141414; transition: border-color 0.2s;
  position: relative;
}
#upload-area:hover { border-color: #00D4FF; }
#upload-area span { font-size: 11px; color: #666; margin-top: 4px; }
#upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* Image List */
#image-list {
  flex: 1; overflow-y: auto; padding: 0 12px 12px;
}
.img-list-item {
  margin-bottom: 6px; padding: 6px;
  background: #1F1F1F; border-radius: 8px;
  border: 0.5px solid #2A2A2A;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: border-color 0.2s;
}
.img-list-item:hover { border-color: #3A3A3A; }
.img-list-item.active {
  border-color: #00D4FF;
  box-shadow: 0 0 0 1px rgba(0,212,255,0.3), 0 0 16px rgba(0,212,255,0.08);
}
.img-list-item.selected { }
.img-thumb {
  width: 40px; height: 40px; border-radius: 4px;
  background: #252525; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-info { flex: 1; min-width: 0; }
.img-name {
  font-size: 11px; color: #E8E8E8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-size { font-size: 10px; color: #666; }
.img-checkbox {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #3A3A3A;
  transition: all 0.2s; cursor: pointer;
}
.img-checkbox:hover { border-color: #555; }
.img-list-item.selected .img-checkbox {
  background: #00D4FF; border-color: #00D4FF;
  box-shadow: 0 0 8px rgba(0,212,255,0.4);
}

/* --- Canvas Area --- */
#canvas-area {
  flex: 1; background: #111; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

/* Canvas Toolbar */
#canvas-toolbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; background: #1A1A1A;
  padding: 4px; border-radius: 8px;
  border: 0.5px solid #2A2A2A;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5); z-index: 10;
}
.toolbar-item {
  padding: 4px 8px; font-size: 12px; color: #AAA;
  cursor: pointer; border-radius: 4px; transition: background 0.2s;
  display: flex; align-items: center; gap: 4px;
}
.toolbar-item:hover { background: #252525; }
.toolbar-item.active { color: #00D4FF; }
.toolbar-divider { width: 1px; background: #2A2A2A; margin: 4px 0; }

/* Canvas Viewport */
#canvas-viewport {
  position: relative; display: flex; align-items: center; justify-content: center;
  flex: 1; width: 100%; overflow: hidden;
}
#canvas-container {
  position: relative; overflow: hidden;
  box-shadow: 0 0 30px rgba(0,0,0,0.6); border-radius: 4px;
  background: #1A1A1A;
}
#preview-image { display: block; max-width: none; }
#preview-image[hidden] { display: none; }

/* Empty State */
#empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #444;
}
#empty-state p { font-size: 13px; color: #444; }
#empty-state.hidden { display: none; }

/* --- Crop Box --- */
#crop-box {
  position: absolute; border: 2px solid #00D4FF;
  background: rgba(0,212,255,0.05);
  cursor: move;
  box-shadow: 0 0 12px rgba(0,212,255,0.15), inset 0 0 12px rgba(0,212,255,0.05);
}
#crop-box.hidden { display: none; }
#crop-box.dragging { user-select: none; }

/* Handles */
.handle {
  position: absolute; width: 10px; height: 10px;
  background: #0D0D0D; border: 1.5px solid #00D4FF;
  border-radius: 2px; box-shadow: 0 0 6px rgba(0,212,255,0.5);
}
.handle-tl { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-tr { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-br { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* Crop Label */
.crop-label {
  position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #00D4FF, #7B2FFF);
  color: #0D0D0D; font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 3px; white-space: nowrap;
  box-shadow: 0 0 10px rgba(0,212,255,0.3);
}

/* Crosshair */
.crop-crosshair-h {
  position: absolute; top: 50%; left: 0; width: 100%; height: 0.5px;
  background: rgba(0,212,255,0.2); pointer-events: none;
}
.crop-crosshair-v {
  position: absolute; left: 50%; top: 0; width: 0.5px; height: 100%;
  background: rgba(0,212,255,0.2); pointer-events: none;
}

/* Dark overlay outside crop box */
.crop-overlay {
  position: absolute; background: rgba(0,0,0,0.6); pointer-events: none;
}

/* --- Alignment Indicator --- */
#alignment-indicator {
  margin-top: 16px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #666;
}
#alignment-indicator span { color: #00D4FF; cursor: pointer; text-decoration: underline; font-size: 11px; }

/* --- Properties Panel (200px) --- */
#properties-panel {
  width: 200px; background: #141414;
  border-left: 0.5px solid #2A2A2A;
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.props-header {
  padding: 16px 16px 12px;
  border-bottom: 0.5px solid #2A2A2A;
}
.props-title { font-size: 14px; font-weight: 500; color: #E8E8E8; }
.props-subtitle { font-size: 11px; color: #666; margin-top: 2px; display: block; }

/* Props Section */
.props-section {
  padding: 12px 16px;
  border-bottom: 0.5px solid #2A2A2A;
}
.props-label { font-size: 12px; color: #888; margin-bottom: 8px; }

/* Tabs (alignment) */
.props-tabs { display: flex; gap: 4px; }
.tab {
  flex: 1; padding: 5px 0; font-size: 11px; text-align: center;
  background: #1A1A1A; color: #888; border-radius: 4px;
  cursor: pointer; border: 0.5px solid #2A2A2A; transition: all 0.2s;
}
.tab:hover { border-color: #3A3A3A; }
.tab.active {
  background: rgba(0,212,255,0.1); color: #00D4FF;
  border-color: rgba(0,212,255,0.3); font-weight: 500;
}

/* Field */
.props-field {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.field-label { font-size: 12px; color: #AAA; width: 28px; flex-shrink: 0; }
.props-field input[type="number"] {
  flex: 1; padding: 5px 8px; font-size: 12px;
  border: 0.5px solid #2A2A2A; border-radius: 4px;
  background: #1A1A1A; color: #E8E8E8; outline: none;
  text-align: center; -moz-appearance: textfield;
}
.props-field input[type="number"]:focus { border-color: #00D4FF; }
.props-field input[type="number"]::-webkit-inner-spin-button,
.props-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}
.field-unit { font-size: 11px; color: #666; width: 14px; flex-shrink: 0; }

/* Select */
.props-field select {
  flex: 1; padding: 5px 8px; font-size: 12px;
  border: 0.5px solid #2A2A2A; border-radius: 4px;
  background: #1A1A1A; color: #E8E8E8; outline: none;
  cursor: pointer; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23666' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.props-field select:focus { border-color: #00D4FF; }

/* Checkbox */
.props-checkbox {
  display: flex; align-items: center; gap: 6px; cursor: pointer; margin-top: 4px;
}
.checkbox-box {
  width: 14px; height: 14px; border: 1.5px solid #2A2A2A;
  border-radius: 3px; display: flex; align-items: center; justify-content: center;
  background: #1A1A1A; transition: all 0.2s;
}
.props-checkbox.checked .checkbox-box {
  border-color: #00D4FF; background: rgba(0,212,255,0.1);
}
.props-checkbox span { font-size: 11px; color: #AAA; }

/* Actions */
.props-actions {
  padding: 16px; display: flex; flex-direction: column; gap: 8px; margin-top: auto;
}
.props-actions .btn-primary { width: 100%; padding: 8px 0; }
.props-actions .btn-secondary { width: 100%; padding: 8px 0; }

/* --- Toast --- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1F1F1F; color: #E8E8E8; font-size: 13px;
  padding: 8px 16px; border-radius: 8px;
  border: 0.5px solid #2A2A2A;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 1000; transition: opacity 0.3s;
}
#toast.hidden { opacity: 0; pointer-events: none; }

/* --- Modal --- */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
#modal-overlay[hidden] { display: none; }
#modal-overlay.hidden { display: none; }
#modal {
  background: #1A1A1A; border-radius: 12px;
  border: 0.5px solid #2A2A2A;
  padding: 24px; min-width: 360px; max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#modal-title { font-size: 15px; font-weight: 500; color: #E8E8E8; margin-bottom: 12px; }
#modal-body { font-size: 13px; color: #AAA; line-height: 1.6; margin-bottom: 16px; }
#modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
#modal-actions .btn-primary, #modal-actions .btn-secondary { padding: 6px 16px; }
