/* ==========================================================================
   rume@lemari - OOTD Canvas Stylesheet
   Pure White background, Pure Black Text/Accents, Minimalist Luxury Aesthetic
   ========================================================================== */

/* Design System / Variables */
:root {
  --color-bg: #ffffff;
  --color-text: #000000;
  --color-border: #000000;
  --color-border-light: #e5e5e5;
  --color-accent-hover: #000000;
  --color-accent-text-hover: #ffffff;
  --color-danger: #ff3b30;
  --color-danger-hover: #ff453a;
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Source Code Pro', Courier, monospace;
  
  --transition-speed: 0.15s;
  --border-width: 1px;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  overflow-x: hidden;
  height: 100vh;
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: var(--border-width) solid var(--color-border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.brand {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: -0.04em;
  line-height: 1;
}

.subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.7;
}

/* Main Workspace Split (2 columns: Sidebar & Canvas) */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0; /* Important for scrollable columns */
  margin-bottom: 80px; /* Space for sticky bottom buttons */
}

/* Panels (Sidebars) */
.panel {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  padding: 20px;
  overflow-y: auto;
  background-color: var(--color-bg);
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  text-transform: uppercase;
  border-bottom: var(--border-width) solid var(--color-border);
  padding-bottom: 8px;
  font-family: var(--font-mono);
}

.section-subtitle {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* Left Panel: Upload Zone */
.upload-dropzone {
  border: var(--border-width) dashed var(--color-border);
  padding: 30px 20px;
  text-align: center;
  position: relative;
  cursor: pointer;
  margin-bottom: 24px;
  transition: background-color var(--transition-speed);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  background-color: rgba(0, 0, 0, 0.03);
}

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

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dropzone-text {
  font-size: 13px;
  font-weight: 400;
}

.dropzone-text strong {
  text-decoration: underline;
}

/* Inventory Grid */
.inventory-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.empty-state {
  grid-column: span 2;
  font-size: 12px;
  color: #666;
  text-align: center;
  padding: 40px 10px;
  line-height: 1.6;
}

.inventory-item {
  border: var(--border-width) solid var(--color-border-light);
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fafafa;
}

.inventory-item:hover {
  border-color: var(--color-border);
}

.inventory-item img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  pointer-events: none;
}

.inventory-item .remove-uploaded {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.inventory-item:hover .remove-uploaded {
  opacity: 1;
}

/* Center Canvas Column */
.canvas-section {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fafafa;
  border: var(--border-width) solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.canvas {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4/5;
  background-color: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  position: relative;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  touch-action: none; /* Crucial: disables standard browser scrolling on canvas */
}

/* Placeholder text in empty canvas */
.canvas-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 80%;
  pointer-events: none;
  z-index: 1;
}

.canvas-placeholder p {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.canvas-placeholder span {
  font-size: 11px;
  font-family: var(--font-mono);
  opacity: 0.5;
}

/* Canvas Placed Items */
.canvas-item {
  position: absolute;
  touch-action: none; /* Disable browser zooming/scrolling on dragging item */
  user-select: none;
  cursor: move;
  display: inline-block;
  will-change: transform;
}

.canvas-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Active selection styling */
.canvas-item.active {
  outline: 1px dashed var(--color-border);
  outline-offset: 4px;
  z-index: 999 !important; /* Force to top visual stack when editing */
}

/* Item Action Corner Handles */
.canvas-item .handle {
  position: absolute;
  width: 28px;
  height: 28px;
  background-color: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  display: none; /* Hidden by default, shown when active */
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  z-index: 10;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

.canvas-item.active .handle {
  display: flex;
}

.canvas-item .handle:hover {
  background-color: var(--color-accent-hover);
  color: var(--color-accent-text-hover);
}

.canvas-item .handle svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Positioning Handles on Bounding Box Corners */
.canvas-item .handle-tl {
  top: -14px;
  left: -14px;
}

.canvas-item .handle-tr {
  top: -14px;
  right: -14px;
}

.canvas-item .handle-br {
  bottom: -14px;
  right: -14px;
  cursor: nwse-resize; /* Resizing cursor indicator */
}

/* Action Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-speed);
  border: var(--border-width) solid var(--color-border);
}

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

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

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

.btn-outline:hover {
  background-color: var(--color-accent-hover);
  color: var(--color-accent-text-hover);
}

/* Global sticky actions */
.app-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-bg);
  border-top: var(--border-width) solid var(--color-border);
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  z-index: 1000;
}

/* Responsive Styles for Tablet & Android (Mobile) */
@media (max-width: 1024px) {
  body {
    height: auto;
    overflow-y: auto;
  }
  
  .app-container {
    height: auto;
    padding: 16px;
  }
  
  .workspace {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 120px; /* Space for sticky footer */
  }
  
  .panel {
    max-height: 400px;
  }
  
  .canvas-section {
    order: -1; /* Move canvas to top of mobile stack */
    aspect-ratio: 4/5;
    height: auto;
    min-height: 450px;
  }
  
  .canvas-viewport {
    padding: 12px;
  }
  
  .canvas {
    max-width: 360px;
  }
  
  .app-actions {
    flex-direction: column-reverse;
    gap: 8px;
    padding: 12px 16px;
  }
  
  .app-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 24px;
  }
  
  .canvas {
    max-width: 300px;
  }
  
  .inventory-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 items in a row on phone viewports */
  }
}
