/* Design System & Themes for Archive Studio */

:root {
  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-normal: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Light Theme Variables */
  --bg-color: #f6f6f7;
  --panel-bg: #ffffff;
  --panel-border: #e2e2e5;
  --text-primary: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-muted: #62666b;
  --accent-color: #000000;
  --accent-hover: #262626;
  --accent-bg-subtle: #f2f2f7;
  --grid-dot: #e2e2e5;
  --input-focus-ring: rgba(0, 0, 0, 0.05);
  --card-bg: #ffffff;
  --success-color: #34c759;
  --danger-color: #ff3b30;
  --item-hover: rgba(0, 0, 0, 0.03);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-color: #0d0d0f;
  --panel-bg: #1a1a1e;
  --panel-border: #2c2c2e;
  --text-primary: #f5f5f7;
  --text-secondary: #8e8e93;
  --text-muted: #a1a1aa;
  --accent-color: #ffffff;
  --accent-hover: #d1d1d6;
  --accent-bg-subtle: #2c2c2e;
  --grid-dot: #222225;
  --input-focus-ring: rgba(255, 255, 255, 0.05);
  --card-bg: #222228;
  --item-hover: rgba(255, 255, 255, 0.03);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Left Toolbar Dock */
.left-toolbar {
  width: 56px;
  height: 100%;
  background-color: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  z-index: 10;
  flex-shrink: 0;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.toolbar-divider {
  width: 24px;
  height: 1px;
  background-color: var(--panel-border);
  margin: 4px 0;
  flex-shrink: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--accent-color);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-fast);
  padding: 0;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
}

.tool-btn:hover:not(:disabled),
.tool-btn.active {
  background-color: var(--accent-bg-subtle);
  color: var(--text-primary);
}

.tool-btn.active {
  border-color: var(--panel-border);
}

/* Tooltips */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: auto;
  left: 125%;
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background-color: var(--text-primary);
  color: var(--panel-bg);
  font-size: 10px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 100;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--panel-border);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Main Canvas Viewport */
.canvas-container {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Floating Navigation Pill */
.nav-pill {
  position: absolute;
  top: 16px;
  left: 16px;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  z-index: 5;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.nav-pill-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.canvas-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: 20px 20px;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  z-index: 1;
  pointer-events: none;
}

.canvas-viewport {
  flex: 1;
  padding: 80px 24px 24px;
  z-index: 2;
  display: flex;
  gap: 24px;
  overflow: hidden;
}

/* App panels */
.workspace-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.workspace-card.main-view {
  flex: 2;
  height: 100%;
}

.workspace-card.side-inspector {
  flex: 1;
  max-width: 380px;
  height: 100%;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
}

.panel-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Drag and Drop Zone */
.dropzone {
  flex: 1;
  border: 2px dashed var(--panel-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  padding: 40px 20px;
  background-color: rgba(0, 0, 0, 0.005);
}

[data-theme="dark"] .dropzone {
  background-color: rgba(255, 255, 255, 0.005);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--text-secondary);
  background-color: var(--accent-bg-subtle);
}

.dropzone-icon {
  color: var(--text-secondary);
  transition: transform var(--transition-normal);
}

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

.dropzone-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

.dropzone-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* File lists and Tree Visualizer */
.file-tree-container {
  flex: 1;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.005);
  font-family: var(--font-mono);
  font-size: 12px;
}

[data-theme="dark"] .file-tree-container {
  background-color: rgba(255, 255, 255, 0.005);
}

.tree-row {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.02);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

[data-theme="dark"] .tree-row {
  border-bottom-color: rgba(255, 255, 255, 0.02);
}

.tree-row:hover {
  background-color: var(--item-hover);
}

.tree-indent {
  width: 16px;
  height: 100%;
  flex-shrink: 0;
  display: inline-block;
}

.tree-icon {
  margin-right: 8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.tree-size {
  color: var(--text-muted);
  margin-left: 8px;
  font-size: 11px;
}

.tree-actions {
  display: flex;
  gap: 6px;
  margin-left: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.tree-row:hover .tree-actions {
  opacity: 1;
}

.tree-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-action-btn:hover {
  background-color: var(--accent-bg-subtle);
  color: var(--text-primary);
}

/* Staged File List (Packer) */
.staged-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.staged-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--accent-bg-subtle);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  gap: 12px;
  animation: slideIn 0.15s ease-out;
}

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

.staged-icon {
  color: var(--text-secondary);
}

.staged-info {
  flex: 1;
  overflow: hidden;
}

.staged-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staged-size {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background-color: var(--panel-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.text-input:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.select-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background-color: var(--panel-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--text-primary);
}

/* Buttons */
.action-btn {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background-color: var(--panel-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.action-btn:hover:not(:disabled) {
  background-color: var(--accent-bg-subtle);
  border-color: var(--text-primary);
}

.action-btn.primary {
  background-color: var(--accent-color);
  color: var(--panel-bg);
  border-color: transparent;
}

.action-btn.primary:hover:not(:disabled) {
  opacity: 0.9;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 680px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 4px;
}

.modal-close-btn:hover {
  background-color: var(--accent-bg-subtle);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow: auto;
  flex: 1;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--accent-color);
  color: var(--panel-bg);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 200;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-msg.visible {
  transform: translateY(0);
  opacity: 1;
}

/* File previews */
.text-preview {
  width: 100%;
  height: 380px;
  font-family: var(--font-mono);
  font-size: 11px;
  background-color: var(--accent-bg-subtle);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
  white-space: pre;
}

.img-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--accent-bg-subtle);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 20px;
  max-height: 400px;
  overflow: hidden;
}

.img-preview img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  box-shadow: var(--shadow-sm);
  border-radius: 4px;
}

/* Progress status */
.progress-container {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: var(--panel-border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background-color: var(--accent-color);
  transition: width 0.1s ease;
}

/* Hide inactive view states */
.view-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .left-toolbar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 8px 16px;
    border-right: none;
    border-top: 1px solid var(--panel-border);
    justify-content: space-around;
    order: 2; /* Push to bottom */
  }

  .toolbar-section {
    flex-direction: row;
    width: auto;
  }

  .toolbar-divider {
    width: 1px;
    height: 24px;
    margin: 0 8px;
  }

  .canvas-container {
    order: 1;
    height: 100%; /* Take remaining space */
  }

  .canvas-viewport {
    flex-direction: column;
    padding-top: 64px;
    overflow-y: auto;
    height: 100%;
  }

  .workspace-card.main-view {
    min-height: 350px;
    border-bottom: 1px solid var(--panel-border);
  }

  .workspace-card.side-inspector {
    max-width: 100%;
    height: auto;
    border-left: none;
  }
}
