/* ============================================================
   Manhua Translation Editor - Glassmorphism Theme
   Modern, Clean, Canva-level UI Design
   ============================================================ */

/* ---- Fonts ---- */
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/Vazirmatn-latin.woff2') format('woff2'),
       url('../assets/fonts/Vazirmatn-arabic.woff2') format('woff2');
  unicode-range: U+0000-024F, U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE9F, U+10E60-10E7E, U+1EE00-1EEFF;
}

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/Vazirmatn-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* ---- CSS Variables ---- */
:root {
  /* Colors */
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f2e;
  --bg-gradient: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 30%, #0a1a2e 60%, #0a0a1a 100%);
  
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-bg-active: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);
  --glass-blur: 20px;
  --glass-radius: 16px;
  --glass-radius-sm: 10px;
  --glass-radius-xs: 6px;
  
  --accent-primary: #7c5cfc;
  --accent-primary-light: #9b82fc;
  --accent-primary-dark: #5a3cd4;
  --accent-secondary: #06d6a0;
  --accent-warning: #ffd166;
  --accent-danger: #ef476f;
  --accent-info: #118ab2;
  
  --gradient-primary: linear-gradient(135deg, #7c5cfc, #06d6a0);
  --gradient-accent: linear-gradient(135deg, #7c5cfc, #c084fc);
  --gradient-danger: linear-gradient(135deg, #ef476f, #ff6b9d);
  --gradient-success: linear-gradient(135deg, #06d6a0, #118ab2);
  
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.45);
  --text-on-accent: #ffffff;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(124, 92, 252, 0.3);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  
  /* Typography */
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-xs: 11px;
  --font-sm: 12px;
  --font-base: 13px;
  --font-md: 14px;
  --font-lg: 16px;
  --font-xl: 18px;
  --font-2xl: 22px;
  --font-3xl: 28px;
  
  /* Layout */
  --topbar-height: 56px;
  --sidebar-width: 260px;
  --panel-width: 320px;
  --bottombar-height: 52px;
  
  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image: var(--bg-gradient);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  direction: rtl;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Selection */
::selection {
  background: var(--accent-primary);
  color: white;
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ---- Glass Components ---- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
}

.glass-sm {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-sm);
}

.glass-panel {
  background: rgba(15, 15, 46, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--glass-radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(124, 92, 252, 0.2);
}

.btn-primary:hover {
  box-shadow: var(--shadow-md), var(--shadow-glow);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border-color: var(--glass-border);
  backdrop-filter: blur(8px);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: var(--space-sm);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--glass-radius-sm);
}

.btn-icon.sm {
  width: 30px;
  height: 30px;
  font-size: var(--font-xs);
}

.btn-icon.lg {
  width: 44px;
  height: 44px;
  font-size: var(--font-lg);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  border-color: transparent;
}

.btn-danger:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 15px rgba(239, 71, 111, 0.3);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  border-color: transparent;
}

/* ---- Inputs ---- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.input-group label {
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input, input[type="text"], input[type="number"], input[type="url"], 
input[type="color"], select, textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-xs);
  color: var(--text-primary);
  font-size: var(--font-base);
  transition: all var(--transition-fast);
  direction: rtl;
}

.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
  outline: none;
}

.input::placeholder, input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  padding-left: 30px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
  border-radius: var(--glass-radius-xs);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

/* ---- Toggle / Switch ---- */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all var(--transition-fast);
}

.toggle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle.active::after {
  right: calc(100% - 16px);
  background: white;
}

.toggle-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: var(--font-xs);
  font-weight: 600;
  line-height: 1;
}

.badge-primary {
  background: rgba(124, 92, 252, 0.2);
  color: var(--accent-primary-light);
  border: 1px solid rgba(124, 92, 252, 0.3);
}

.badge-success {
  background: rgba(6, 214, 160, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(6, 214, 160, 0.25);
}

.badge-warning {
  background: rgba(255, 209, 102, 0.15);
  color: var(--accent-warning);
  border: 1px solid rgba(255, 209, 102, 0.25);
}

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

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 10px;
  background: rgba(20, 20, 40, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-xs);
  font-size: var(--font-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 1000;
}

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

/* ============================================================
   Layout
   ============================================================ */

/* ---- App Container ---- */
#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  background: rgba(10, 10, 26, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  flex-shrink: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-logo svg {
  width: 28px;
  height: 28px;
}

