/* cake-viewer/style.css — 蛋糕3D预览器独立样式 */
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f0f0f0;
  overflow: hidden;
}

#cake-viewer-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #ffffff 0%, #e0e0e0 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#loading-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  color: #666;
  pointer-events: none;
  transition: opacity 0.5s;
}

#hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #666;
  background: rgba(255, 255, 255, 0.7);
  padding: 5px 12px;
  border-radius: 14px;
  pointer-events: none;
  white-space: nowrap;
}

/* ====== 顶部工具栏 ====== */
#toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: flex;
  gap: 8px;
}
#toolbar button {
  padding: 7px 16px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
#toolbar button:hover {
  background: #555;
}
#toolbar button:active {
  background: #222;
}
#btnSaveScheme { background: #2e7d32; }
#btnSaveScheme:hover { background: #388e3c; }
#btnLoadPreset { background: #ef6c00; }
#btnLoadPreset:hover { background: #fb8c00; }
#btnLoadScheme { background: #1565c0; }
#btnLoadScheme:hover { background: #1976d2; }
#btnShareScheme { background: #6a1b9a; }
#btnShareScheme:hover { background: #7b1fa2; }

/* ====== 预设配色弹框 ====== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 90vw;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 12px 12px 0 0;
}
.modal-title { font-size: 16px; font-weight: 600; color: #333; }
.modal-close {
  background: none; border: none; font-size: 26px; line-height: 1;
  color: #999; cursor: pointer; padding: 0 6px;
}
.modal-close:hover { color: #333; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 16px;
}
.preset-card {
  cursor: pointer;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  background: #fafafa;
}
.preset-card:hover { border-color: #1976d2; transform: translateY(-2px); }
.preset-card img { width: 100%; height: 120px; object-fit: cover; display: block; background: #fff; }
.preset-card .preset-name {
  padding: 8px 6px; font-size: 13px; text-align: center; color: #333;
}

/* ====== 手机适配 ====== */
@media (max-width: 600px) {
  body { overflow: auto; }
  #cake-viewer-container { height: 100vh; }
  #toolbar {
    flex-wrap: wrap;
    gap: 6px;
    top: 8px;
    left: 8px;
    right: 8px;
  }
  #toolbar button { padding: 6px 10px; font-size: 12px; }
  #hint { font-size: 10px; top: auto; bottom: 8px; max-width: 92vw; white-space: normal; text-align: center; }
  #color-panel {
    width: 160px;
    right: 8px;
    max-height: 70vh;
    padding: 10px;
  }
  .slot-btn { width: 24px; height: 24px; }
  .slot-name { font-size: 7px; }
  .modal-content { width: 94vw; max-height: 80vh; }
  .preset-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 12px; }
  .preset-card img { height: 100px; }
  .preset-card .preset-name { font-size: 12px; padding: 6px 4px; }
}

/* ====== 右侧调色面板（无遮罩，浮动） ====== */
#color-panel {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.92);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  width: 184px;
  max-height: 82vh;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  z-index: 10;
}
#color-panel.hidden {
  display: none;
}
#panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  z-index: 1;
}
#panel-spec {
  font-size: 11px;
  color: #888;
  text-align: center;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 18px;
  background: rgba(255, 255, 255, 0.92);
  z-index: 1;
}
.panel-section {
  margin-bottom: 10px;
}
.panel-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 5px;
}
#custom-color {
  width: 100%;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0;
  background: none;
  cursor: pointer;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 4px;
  justify-content: center;
}

.slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.slot-btn {
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 50%;
  border: 2px solid #ccc;
  background: #eee;
  cursor: pointer;
  transition: transform 0.15s;
}
.slot-btn:hover {
  transform: scale(1.12);
}
.slot-name {
  font-size: 8px;
  line-height: 1.1;
  color: #777;
  text-align: center;
  width: 100%;
  word-break: break-all;
  white-space: normal;
}
