/* ============================================================
   style.css - MagicCam Base Styles
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #000;
  --surface: rgba(28, 28, 30, 0.94);
  --surface-light: rgba(44, 44, 46, 0.9);
  --border: rgba(255,255,255,0.12);
  --text: #ffffff;
  --text-secondary: rgba(255,255,255,0.55);
  --accent: #FFD60A;
  --danger: #FF453A;
  --success: #30D158;
  --info: #0A84FF;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 26px;
  --radius-xl: 36px;
  --safe-top: env(safe-area-inset-top, 44px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  position: relative;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(30,30,32,0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  max-width: 80vw;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.9); }
}

/* ---- Utility ---- */
.hidden { display: none !important; }

button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  touch-action: manipulation;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 4px;
  height: 4px;
}

input[type="text"] {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  width: 100%;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 22px;
  border-radius: var(--radius-md);
  width: 100%;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: opacity 0.15s;
}
.btn-secondary:active { opacity: 0.75; }

.btn-danger {
  background: rgba(255, 69, 58, 0.2);
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,69,58,0.3);
  transition: opacity 0.15s;
}
.btn-danger:active { opacity: 0.75; }

.btn-success {
  background: var(--success);
  color: #000;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 22px;
  border-radius: var(--radius-md);
  width: 100%;
  transition: opacity 0.15s;
}
.btn-success:active { opacity: 0.8; }

/* ---- Secret Menu ---- */
.secret-menu {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.menu-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 88dvh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 8px);
  animation: slideUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow: hidden;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.menu-handle {
  width: 36px;
  height: 5px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  flex-shrink: 0;
}

.menu-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.menu-close-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.menu-close-btn svg { width: 22px; height: 22px; }

/* ---- Tabs ---- */
.menu-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.menu-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-light);
  white-space: nowrap;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.tab-btn.tab-active {
  color: var(--bg);
  background: var(--accent);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}

/* ---- Preset List ---- */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}
.empty-state span { font-size: 40px; }

.preset-card {
  background: var(--surface-light);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

.preset-card.active-preset {
  border-color: var(--accent);
}

.preset-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255,214,10,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.preset-info {
  flex: 1;
  min-width: 0;
}

.preset-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.preset-actions {
  display: flex;
  gap: 6px;
}

.preset-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}
.preset-action-btn:active { background: rgba(255,255,255,0.15); }

/* ---- Upload ---- */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-zone {
  background: var(--surface-light);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.upload-icon { font-size: 44px; }

.upload-title {
  font-size: 17px;
  font-weight: 600;
}

.upload-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.video-preview-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.video-preview {
  width: 100%;
  max-height: 200px;
  border-radius: var(--radius-md);
  background: #000;
  object-fit: contain;
}

.preview-controls {
  display: flex;
  gap: 8px;
}

.chroma-options {
  background: var(--surface-light);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
}

.chroma-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.chroma-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--progress, 0%);
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s;
}

#progressLabel {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.save-preset-section {
  background: var(--surface-light);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
}

.alpha-check-msg {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}

.alpha-check-msg.ok {
  background: rgba(48,209,88,0.15);
  color: var(--success);
  border: 1px solid rgba(48,209,88,0.25);
}

.alpha-check-msg.warn {
  background: rgba(255,159,10,0.15);
  color: #FF9F0A;
  border: 1px solid rgba(255,159,10,0.25);
}

.alpha-check-msg.error {
  background: rgba(255,69,58,0.15);
  color: var(--danger);
  border: 1px solid rgba(255,69,58,0.25);
}

/* ---- Trigger tab ---- */
.trigger-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.trigger-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-light);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s;
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.radio-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label strong { font-size: 15px; }
.radio-label small  { font-size: 12px; color: var(--text-secondary); }

.delay-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.delay-btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-light);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.delay-btn.delay-active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.active-preset-display {
  background: var(--surface-light);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--accent);
}

/* ---- Help ---- */
.help-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-section h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-list li {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-light);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.compat-check {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compat-result {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface-light);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