.topbar-logo .logo-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--glass-border);
  flex-shrink: 0;
}

.topbar-project-name {
  font-size: var(--font-md);
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-sm);
}

.topbar-tools .btn-icon {
  border: none;
  border-radius: var(--glass-radius-xs);
}

.topbar-tools .btn-icon.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.4);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

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

/* ---- Left Sidebar (Pages) ---- */
.sidebar-left {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 26, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--glass-border);
  z-index: 50;
  transition: transform var(--transition-normal), width var(--transition-normal);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-left.collapsed {
  width: 0;
  border-left: none;
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}

.page-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.page-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm);
  border-radius: var(--glass-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  user-select: none;
}

.page-item:hover {
  background: var(--glass-bg-hover);
}

.page-item.active {
  background: rgba(124, 92, 252, 0.1);
  border-color: rgba(124, 92, 252, 0.3);
}

.page-thumb {
  width: 48px;
  height: 64px;
  border-radius: var(--glass-radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

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

.page-info {
  flex: 1;
  min-width: 0;
}

.page-info .page-name {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-info .page-meta {
  font-size: var(--font-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: 2px;
}

.page-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.page-status.untranslated { background: var(--text-muted); }
.page-status.partial { background: var(--accent-warning); }
.page-status.translated { background: var(--accent-secondary); }

/* ---- Canvas Area ---- */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(124, 92, 252, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(6, 214, 160, 0.03) 0%, transparent 50%);
}

.canvas-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
}

.canvas-container:active {
  cursor: grabbing;
}

.canvas-container.tool-select {
  cursor: crosshair;
}

.canvas-container.tool-move {
  cursor: grab;
}

.canvas-container.tool-move:active {
  cursor: grabbing;
}

.canvas-container.tool-text {
  cursor: text;
}

#editorCanvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* Canvas Zoom Indicator */
.canvas-zoom-indicator {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-xs) var(--space-md);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 10;
}

.canvas-zoom-indicator.visible {
  opacity: 1;
}

/* Canvas Controls */
.canvas-controls {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  display: flex;
  gap: var(--space-xs);
  z-index: 10;
}

.canvas-controls .btn-icon {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.canvas-controls .btn-icon:hover {
  background: rgba(0, 0, 0, 0.8);
  color: var(--text-primary);
}

/* Canvas Info */
.canvas-info {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
  z-index: 10;
}

.canvas-info .info-badge {
  padding: var(--space-xs) var(--space-md);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* ---- Right Panel (Translation) ---- */
.panel-right {
  width: var(--panel-width);
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  z-index: 50;
  transition: transform var(--transition-normal), width var(--transition-normal);
  flex-shrink: 0;
  overflow: hidden;
}

.panel-right.collapsed {
  width: 0;
  border-right: none;
}

/* Panel Tabs */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  overflow-x: auto;
}

.panel-tab {
  flex: 1;
  padding: var(--space-md);
  text-align: center;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.panel-tab:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

.panel-tab.active {
  color: var(--accent-primary-light);
  border-bottom-color: var(--accent-primary);
}

/* Panel Content */
.panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg);
  display: none;
}

.panel-content.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Translation Panel */
.original-text-box {
  padding: var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-sm);
  min-height: 60px;
  position: relative;
}

.original-text-box .label {
  position: absolute;
  top: -8px;
  right: 12px;
  padding: 0 6px;
  background: var(--bg-secondary);
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.original-text-box .text-content {
  font-size: var(--font-md);
  color: var(--text-secondary);
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  min-height: 30px;
}

.original-text-box .text-content.empty {
  color: var(--text-muted);
  font-style: italic;
  direction: rtl;
}

.translation-input-area {
  position: relative;
}

.translation-input-area textarea {
  min-height: 100px;
  direction: rtl;
  font-size: var(--font-md);
  line-height: 1.8;
}

/* Region List */
.regions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.region-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.region-item:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
}

.region-item.active {
  background: rgba(124, 92, 252, 0.1);
  border-color: rgba(124, 92, 252, 0.3);
}

.region-item .region-preview {
  width: 36px;
  height: 36px;
  border-radius: var(--glass-radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass-bg);
}

