/* Keyboard Style Sheet & Themes */
:root {
  --kb-bg: #0f172a;
  --kb-row-gap: 6px;
  --kb-key-gap: 4px;
  --kb-key-bg: #1e293b;
  --kb-key-text: #f8fafc;
  --kb-key-border: rgba(255, 255, 255, 0.08);
  --kb-key-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  --kb-key-hover: #334155;
  --kb-key-active: #0284c7;
  --kb-special-bg: #0b1329;
  --kb-accent: #38bdf8;
  --kb-radius: 12px;
}

/* Theme Classes */
body.theme-midnight {
  --kb-bg: #0f172a;
  --kb-key-bg: #1e293b;
  --kb-key-text: #f1f5f9;
  --kb-key-border: rgba(255, 255, 255, 0.08);
  --kb-key-hover: #334155;
  --kb-key-active: #0284c7;
  --kb-special-bg: #020617;
  --kb-accent: #38bdf8;
}

body.theme-cyber-neon {
  --kb-bg: #05050e;
  --kb-key-bg: #131427;
  --kb-key-text: #67e8f9;
  --kb-key-border: rgba(6, 182, 212, 0.3);
  --kb-key-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
  --kb-key-hover: #1e2042;
  --kb-key-active: #06b6d4;
  --kb-special-bg: #0a0a1a;
  --kb-accent: #22d3ee;
}

body.theme-oled {
  --kb-bg: #000000;
  --kb-key-bg: #121212;
  --kb-key-text: #ffffff;
  --kb-key-border: #27272a;
  --kb-key-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
  --kb-key-hover: #262626;
  --kb-key-active: #10b981;
  --kb-special-bg: #080808;
  --kb-accent: #34d399;
}

body.theme-emerald {
  --kb-bg: #06241b;
  --kb-key-bg: #0f3d2f;
  --kb-key-text: #ecfdf5;
  --kb-key-border: rgba(52, 211, 153, 0.2);
  --kb-key-shadow: 0 2px 0 rgba(2, 44, 34, 0.6);
  --kb-key-hover: #134e3a;
  --kb-key-active: #10b981;
  --kb-special-bg: #041913;
  --kb-accent: #10b981;
}

body.theme-gold {
  --kb-bg: #1c1408;
  --kb-key-bg: #2d210e;
  --kb-key-text: #fef08a;
  --kb-key-border: rgba(250, 204, 21, 0.25);
  --kb-key-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  --kb-key-hover: #423218;
  --kb-key-active: #eab308;
  --kb-special-bg: #130d04;
  --kb-accent: #fbbf24;
}

body.theme-pastel {
  --kb-bg: #1f1a2e;
  --kb-key-bg: #312a45;
  --kb-key-text: #fbcfe8;
  --kb-key-border: rgba(244, 114, 182, 0.2);
  --kb-key-shadow: 0 2px 0 rgba(17, 13, 27, 0.6);
  --kb-key-hover: #43395c;
  --kb-key-active: #f472b6;
  --kb-special-bg: #14101e;
  --kb-accent: #f472b6;
}

/* Base key layout & responsive sizing */
#keyboard-container {
  background-color: var(--kb-bg);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.kb-row {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--kb-key-gap);
  width: 100%;
}

.kb-key {
  position: relative;
  background-color: var(--kb-key-bg);
  color: var(--kb-key-text);
  border: 1px solid var(--kb-key-border);
  box-shadow: var(--kb-key-shadow);
  border-radius: var(--kb-radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  height: 44px;
  flex: 1 1 0;
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.05s ease, background-color 0.08s ease;
  outline: none;
}

@media (min-width: 640px) {
  .kb-key {
    height: 48px;
    font-size: 17px;
  }
}

.kb-key:active,
.kb-key.is-pressed {
  transform: translateY(2px) scale(0.96);
  background-color: var(--kb-key-active) !important;
  color: #ffffff !important;
}

.kb-key.special-key {
  background-color: var(--kb-special-bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--kb-accent);
}

.kb-key.wide-key {
  flex: 1.5 1 0;
}

.kb-key.space-key {
  flex: 4 1 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.kb-key.enter-key {
  flex: 1.6 1 0;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Key popup indicator */
#key-popup-indicator {
  background-color: var(--kb-key-active);
  color: #ffffff;
  width: 50px;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

/* Custom Scrollbars */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Diacritic buttons */
.harakat-btn {
  transition: all 0.15s ease;
}
.harakat-btn:active {
  transform: scale(0.88);
  background-color: #0284c7;
  color: #ffffff;
}

/* Pulsing text cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: #38bdf8;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
  margin-inline-start: 1px;
}

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

/* Decor Pill Badges */
.decor-badge-btn {
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  background-color: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.decor-badge-btn:hover {
  background-color: #334155;
  color: #ffffff;
}
.decor-badge-btn.active {
  background-color: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
}