/* =========================================================
   ROOT THEME VARIABLES
   ========================================================= */

:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --textarea-bg: #f8fafc;
  --text-muted: #64748b;
  --text-dark: #0f172a;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dark {
  --background: #000000;
  --foreground: #ffffff;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #172554;
  --border: #262626;
  --card-bg: #0a0a0a;
  --textarea-bg: #050505;
  --text-muted: #a3a3a3;
  --text-dark: #ffffff;
  --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* =========================================================
   GLOBAL RESET
   ========================================================= */

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
               "Segoe UI Arabian", "Noto Sans Arabic", "Scheherazade New", "Amiri",
               "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", "Segoe UI Urdu",
               "Noto Sans Devanagari", "Kohinoor Devanagari", "Mangal", "Arial Unicode MS",
               "Noto Sans Thai", "Segoe UI Thai", "Leelawadee",
               "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", "MS Gothic",
               "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
               "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic",
               sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

/* =========================================================
   LAYOUT STRUCTURE
   ========================================================= */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background-color: var(--card-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

@media (min-width: 1024px) {
  .header-content {
    padding: 0 32px;
  }
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

@media (min-width: 768px) {
  .logo-text h1 {
    font-size: 22px;
  }
}

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

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 32px;
  margin-inline-end: 16px;
}

@media (min-width: 1024px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  opacity: 0.8;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  opacity: 1;
  color: var(--primary);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--foreground);
  transition: background-color 0.2s ease;
}

.icon-btn:hover {
  background-color: var(--textarea-bg);
}

.menu-btn {
  display: flex;
}

@media (min-width: 1024px) {
  .menu-btn {
    display: none;
  }
}

/* Sidebar & Main Wrapper */
.main-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
}

/* Sidebar */
.app-sidebar {
  display: none;
  width: 340px;
  flex-shrink: 0;
  border-inline-end: 1px solid var(--border);
  background-color: var(--card-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

@media (min-width: 1024px) {
  .app-sidebar {
    display: block;
  }
}

.sidebar-sticky {
  position: sticky;
  top: 64px;
  padding: 20px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-dark);
}

/* Main Content Area */
.app-main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  background-color: var(--background);
  transition: background-color 0.2s ease;
}

