@import "tailwindcss";

:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --bg-hover: #383838;
  --border: #3a3a3a;
  --text-primary: #f0f0f0;
  --text-secondary: #9a9a9a;
  --text-muted: #666;
  --accent: #5563DE;
  --accent-hover: #6675f0;
  --success: #3d9970;
  --warning: #e67e22;
  --danger: #e74c3c;

  --label-red: #e74c3c;
  --label-yellow: #f1c40f;
  --label-green: #2ecc71;
  --label-blue: #3498db;
  --label-purple: #9b59b6;
  
  --sidebar-width: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  height: 100vh;
  overflow: hidden;
}

#app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

#main-nav {
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
}

.nav-item.hidden {
  display: none;
}

.context-area {
  flex: 1;
  padding: 20px;
  border-top: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
}

#btn-shortcuts {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
}

/* Main Content */
#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
}

#page-container {
  flex: 1;
  height: 100%;
  overflow-y: auto;
}

/* Gallery Styles */
.gallery-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.gallery-toolbar {
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 20px;
  align-items: center;
}

.gallery-grid {
  flex: 1;
  display: grid;
  gap: 15px;
  padding: 20px;
  overflow-y: auto;
}

.photo-item {
  position: relative;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.photo-item:hover { transform: scale(1.02); }
.photo-item.selected { border-color: var(--accent); }
.photo-item.rejected { opacity: 0.5; filter: grayscale(0.5) sepia(0.2); }

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  justify-content: space-between;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Detail Sidebar */
#detail-sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}

.preview-img {
  width: 100%;
  border-radius: 4px;
  margin-bottom: 15px;
}

.detail-content .filename { font-weight: bold; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; }
.detail-content .meta { color: var(--text-secondary); font-size: 12px; margin-bottom: 15px; }

.stars-input { margin-bottom: 15px; font-size: 1.2rem; }
.star-btn { cursor: pointer; opacity: 0.3; }
.star-btn.active { opacity: 1; }

.color-input { display: flex; gap: 8px; margin-bottom: 20px; }
.color-dot-btn { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-dot-btn.active { border-color: white; transform: scale(1.2); }

.tags-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-chip { background: var(--bg-tertiary); padding: 2px 8px; border-radius: 12px; font-size: 12px; }

#photo-notes { width: 100%; background: var(--bg-tertiary); border: 1px solid var(--border); color: white; padding: 8px; border-radius: 4px; height: 80px; margin-bottom: 20px; resize: none; }

/* Common UI Elements */
.btn {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn:hover { opacity: 0.9; }
.w-full { width: 100%; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  padding: 12px 20px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modals */
#modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#modal-container.hidden { display: none; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  padding: 24px;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

/* Setup Page */
.setup-page {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
}

.setup-page h2 { margin-bottom: 20px; color: var(--accent); }
.setup-page code {
  display: block;
  background: #000;
  padding: 15px;
  border-radius: 4px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: monospace;
}
.setup-page ol { margin-left: 20px; margin-bottom: 20px; }
.setup-page li { margin-bottom: 10px; }

/* Analyze Styles */
.analyze-page { padding: 20px; height: 100%; overflow-y: auto; width: 100%; }
.analyze-grid { display: grid; grid-template-columns: 1fr 350px; gap: 20px; margin-top: 20px; }
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.photo-card { grid-row: span 2; }
.canvas-wrapper { position: relative; background: #000; border-radius: 4px; overflow: hidden; display: flex; justify-content: center; }
#analyze-canvas { display: block; max-width: 100%; cursor: crosshair; }

.chart-wrapper { height: 200px; margin: 15px 0; }
.exposure-stats { display: flex; flex-direction: column; gap: 8px; }
.stat-row { display: flex; justify-content: space-between; }
.stat-row.warning { color: var(--warning); }

.colors-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 15px; }
.color-chip-large { height: 60px; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; cursor: pointer; }

/* Editor Styles */
.editor-page { height: 100%; display: flex; flex-direction: column; width: 100%; }
.editor-main { flex: 1; display: flex; overflow: hidden; }
.canvas-container { flex: 1; background: #000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.editor-tools { width: 300px; background: var(--bg-secondary); border-left: 1px solid var(--border); padding: 20px; }
.tool-group { margin-bottom: 30px; }
.tool-group h3 { margin-bottom: 15px; font-size: 14px; text-transform: uppercase; color: var(--text-secondary); }
.control { margin-bottom: 15px; }
.control label { display: block; margin-bottom: 5px; }
.control input[type="range"] { width: 100%; }

/* Whiteboard Styles */
.whiteboard-page { height: 100%; display: flex; flex-direction: column; width: 100%; }
.whiteboard-header { padding: 10px 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.whiteboard-main { flex: 1; display: flex; overflow: hidden; }
.photo-pool { width: 200px; background: var(--bg-secondary); border-right: 1px solid var(--border); padding: 15px; overflow-y: auto; }
.pool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pool-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: grab; }

#canvas-viewport { flex: 1; background: #111; position: relative; overflow: hidden; }
#infinite-canvas { position: absolute; top: 0; left: 0; width: 10000px; height: 10000px; transform-origin: 0 0; }

.board-item-el { position: absolute; cursor: move; }
.board-item-el img { max-width: 200px; border: 2px solid transparent; border-radius: 4px; }
.board-item-el:hover img { border-color: var(--accent); }

.board-group-el { position: absolute; border: 2px solid; border-radius: 8px; pointer-events: none; }
.group-label { position: absolute; top: -25px; left: 0; padding: 2px 8px; border-radius: 4px 4px 0 0; font-size: 12px; font-weight: bold; pointer-events: auto; cursor: move; }

.page-header { padding: 15px 20px; display: flex; align-items: center; gap: 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }

/* Upload Styles */
.upload-page { padding: 40px; width: 100%; }
.drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 60px; text-align: center; cursor: pointer; transition: all 0.2s; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--bg-secondary); }
.drop-zone .icon { font-size: 3rem; display: block; margin-bottom: 10px; }

.upload-queue { margin-top: 40px; }
.queue-item { display: flex; align-items: center; gap: 15px; padding: 10px; border-bottom: 1px solid var(--border); }
.progress-bar { flex: 1; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.progress { height: 100%; background: var(--accent); transition: width 0.3s; }

.canvas-wrapper {
  position: relative;
  display: inline-block;
}

.crop-overlay {
  position: absolute;
  border: 2px dashed white;
  background: rgba(255, 255, 255, 0.2);
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.aspect-ratio-selector {
  display: flex;
  gap: 4px;
  justify-content: space-between;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.mb-2 { margin-bottom: 8px; }
.mt-2 { margin-top: 8px; }

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

.hidden { display: none !important; }