.region-item .region-info {
  flex: 1;
  min-width: 0;
}

.region-item .region-name {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.region-item .region-text {
  font-size: var(--font-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.region-item .region-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.region-item .region-status.done {
  background: var(--accent-secondary);
}

.region-item .region-status.pending {
  background: var(--text-muted);
}

/* ---- Text Styling Section ---- */
.style-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.style-section .section-title {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Style Presets */
.style-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.style-preset {
  padding: var(--space-sm);
  border-radius: var(--glass-radius-xs);
  text-align: center;
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
}

.style-preset:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
}

.style-preset.active {
  background: rgba(124, 92, 252, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary-light);
}

.style-preset .preset-icon {
  font-size: 16px;
  display: block;
  margin-bottom: 2px;
}

/* Font Controls */
.font-controls {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: var(--space-sm);
}

.font-controls select {
  grid-column: 1 / -1;
}

/* Size & Spacing */
.size-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.size-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.size-control label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.size-control input {
  text-align: center;
  padding: var(--space-xs) var(--space-sm);
}

/* Alignment */
.align-controls {
  display: flex;
  gap: var(--space-xs);
}

.align-controls .btn-icon {
  flex: 1;
}

.align-controls .btn-icon.active {
  background: var(--accent-primary);
  color: white;
}

/* Style Toggles */
.style-toggles {
  display: flex;
  gap: var(--space-xs);
}

.style-toggles .btn-icon {
  flex: 1;
}

.style-toggles .btn-icon.active {
  background: var(--accent-primary);
  color: white;
}

/* Color Controls */
.color-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.color-controls input[type="color"] {
  flex-shrink: 0;
}

.color-controls .color-presets {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.color-preset {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.color-preset:hover {
  transform: scale(1.15);
}

.color-preset.active {
  border-color: white;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* Effects */
.effects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.effect-item {
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--glass-radius-sm);
  text-align: center;
  font-size: var(--font-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
}

.effect-item:hover {
  background: var(--glass-bg-hover);
}

.effect-item.active {
  background: rgba(124, 92, 252, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary-light);
}

.effect-item .effect-icon {
  font-size: 20px;
  display: block;
  margin-bottom: 4px;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  padding: var(--space-xl);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  background: rgba(15, 15, 46, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-overlay.visible .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: var(--font-xl);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-xl);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-start;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* ---- Upload Zone ---- */
.upload-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--glass-radius);
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-primary);
}

.upload-zone:hover::before, .upload-zone.dragover::before {
  opacity: 0.05;
}

.upload-zone-content {
  position: relative;
  z-index: 1;
}

.upload-zone-icon {
  font-size: 48px;
  margin-bottom: var(--space-lg);
  opacity: 0.7;
}

.upload-zone h3 {
  font-size: var(--font-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.upload-zone p {
  font-size: var(--font-base);
  color: var(--text-muted);
}

.upload-url-section {
  margin-top: var(--space-xl);
  display: flex;
  gap: var(--space-sm);
}

.upload-url-section input {
  flex: 1;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-top: var(--space-lg);
  font-size: var(--font-md);
  color: var(--text-secondary);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

.toast {
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--glass-radius-sm);
  font-size: var(--font-sm);
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--transition-spring) forwards;
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: 400px;
}

.toast.success {
  background: rgba(6, 214, 160, 0.9);
  border: 1px solid rgba(6, 214, 160, 0.5);
}

.toast.error {
  background: rgba(239, 71, 111, 0.9);
  border: 1px solid rgba(239, 71, 111, 0.5);
}

.toast.info {
  background: rgba(124, 92, 252, 0.9);
  border: 1px solid rgba(124, 92, 252, 0.5);
}

.toast.warning {
  background: rgba(255, 209, 102, 0.9);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: #1a1a2e;
}

.toast.leaving {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(20px) scale(0.9); }
}

/* ---- Empty States ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  text-align: center;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--space-xl);
  opacity: 0.4;
}

.empty-state h3 {
  font-size: var(--font-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.empty-state p {
  font-size: var(--font-base);
  color: var(--text-muted);
  max-width: 300px;
  margin-bottom: var(--space-xl);
}

/* ---- Welcome Screen ---- */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.welcome-card {
  width: 100%;
  max-width: 520px;
  padding: var(--space-3xl);
  text-align: center;
}

.welcome-card .welcome-icon {
  font-size: 64px;
  margin-bottom: var(--space-xl);
}

.welcome-card h1 {
  font-size: var(--font-2xl);
  font-weight: 700;
  margin-bottom: var(--space-sm);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card .subtitle {
  font-size: var(--font-md);
  color: var(--text-muted);
  margin-bottom: var(--space-2xl);
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
  text-align: right;
}

.welcome-feature {
  padding: var(--space-md);
  border-radius: var(--glass-radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.welcome-feature .feature-icon {
  font-size: 20px;
  margin-bottom: var(--space-xs);
}

.welcome-feature h4 {
  font-size: var(--font-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.welcome-feature p {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* ---- Export Modal ---- */
.export-options {
  display: grid;
  gap: var(--space-lg);
}

.export-option {
  padding: var(--space-lg);
  border-radius: var(--glass-radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.export-option:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}

.export-option .export-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: var(--glass-radius-sm);
  background: var(--glass-bg);
  flex-shrink: 0;
}

.export-option .export-info h4 {
  font-size: var(--font-md);
  font-weight: 600;
  margin-bottom: 2px;
}

.export-option .export-info p {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

/* ---- Recent Projects ---- */
.recent-projects {
  margin-top: var(--space-2xl);
  text-align: right;
}

.recent-projects h3 {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 200px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--glass-radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-item:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
}

.project-item .project-icon {
  font-size: 24px;
}

.project-item .project-info {
  flex: 1;
}

.project-item .project-info h4 {
  font-size: var(--font-sm);
  font-weight: 500;
}

.project-item .project-info p {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* ============================================================
   Mobile Responsive
   ============================================================ */

@media (max-width: 1024px) {
  :root {
    --panel-width: 280px;
    --sidebar-width: 220px;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 48px;
    --panel-width: 100%;
    --sidebar-width: 100%;
  }

  body {
    direction: rtl;
  }

  .topbar {
    padding: 0 var(--space-md);
  }

  .topbar-project-name {
    display: none;
  }

  .topbar-divider:first-of-type {
    display: none;
  }

  /* Sidebar becomes overlay on mobile */
  .sidebar-left {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar-left.open {
    transform: translateX(0);
  }

  .sidebar-left.collapsed {
    width: 280px;
    transform: translateX(100%);
  }

  /* Right panel becomes bottom sheet */
  .panel-right {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 60vh;
    border-right: none;
    border-top: 1px solid var(--glass-border);
    border-radius: var(--glass-radius) var(--glass-radius) 0 0;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    z-index: 200;
  }

  .panel-right.open {
    transform: translateY(0);
  }

  .panel-right.collapsed {
    width: 100%;
    transform: translateY(100%);
  }

  /* Mobile bottom bar */
  .mobile-bottombar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottombar-height);
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    z-index: 150;
    align-items: center;
    justify-content: space-around;
    padding: 0 var(--space-sm);
  }

  .canvas-area {
    padding-bottom: var(--bottombar-height);
  }

  .canvas-controls {
    bottom: calc(var(--bottombar-height) + var(--space-md));
  }

  .mobile-overlay {
    display: block;
  }

  .welcome-features {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    padding: var(--space-xl);
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    margin: var(--space-md);
  }
}

@media (max-width: 480px) {
  .topbar-tools {
    gap: 2px;
    padding: 2px;
  }
  
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: var(--font-xs);
  }
}

/* ---- Desktop-only ---- */
.mobile-bottombar {
  display: none;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

/* ---- Utilities ---- */
.hidden { display: none !important; }
.visible { display: flex !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-primary-light); }
.font-bold { font-weight: 700; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }

/* Animation helpers */
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

/* ---- Keyboard shortcuts modal ---- */
.shortcuts-grid {
  display: grid;
  gap: var(--space-sm);
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.shortcut-row .shortcut-keys {
  display: flex;
  gap: var(--space-xs);
}

.shortcut-row kbd {
  padding: 2px 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  font-size: var(--font-xs);
  font-family: monospace;
  color: var(--text-secondary);
}

.shortcut-row .shortcut-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ---- Scrollable panel sections ---- */
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
}

.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---- No-select areas ---- */
.no-select {
  user-select: none;
  -webkit-user-select: none;
}
