/* PHOTOBOOTH MINIMALIST DESIGN SYSTEM */
/* Strictly 3 Colors: White, Black, Gray */

:root {
  --bg-primary: #FFFFFF;
  --bg-secondary: #F7F7F8;
  --bg-tertiary: #EFEFEF;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-light: #E5E5E5;
  --border-dark: #111111;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.branch-badge {
  font-size: 0.8rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Step Bar */
.step-nav {
  display: flex;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: 8px 16px;
  gap: 8px;
}

.step-indicator {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 0;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.step-indicator.active {
  color: var(--text-primary);
  border-bottom-color: var(--border-dark);
}

.step-indicator.completed {
  color: var(--text-secondary);
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* View Views */
.view-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeIn 0.25s ease-out;
}

.view-panel.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Header */
.section-header {
  margin-bottom: 16px;
  text-align: center;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Branch Cards */
.branch-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.branch-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.branch-card:hover, .branch-card:active {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-sm);
}

.branch-card.selected {
  border: 2px solid var(--border-dark);
  background: #FAFAFA;
}

.branch-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.branch-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-online { background-color: #10B981; }
.status-offline { background-color: #9CA3AF; }

/* Frame Selection Grid */
.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.frame-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.frame-card:hover, .frame-card:active {
  border-color: var(--border-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.frame-card.selected {
  border: 2px solid var(--border-dark);
}

.frame-thumb-box {
  width: 100%;
  aspect-ratio: 2/3;
  background: #EAEAEA;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.frame-info {
  padding: 10px;
  background: var(--bg-primary);
}

.frame-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-cuts {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ================= EDITOR VIEW ================= */
.editor-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
}

/* Canvas Viewport */
.canvas-wrapper {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 2/3; /* 1200 x 1800 standard */
  background: #FFFFFF;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  user-select: none;
  touch-action: none;
}

/* Dropzone Layers */
.dropzones-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.dropzone-item {
  position: absolute;
  overflow: hidden;
  background: #ECECEC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  border: 1px dashed #AAAAAA;
  transition: box-shadow 0.15s ease;
}

/* Empty Dropzone: Always elevated above frame overlay so it is 100% visible and clickable */
.dropzone-item.empty-slot {
  z-index: 35 !important;
  background: rgba(248, 249, 250, 0.95);
  border: 2px dashed #333333;
}

.dropzone-item.empty-slot:hover,
.dropzone-item.empty-slot:active {
  background: #FFFFFF;
  border-color: #000000;
}

/* Filled Dropzone: Sits nicely underneath the frame overlay */
.dropzone-item.filled-slot {
  z-index: 10;
  background: #000000;
  border: none;
}

.dropzone-item.active-slot {
  box-shadow: 0 0 0 3px #000000, 0 0 10px rgba(0,0,0,0.3);
  z-index: 28 !important;
}

.dropzone-empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #111111;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  padding: 8px;
  width: 100%;
  height: 100%;
}

.dropzone-empty-hint svg {
  margin-bottom: 6px;
  stroke: #111111;
}

.dropzone-empty-hint .hint-sub {
  font-size: 0.65rem;
  font-weight: 400;
  color: #666666;
  margin-top: 2px;
}

.dropzone-image {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

/* Frame Overlay (Layer Top) */
.frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 25;
}

/* Floating Edit Toolbar for Selected Slot */
.slot-toolbar {
  margin-top: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  max-width: 100%;
  overflow-x: auto;
}

.tool-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.tool-btn:hover, .tool-btn:active {
  background: var(--bg-secondary);
}

.tool-btn.danger {
  color: #DC2626;
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border-light);
}

/* Bottom Action Bar */
.bottom-bar {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  gap: 8px;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.btn-primary:hover, .btn-primary:active {
  background: #333333;
}

.btn-primary:disabled {
  background: #CCCCCC;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-dark);
}

.btn-block {
  width: 100%;
}

/* ================= SUCCESS SCREEN ================= */
.success-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}

.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #111111;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
}

.job-code {
  display: inline-block;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-dark);
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  letter-spacing: 1px;
}

.result-preview-box {
  max-width: 260px;
  margin: 16px auto;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.result-preview-box img {
  width: 100%;
  display: block;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile full-screen touch lock */
@media (max-width: 640px) {
  .main-content {
    padding: 12px;
  }
  .canvas-wrapper {
    max-width: 100%;
  }
}
