/* ===== SEN Language Editor - Modern UI Styles ===== */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #ec4899;
  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-tertiary: #94a3b8;
  --border-radius: 12px;
  --transition: all 0.3s ease;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --sidebar-width: 280px;
  --panel-padding: 20px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ===== Autocomplete Dropdown ===== */
.autocomplete-dropdown {
  position: absolute;
  z-index: 9999;
  background: #1e293b;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.2);
  max-height: 300px;
  overflow-y: auto;
  min-width: 350px;
  max-width: 500px;
  animation: dropdownFadeIn 0.15s ease;
  backdrop-filter: blur(10px);
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.autocomplete-item {
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.1s ease;
  color: var(--text-secondary);
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(99, 102, 241, 0.25);
}

.autocomplete-item.selected {
  border-left: 3px solid var(--accent-primary);
  padding-left: 12px;
}

.ac-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.ac-text {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c792ea;
}

.ac-text strong {
  color: #ffcb6b;
  text-decoration: underline;
}

.ac-type {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}

.ac-desc {
  color: var(--text-tertiary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  flex-shrink: 1;
}

/* Autocomplete scrollbar */
.autocomplete-dropdown::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ===== Tutorial Overlay ===== */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.tutorial-overlay.hidden {
  display: none;
}

.tutorial-modal {
  width: 80%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.tutorial-header {
  padding: 30px;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--accent-secondary));
  position: relative;
}

.tutorial-logo {
  font-size: 48px;
  margin-bottom: 15px;
  animation: float 3s ease-in-out infinite;
}

.tutorial-header h2 {
  font-size: 28px;
  margin-bottom: 8px;
  background: linear-gradient(to right, #fff, #bbf7d0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tutorial-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.8);
}

.tutorial-tabs {
  display: flex;
  background: var(--bg-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
}

.tutorial-tab {
  padding: 15px 20px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tutorial-tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.tutorial-tab.active {
  color: var(--accent-primary);
  border-bottom: 2px solid var(--accent-primary);
}

.tutorial-content {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
}

.tutorial-panel {
  display: none;
}

.tutorial-panel.active {
  display: block;
}

.tutorial-section {
  margin-bottom: 30px;
}

.tutorial-section h3 {
  font-size: 20px;
  margin-bottom: 15px;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tutorial-section h4 {
  font-size: 16px;
  margin: 20px 0 10px;
  color: var(--text-secondary);
}

.tutorial-section p {
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-bottom: 15px;
}

.code-example {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  margin: 15px 0;
  overflow-x: auto;
  border-left: 3px solid var(--accent-primary);
}

.tags-table, .shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.tags-table th, .shortcuts-table th {
  background: rgba(99, 102, 241, 0.2);
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
}

.tags-table td, .shortcuts-table td {
  padding: 12px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.shortcut-key {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  margin: 0 2px;
}

.shape-grid {
  display: flex;
  gap: 15px;
  margin: 15px 0;
  flex-wrap: wrap;
}

.shape-demo {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  padding: 12px 15px;
  font-family: monospace;
  min-width: 120px;
  text-align: center;
}

.tutorial-footer {
  padding: 20px;
  background: var(--bg-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tutorial-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
}

.tutorial-checkbox input {
  width: 18px;
  height: 18px;
}

.tutorial-close-btn {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tutorial-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

/* ===== App Layout ===== */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-header {
  padding: 25px 20px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
}

.logo-icon {
  font-size: 32px;
  animation: pulse 2s infinite;
}

.logo h1 {
  font-size: 22px;
  background: linear-gradient(to right, var(--accent-primary), var(--accent-tertiary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.tagline {
  color: var(--text-tertiary);
  font-size: 14px;
  margin-bottom: 20px;
}

.help-btn {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 8px;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
}

.help-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  scroll-behavior: smooth;
}

.nav-section {
  margin-bottom: 25px;
}

.nav-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  padding: 0 20px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-btn {
  display: flex;
  align-items: center;
  width: calc(100% - 40px);
  margin: 0 20px 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-size: 12px;
  gap: 6px;
}

.nav-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  transform: translateX(5px);
}

.nav-btn.active {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.ref-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 13px;
}

.ref-tag {
  color: var(--accent-primary);
  font-family: monospace;
}

.ref-desc {
  color: var(--text-tertiary);
}

.sidebar-footer {
  padding: 20px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.fps-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-tertiary);
}

.fps-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.credits {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.file-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.tab-icon {
  font-size: 18px;
}

.tab-name {
  color: var(--text-secondary);
}

.panel-actions {
  display: flex;
  gap: 15px;
}

.badge {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.line-count {
  color: var(--text-tertiary);
  font-size: 14px;
}

.editor-panel, .preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-panel {
  background: white;
}

/* ===== Editor ===== */
.editor-container {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-primary);
}

.line-numbers {
  width: 50px;
  background: rgba(0, 0, 0, 0.2);
  padding: 20px 10px;
  text-align: right;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-tertiary);
  overflow: hidden;
  user-select: none;
}

.code-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.sen-editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: #e2e8f0;
  background: #1a1a2e;
  border: none;
  resize: none;
  outline: none;
  caret-color: var(--accent-primary);
  white-space: pre;
  overflow: auto;
  z-index: 2;
}

.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre;
  overflow-wrap: break-word;
  color: #94a3b8;
  pointer-events: none;
  z-index: 1;
  overflow: auto;
  background: transparent;
}

/* ===== Preview ===== */
.preview-container {
  flex: 1;
  overflow: hidden;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

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

.toast {
  padding: 15px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  min-width: 300px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.toast.error {
  background: linear-gradient(135deg, #ef4444, #f87171);
}

.toast.warning {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.toast.info {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.toast.fade-out {
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

/* ===== Split View ===== */
.split-view .editor-panel,
.split-view .preview-panel {
  display: flex !important;
  flex-direction: column;
  height: 50%;
}

.split-view .preview-panel {
  border-top: 2px solid var(--accent-primary);
}

/* ===== Animations ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .tutorial-modal {
    width: 95%;
    height: 95vh;
  }
  
  .tutorial-tabs {
    flex-wrap: wrap;
  }
  
  .autocomplete-dropdown {
    max-width: 90vw;
    min-width: 250px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 50vh;
  }
  
  .main-content {
    height: 50vh;
  }
  
  .tutorial-modal {
    width: 95vw;
    height: 95vh;
  }
  
  .tutorial-content {
    padding: 15px;
  }
  
  .shape-grid {
    flex-direction: column;
  }
  
  .tutorial-footer {
    flex-direction: column;
    gap: 15px;
  }
  
  .autocomplete-dropdown {
    max-width: 80vw;
    min-width: 200px;
  }
  
  .ac-desc {
    display: none;
  }
}