@media (min-width: 768px) {
  .app-main {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .app-main {
    padding: 32px;
  }
}

.content-container {
  max-width: 896px;
  margin: 0 auto;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  background-color: var(--card-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.footer-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 767px) {
  .footer-content {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

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

.footer-links {
  display: none;
  gap: 24px;
}

@media (min-width: 768px) {
  .footer-links {
    display: flex;
  }
}

.footer-link {
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--primary);
}

/* =========================================================
   UI COMPONENTS
   ========================================================= */

/* Language Navigation Menu */
.lang-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  width: 100%;
  text-align: start;
}

.lang-link:not(.active) {
  color: var(--foreground);
}

.lang-link:not(.active):hover {
  border-color: var(--border);
  background-color: var(--textarea-bg);
}

.lang-link.active {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.lang-flag {
  width: 32px;
  height: 24px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  flex-shrink: 0;
}

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

.lang-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.lang-native {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.lang-link.active .lang-native {
  color: rgba(255, 255, 255, 0.8);
}

/* Mobile Drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background-color: rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  height: 100%;
  height: 100dvh;
  width: 280px;
  max-width: 85vw;
  background-color: var(--card-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
  display: flex;
  flex-direction: column;
  visibility: hidden;
}

.mobile-drawer.open {
  transform: translateX(0);
  visibility: visible;
}

/* Prevent background scroll when drawer is open */
.no-scroll {
  overflow: hidden !important;
  height: 100% !important;
}

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

.drawer-title {
  font-size: 18px;
  font-weight: 700;
}

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

/* Main Keyboard Area Page elements */
.biscuit-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.page-title span {
  color: var(--primary);
}

@media (min-width: 640px) {
  .page-title {
    font-size: 36px;
  }
}

@media (min-width: 1024px) {
  .page-title {
    font-size: 42px;
  }
}

.page-description {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .page-description {
    font-size: 16px;
  }
}

/* Textarea input */
.keyboard-textarea {
  width: 100%;
  min-height: 180px;
  resize: none;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: var(--textarea-bg);
  padding: 20px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--foreground);
  caret-color: var(--foreground);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 1024px) {
  .keyboard-textarea {
    min-height: 220px;
  }
}

.keyboard-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.keyboard-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Action Bar */
.action-bar {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: var(--card-bg);
  color: var(--foreground);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  user-select: none;
}

.action-btn:hover {
  background-color: var(--textarea-bg);
  box-shadow: var(--shadow-md);
}

.action-btn:active {
  transform: scale(0.96);
}

/* Virtual Keyboard Card Container */
.keyboard-container {
  margin-top: 20px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background-color: var(--card-bg);
  padding: 8px;
  box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
  .keyboard-container {
    margin-top: 24px;
    padding: 16px;
  }
}

/* SVGs for icons */
.svg-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================
   SIMPLE KEYBOARD CUSTOMIZATION & OVERRIDES
   ========================================================= */

.simple-keyboard {
  width: 100% !important;
  background: var(--card-bg) !important;
  border-radius: 12px !important;
  padding: 0 !important;
  box-shadow: none !important;
  color: var(--foreground) !important;
  border: none !important;
  touch-action: manipulation;
}

.simple-keyboard .hg-row .hg-button {
  margin-inline-end: 5px !important;
  margin-inline-start: 0 !important;
}

.simple-keyboard .hg-row > .hg-button:last-child,
.simple-keyboard .hg-row > div:last-child {
  margin-inline-end: 0 !important;
}

.simple-keyboard .hg-row {
  margin-bottom: 8px;
  display: flex;
}

.simple-keyboard .hg-row:last-child {
  margin-bottom: 0;
}

.simple-keyboard .hg-button {
  height: 52px !important;
  border-radius: 10px !important;
  border: 1px solid var(--border) !important;
  background: var(--card-bg) !important;
  color: var(--foreground) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  font-family: inherit !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease !important;
  box-shadow: var(--shadow-sm) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.simple-keyboard .hg-button:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--text-dark) !important;
}

.simple-keyboard .hg-button:active {
  transform: scale(0.96) !important;
}

/* Space, backspace, caps lock custom sizes/styling */
.simple-keyboard .hg-button[data-skbtn="{space}"] {
  flex-grow: 5;
  font-weight: 600;
}

.simple-keyboard .hg-button[data-skbtn="{bksp}"] {
  font-size: 22px;
  background-color: var(--textarea-bg) !important;
}

.simple-keyboard .hg-button[data-skbtn="{capslock}"] {
  background-color: var(--textarea-bg) !important;
}

.simple-keyboard .hg-button.hg-activeButton {
  background: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary) !important;
}

/* RTL layouts configuration styles */
.rtl-layout {
  direction: rtl;
}

.rtl-layout .keyboard-textarea {
  direction: rtl;
  text-align: right;
}

.rtl-layout .simple-keyboard .hg-row {
  flex-direction: row-reverse;
}

/* =========================================================
   RESPONSIVE DESIGN FOR KEYBOARD
   ========================================================= */

@media (max-width: 768px) {
  .simple-keyboard .hg-button {
    height: 48px !important;
    min-width: 0 !important;
    padding: 0 4px !important;
    border-radius: 8px !important;
    font-size: 17px !important;
  }
  
  .simple-keyboard .hg-button[data-skbtn="{bksp}"] {
    font-size: 20px !important;
  }
}

@media (max-width: 480px) {
  .simple-keyboard .hg-row {
    margin-bottom: 6px;
  }

  .simple-keyboard .hg-button {
    height: 44px !important;
    padding: 0 2px !important;
    border-radius: 6px !important;
    font-size: 15px !important;
  }

  .simple-keyboard .hg-button[data-skbtn="{bksp}"] {
    font-size: 18px !important;
  }
}

/* =========================================================
   LONG-FORM INFO CONTENT STYLING
   ========================================================= */

.content-section {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding-top: 40px;
  transition: border-color 0.2s ease;
}

.section-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.section-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.section-title span {
  color: var(--primary);
}

@media (min-width: 768px) {
  .section-title {
    font-size: 26px;
  }
}

.section-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.section-p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--foreground);
  margin-bottom: 16px;
  opacity: 0.9;
}

/* Cards & Grids */
.columns-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .columns-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

.feature-grid-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .feature-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .feature-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.info-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.info-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.card-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Real Life Use Case & Topics Layout */
.flex-split-row {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

@media (min-width: 768px) {
  .flex-split-row {
    flex-direction: row;
  }
}

.split-left-card {
  flex: 1;
  background-color: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 16px;
  padding: 24px;
}

.split-left-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bullet-item {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
  position: relative;
  padding-inline-start: 20px;
}

.bullet-item::before {
  content: "✓";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  color: var(--primary);
  font-weight: 700;
}

.split-right-grid {
  flex: 1.2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 767px) {
  .split-right-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.topic-badge {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.topic-badge:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.topic-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

/* FAQ Accordion Details Styles */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.faq-item {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-item[open] {
  border-color: var(--primary);
}

.faq-question {
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.faq-item[open] .faq-question::after {
  content: "−";
}

.faq-answer {
  padding: 0 20px 16px 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  border-top: 1px solid transparent;
}

.faq-item[open] .faq-answer {
  border-top-color: var(--border);
  padding-top: 12px;
}
