/* RXA Dither & ASCII Studio · Stylesheet
 * Rồng Xanh 2026 Brand Design System
 */
:root {
  --rx-blue: #2658B7;
  --rx-blue-hover: #1e4796;
  --rx-blue-soft: rgba(38, 88, 183, 0.12);
  --rx-purple: #582C83;
  --rx-orange: #FF5722;
  --rx-sand: #E5C28C;
  --rx-cyan: #29F1C3;
  --rx-lime: #D5FF5C;
  --rx-sky: #CEE9FE;
  
  --bg-app: #0D1117;
  --bg-sidebar: #161B22;
  --bg-panel: #21262D;
  --bg-panel-subtle: #1A1F27;
  --bg-input: #0D1117;
  --border-color: #30363D;
  --border-hover: #484F58;
  
  --text-main: #F0F6FC;
  --text-muted: #8B949E;
  --text-dim: #6E7681;
  --text-accent: #58A6FF;

  --sidebar-w: 390px;
  --topbar-h: 56px;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 18px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  background: linear-gradient(135deg, var(--rx-blue), #183b80);
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.brand-titles h1 {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles p {
  font-size: 11px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lang {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-lang:hover {
  background: var(--border-hover);
}

/* Main Workspace */
.main-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Center Stage Viewport */
.viewport-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #080B10;
  overflow: hidden;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.view-mode-selector {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn.active {
  background: var(--rx-blue);
  color: #FFFFFF;
  font-weight: 600;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.icon-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--border-hover);
  color: #fff;
}

/* Canvas Canvas Stage */
.canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 20px 20px;
}

.canvas-wrapper.panning {
  cursor: grabbing;
}

.canvas-transform-layer {
  position: relative;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
}

#renderCanvas, #sourceCanvas {
  display: block;
}

#sourceCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Split Slider Handle */
.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--rx-cyan);
  box-shadow: 0 0 10px var(--rx-cyan);
  cursor: ew-resize;
  z-index: 5;
  pointer-events: auto;
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  background: #FFFFFF;
  border: 2px solid var(--rx-blue);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--rx-blue);
  font-weight: 700;
  user-select: none;
}

/* Stage Bottom Info Bar */
.stage-infobar {
  height: 28px;
  padding: 0 16px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.loading-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--rx-cyan);
  font-weight: 500;
}

.loading-indicator.active {
  display: flex;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(41, 241, 195, 0.3);
  border-top-color: var(--rx-cyan);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Right Control Sidebar */
.control-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 10;
}

/* Sidebar Tab Nav */
.sidebar-tabs {
  display: flex;
  background: var(--bg-panel-subtle);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.sidebar-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--rx-blue);
  border-bottom-color: var(--rx-blue);
  background: var(--rx-blue-soft);
}

/* Sidebar Scroll Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.sidebar-pane.active {
  display: flex;
}

/* Control Group Panels */
.control-group {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-title span.badge {
  background: var(--rx-blue-soft);
  color: var(--text-accent);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: none;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.control-label {
  color: var(--text-main);
  font-weight: 500;
}

.control-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-accent);
}

.control-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Slider Style */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  border: 1px solid var(--border-color);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--rx-blue);
  border: 2px solid #FFFFFF;
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--rx-cyan);
}

/* Select & Inputs */
select, input[type="text"] {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

select:focus, input[type="text"]:focus {
  border-color: var(--rx-blue);
}

/* Checkbox Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

input[type="checkbox"]:checked + .toggle-switch {
  background: var(--rx-blue);
  border-color: var(--rx-blue);
}

input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: #FFFFFF;
}

input[type="checkbox"] {
  display: none;
}

/* Preset Cards Grid */
.preset-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-card:hover {
  border-color: var(--rx-blue);
  background: var(--bg-panel-subtle);
  transform: translateY(-1px);
}

.preset-card.active {
  border-color: var(--rx-blue);
  background: var(--rx-blue-soft);
  box-shadow: 0 0 0 1px var(--rx-blue);
}

.preset-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.preset-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preset-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.preset-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--rx-blue);
  background: var(--rx-blue-soft);
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 6px;
  color: var(--rx-blue);
}

.dropzone-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.sample-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.sample-thumb {
  flex: 1;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.sample-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-thumb:hover {
  border-color: var(--rx-cyan);
  transform: scale(1.03);
}

.sample-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  font-size: 9px;
  text-align: center;
  color: #fff;
  padding: 2px 0;
}

/* Color Sliders Grid */
.color-ratio-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.color-ratio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.color-tag {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Primary Action Buttons */
.btn-primary {
  background: var(--rx-blue);
  color: #FFFFFF;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  width: 100%;
}

.btn-primary:hover {
  background: var(--rx-blue-hover);
  box-shadow: 0 4px 12px rgba(38, 88, 183, 0.4);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
  width: 100%;
}

.btn-secondary:hover {
  background: var(--border-hover);
  border-color: var(--text-muted);
}

.btn-accent {
  background: linear-gradient(135deg, var(--rx-cyan), #00C896);
  color: #071724;
  border: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
  width: 100%;
}

.btn-accent:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(41, 241, 195, 0.3);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1F242C;
  color: #FFFFFF;
  border: 1px solid var(--rx-cyan);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 960px) {
  .app-container {
    flex-direction: column;
  }
  .main-workspace {
    flex-direction: column;
  }
  .control-sidebar {
    width: 100%;
    height: 45vh;
  }
}
