/* 全域樣式與變數 */
:root {
  --bg-dark: #0f1115;
  --bg-panel: rgba(22, 26, 33, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  
  --success-color: #10b981;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  
  --panel-radius: 16px;
  --input-radius: 8px;
  --transition-speed: 0.25s;
}

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

body {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* 背景發光效果 */
.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #151a24 0%, #0d0f12 100%);
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
}

.glow-1 {
  top: -10%;
  left: 10%;
  width: 40vw;
  height: 40vw;
  background: var(--accent-color);
}

.glow-2 {
  bottom: -10%;
  right: 10%;
  width: 45vw;
  height: 45vw;
  background: #6366f1;
}

/* 主容器 */
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* 標頭樣式 */
.app-header {
  text-align: center;
  margin-bottom: 10px;
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.shield-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.4));
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 16px;
  font-weight: 300;
}

/* 隱私聲明 */
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  color: var(--success-color);
  font-weight: 500;
  max-width: 90%;
  margin: 0 auto;
}

/* 版面結構 */
.main-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 968px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* 面板通用樣式 (玻璃面效果) */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--panel-radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.section-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
  position: relative;
  padding-left: 12px;
  color: #fff;
}

.section-title h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 4px;
  background: var(--accent-color);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-color);
}

/* 表單與控制項 */
.control-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  gap: 16px;
}

.control-group.half {
  flex: 1;
  min-width: 0; /* 防止 flex 項目溢出 */
}

label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

label span {
  font-family: monospace;
  color: var(--accent-color);
  font-weight: 600;
}

textarea, select, input[type="text"] {
  background: rgba(10, 12, 16, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.92rem;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

textarea:focus, select:focus, input[type="text"]:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  resize: vertical;
}

/* 快速標籤按鈕 */
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.quick-tag-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.quick-tag-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* 滑桿設計 (Range Inputs) */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-color);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-color);
  transition: transform 0.1s;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* 顏色選擇器 */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 12, 16, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  padding: 6px 10px;
  height: 40px;
}

.color-picker-wrapper input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 28px;
  height: 24px;
  background: none;
  cursor: pointer;
  padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#color-hex {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* 按鈕樣式 */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--input-radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition-speed);
  width: 100%;
}

.btn-icon {
  font-size: 1.1rem;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* 拖曳區 (Dropzone) */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--panel-radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-speed);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 380px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-color);
  background: rgba(59, 130, 246, 0.02);
  box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.05);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
  transition: transform var(--transition-speed);
}

.dropzone:hover .upload-icon {
  transform: translateY(-5px);
}

.dropzone h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.dropzone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.file-limits {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 預覽貨櫃與 Canvas */
.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.preview-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.preview-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.image-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: monospace;
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 4px;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
  min-height: 380px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

#preview-canvas {
  max-width: 100%;
  max-height: 550px;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  background-image: 
    linear-gradient(45deg, #181d24 25%, transparent 25%), 
    linear-gradient(-45deg, #181d24 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #181d24 75%), 
    linear-gradient(-45deg, transparent 75%, #181d24 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* 隱藏元素工具 */
.hidden {
  display: none !important;
}

/* 頁腳 */
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
