/* ============================================================
   HTML & CSS Reference — Modern Clean Theme
   ============================================================ */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --primary-bg: #eef2ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --sidebar-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --code-keyword: #c084fc;
  --code-string: #34d399;
  --code-tag: #60a5fa;
  --code-attr: #fbbf24;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-width: 300px;
  --header-height: 56px;
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', 'Nafees Nastaleeq', serif;
  --font-code: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-en);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

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

/* --- Sidebar --- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  user-select: none;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-xs);
  font-family: var(--font-code);
  font-size: 14px;
  font-weight: 700;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: var(--border-light);
  transition: all 0.15s ease;
  margin-right: auto;
}

.back-link:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

.sidebar-close:hover {
  background: var(--border-light);
  color: var(--text);
}

/* --- Language Toggle --- */
.lang-toggle {
  display: flex;
  margin: 12px 16px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.lang-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-family: var(--font-en);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.lang-btn[data-lang="ur"] {
  font-family: var(--font-ur);
  font-size: 15px;
}

.lang-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.lang-btn:hover:not(.active) {
  color: var(--text);
}

/* --- Search --- */
.sidebar-search {
  position: relative;
  margin: 0 16px 12px;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-en);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

/* --- Sidebar Navigation --- */
#sidebarNav {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
}

#sidebarNav::-webkit-scrollbar {
  width: 4px;
}

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

#sidebarNav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

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

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: default;
}

.nav-icon {
  font-size: 14px;
}

.nav-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 2px 7px;
  border-radius: 10px;
}

.nav-list {
  list-style: none;
}

.nav-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px 7px 32px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.nav-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 0 3px 3px 0;
  transition: background 0.15s ease;
}

.nav-list li:hover {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.nav-list li:hover::before {
  background: var(--primary-light);
}

.nav-list li.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 500;
}

.nav-list li.active::before {
  background: var(--primary);
}

.nav-list li .tag-badge {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 0 6px;
  border-radius: 4px;
  opacity: 0.8;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
  opacity: 1;
}

/* --- Main Content --- */
#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-open {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  margin-right: 12px;
}

.sidebar-open:hover {
  background: var(--border-light);
  color: var(--text);
}

.top-bar-spacer {
  flex: 1;
}

.top-bar-info {
  font-size: 13px;
  color: var(--text-muted);
}

.total-count {
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Content Area (scrollable) --- */
.topic-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.content-area {
  padding: 32px 40px 80px;
  max-width: 900px;
}

.content-area::-webkit-scrollbar {
  width: 6px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* --- Welcome Screen --- */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.welcome-content {
  text-align: center;
  max-width: 480px;
}

.welcome-icon {
  font-size: 48px;
  font-family: var(--font-code);
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-bg);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  margin: 0 auto 24px;
}

.welcome-content h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.welcome-sub {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.welcome-langs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.welcome-lang {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
}

.welcome-lang-sep {
  color: var(--text-muted);
}

.welcome-lang.urdu-text {
  font-family: var(--font-ur);
  font-size: 20px;
}

.welcome-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 28px;
}

.welcome-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  box-shadow: var(--shadow-sm);
}

.welcome-stat-num {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.welcome-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

.welcome-hint {
  font-size: 14px;
  color: var(--text-muted);
}

/* --- Article Content Styles --- */
.content-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.content-header .tag-syntax {
  display: inline-block;
  font-family: var(--font-code);
  font-size: 14px;
  padding: 4px 12px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: var(--radius-xs);
  margin-bottom: 12px;
}

.content-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.content-header .head-sub {
  font-family: var(--font-ur);
  font-size: 20px;
  color: var(--text-secondary);
  direction: rtl;
  text-align: right;
}

.content-header .cat-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--border-light);
  padding: 3px 10px;
  border-radius: 12px;
  margin-top: 8px;
}

.description-block {
  margin-bottom: 20px;
}

.description-block p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.description-block .urdu-text {
  font-family: var(--font-ur);
  font-size: 18px;
  direction: rtl;
  text-align: right;
  line-height: 1.9;
  color: var(--text);
  padding: 16px 20px;
  background: #fefce8;
  border-radius: var(--radius-sm);
  border-right: 4px solid var(--warning);
}

/* --- Code Example Display --- */
.code-example-block {
  margin-bottom: 24px;
}

.code-example-block .example-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.code-example-block pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

/* Simple syntax highlighting within pre tags */
.code-example-block pre .tag { color: var(--code-tag); }
.code-example-block pre .attr { color: var(--code-attr); }
.code-example-block pre .string { color: var(--code-string); }
.code-example-block pre .keyword { color: var(--code-keyword); }
.code-example-block pre .comment { color: #64748b; font-style: italic; }

/* --- Attributes / Values Table --- */
.attrs-table, .values-table {
  margin-bottom: 24px;
}

.attrs-table h3, .values-table h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.attrs-table table, .values-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.attrs-table th, .values-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--border-light);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.attrs-table td, .values-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

.attrs-table td:first-child, .values-table td:first-child {
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
}

.attrs-table tr:hover td, .values-table tr:hover td {
  background: var(--primary-bg);
}

.attrs-table .urdu-text, .values-table .urdu-text {
  font-family: var(--font-ur);
  font-size: 16px;
}

/* --- Live Editor Section --- */
.live-editor-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 2px solid var(--border);
}

.live-editor-section .editor-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.live-editor-section .editor-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.editor-container {
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.editor-lang-label {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.editor-btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font-en);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-btn.run-btn {
  background: var(--primary);
  color: white;
}

.editor-btn.run-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.editor-btn.reset-btn {
  background: #334155;
  color: var(--text-muted);
}

.editor-btn.reset-btn:hover {
  background: #475569;
  color: var(--code-text);
}

.editor-textarea {
  width: 100%;
  min-height: 120px;
  padding: 16px 20px;
  background: transparent;
  border: none;
  color: var(--code-text);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  tab-size: 2;
}

.preview-container {
  border-top: 1px solid #334155;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.preview-iframe {
  width: 100%;
  min-height: 120px;
  background: white;
  border: none;
  display: block;
}

/* --- RTL / Urdu Mode --- */
html[lang="ur"] .urdu-text {
  font-family: var(--font-ur);
}

html[lang="ur"] .lang-toggle .lang-btn[data-lang="ur"],
html[lang="en"] .lang-toggle .lang-btn[data-lang="en"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-close {
    display: block;
  }

  .sidebar-open {
    display: block;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .content-area {
    padding: 20px 16px 60px;
  }

  .welcome-stats {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .welcome-content h1 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .content-area {
    padding: 16px 12px 60px;
  }

  .welcome-icon {
    width: 60px;
    height: 60px;
    font-size: 36px;
  }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-area > * {
  animation: fadeIn 0.25s ease forwards;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

.no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
