/* ==========================================================================
   Hajj & Umrah Voice Translator - Mobile First Stylesheet
   Theme: Islamic Emerald, Desert Gold, Accessible High Contrast
   ========================================================================== */

:root {
  --primary: #065f46;         /* Emerald 800 */
  --primary-light: #10b981;   /* Emerald 500 */
  --primary-dark: #064e3b;    /* Emerald 900 */
  --accent-gold: #d97706;     /* Amber 600 */
  --accent-gold-light: #fef3c7;
  --danger-red: #dc2626;      /* Red 600 */
  --danger-light: #fee2e2;
  --bg-main: #f3f4f6;         /* Gray 100 */
  --card-bg: #ffffff;
  --text-main: #1f2937;       /* Gray 800 */
  --text-muted: #6b7280;      /* Gray 500 */
  --border-color: #e5e7eb;    /* Gray 200 */
  --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);
  --bottom-nav-height: 68px;

  /* Dynamic font scaling */
  --base-font-size: 16px;
  --arabic-font-size: 22px;
  --arabic-translit-size: 15px;
}

/* Font Size Scaling Classes (A- / A+) */
body.font-size-sm {
  --base-font-size: 14px;
  --arabic-font-size: 19px;
  --arabic-translit-size: 13px;
}
body.font-size-md {
  --base-font-size: 16px;
  --arabic-font-size: 22px;
  --arabic-translit-size: 15px;
}
body.font-size-lg {
  --base-font-size: 18px;
  --arabic-font-size: 26px;
  --arabic-translit-size: 17px;
}
body.font-size-xl {
  --base-font-size: 20px;
  --arabic-font-size: 30px;
  --arabic-translit-size: 19px;
}

/* Dark Mode Theme */
body.dark-theme {
  --bg-main: #111827;
  --card-bg: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --primary: #059669;
  --primary-light: #34d399;
  --primary-dark: #047857;
  --accent-gold-light: #78350f;
  --danger-light: #7f1d1d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--base-font-size);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 12px);
  user-select: none;
  -webkit-user-select: none;
}

/* Arabic typography class */
.font-arabic {
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", Tahoma, serif;
  font-size: var(--arabic-font-size);
  line-height: 1.8;
  direction: rtl;
  text-align: right;
}

.font-latin-translit {
  font-size: var(--arabic-translit-size);
  font-style: italic;
  color: var(--accent-gold);
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-branding {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo-badge {
  background: var(--accent-gold);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.app-title-box h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.app-title-box p {
  font-size: 0.72rem;
  opacity: 0.85;
  margin: 0;
}

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

.btn-header-action {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-header-action:hover, .btn-header-action:active {
  background: rgba(255, 255, 255, 0.3);
}

/* Offline & Status Pill */
.offline-banner {
  background: #f59e0b;
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 8px;
  display: none;
}

/* App Main Container (Mobile Max Width 640px) */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 14px;
}

/* Tab Page Wrapper */
.tab-page {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-page.active {
  display: block;
}

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

/* Card Container */
.app-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

/* Language Selector Bar */
.lang-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 6px 8px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.btn-swap-lang {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin: 0 4px;
  transition: transform 0.2s;
}

.btn-swap-lang:active {
  transform: rotate(180deg) scale(0.9);
}

/* Pintasan Pilihan Bahasa Cepat */
.lang-preset-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 2px 8px 2px;
  margin-bottom: 10px;
  scrollbar-width: none;
}
.lang-preset-scroll::-webkit-scrollbar {
  display: none;
}

.lang-preset-pill {
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-preset-pill:hover {
  background: rgba(16, 185, 129, 0.12);
}

.lang-preset-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Modal Pilihan Bahasa */
.lang-modal-content {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 15px 30px rgba(0,0,0,0.3);
  border: 2px solid var(--primary);
  animation: zoomIn 0.2s ease-out;
}

.lang-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-lang-choice {
  background: var(--bg-main);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  transition: all 0.2s;
}

.btn-lang-choice:active, .btn-lang-choice:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Translator Input Box */
.input-card {
  position: relative;
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

.input-card:focus-within {
  border-color: var(--primary);
}

.card-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-lang-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(16, 185, 129, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
}

.card-top-tools {
  display: flex;
  gap: 6px;
}

.tool-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.tool-icon-btn:hover {
  background: var(--bg-main);
  color: var(--text-main);
}

.translate-textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 1.1rem;
  min-height: 85px;
  resize: none;
  font-family: inherit;
  user-select: text;
  -webkit-user-select: text;
}

.translate-textarea.arabic-text {
  font-family: "Amiri", "Traditional Arabic", serif;
  font-size: var(--arabic-font-size);
  direction: rtl;
  text-align: right;
}

.input-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action-pill {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-action-pill:active {
  background: var(--border-color);
}

.btn-mic-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 22px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.btn-mic-primary.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  animation: pulseMic 1.2s infinite;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

@keyframes pulseMic {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Translated Output Card */
.output-card {
  background: var(--card-bg);
  border: 2px solid var(--primary-light);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  position: relative;
}

.output-transliteration-box {
  background: rgba(217, 119, 6, 0.08);
  border-left: 3px solid var(--accent-gold);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 10px 0;
}

.output-text-box {
  font-size: 1.25rem;
  color: var(--text-main);
  font-weight: 600;
  min-height: 60px;
  user-select: text;
  -webkit-user-select: text;
}

.output-text-box.arabic-output {
  font-family: "Amiri", "Traditional Arabic", serif;
  font-size: var(--arabic-font-size);
  direction: rtl;
  text-align: right;
  line-height: 1.9;
  color: var(--primary-dark);
}

body.dark-theme .output-text-box.arabic-output {
  color: #34d399;
}

.output-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.tts-rate-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
}

.output-tool-btns {
  display: flex;
  gap: 8px;
}

.btn-tool-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tool-circle:hover {
  background: var(--border-color);
}

.btn-tool-circle.btn-speak-highlight {
  background: var(--primary);
  color: #ffffff;
  border: none;
  box-shadow: 0 3px 8px rgba(6, 95, 70, 0.3);
}

.btn-tool-circle.speaking {
  animation: waveSound 1s infinite alternate;
  background: var(--accent-gold);
}

@keyframes waveSound {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

/* Audio Wave Visualizer */
.audio-wave-box {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 0;
}

.audio-wave-box.active {
  display: flex;
}

.audio-bar {
  width: 4px;
  height: 16px;
  background: #ef4444;
  border-radius: 4px;
  animation: soundBar 0.8s ease-in-out infinite alternate;
}
.audio-bar:nth-child(2) { animation-delay: 0.15s; height: 28px; }
.audio-bar:nth-child(3) { animation-delay: 0.3s; height: 36px; }
.audio-bar:nth-child(4) { animation-delay: 0.45s; height: 24px; }
.audio-bar:nth-child(5) { animation-delay: 0.2s; height: 18px; }

@keyframes soundBar {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1.4); }
}

/* ==========================================================================
   2. Mode Percakapan Langsung (Face-to-Face Split Screen)
   ========================================================================== */
.conversation-view-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
  gap: 12px;
}

.convo-half {
  flex: 1;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  box-shadow: var(--shadow-md);
}

/* Top half is rotated 180 degrees for the Saudi Speaker */
.convo-half-flipped {
  transform: rotate(180deg);
  border-color: var(--accent-gold);
  background: linear-gradient(to bottom, var(--card-bg), rgba(217, 119, 6, 0.05));
}

.convo-half-normal {
  border-color: var(--primary-light);
  background: linear-gradient(to bottom, var(--card-bg), rgba(16, 185, 129, 0.05));
}

.convo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.convo-role-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}

.convo-half-flipped .convo-role-badge {
  background: var(--accent-gold);
  color: #fff;
}

.convo-half-normal .convo-role-badge {
  background: var(--primary);
  color: #fff;
}

.convo-text-display {
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  padding: 8px 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.convo-footer {
  display: flex;
  align-items: center;
  justify-content: center;
}

.convo-mic-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  transition: all 0.2s;
}

.convo-half-flipped .convo-mic-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.convo-half-normal .convo-mic-btn {
  background: linear-gradient(135deg, #10b981, #059669);
}

.convo-mic-btn.active {
  background: #dc2626 !important;
  animation: pulseMic 1s infinite;
}

/* ==========================================================================
   3. Buku Saku Haji & Frasa Offline (Phrasebook)
   ========================================================================== */
.phrasebook-search-box {
  margin-bottom: 12px;
  position: relative;
}

.phrase-search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

.phrase-search-input:focus {
  border-color: var(--primary);
}

.search-icon-inside {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.category-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.category-chips-scroll::-webkit-scrollbar {
  display: none;
}

.cat-chip {
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cat-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.phrase-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phrase-item-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s;
}

.phrase-item-card:active {
  transform: scale(0.99);
}

.phrase-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.phrase-arabic-text {
  font-family: "Amiri", serif;
  font-size: var(--arabic-font-size);
  direction: rtl;
  text-align: right;
  color: var(--primary-dark);
  font-weight: 700;
  line-height: 1.8;
  flex: 1;
}

body.dark-theme .phrase-arabic-text {
  color: #34d399;
}

.phrase-actions {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.btn-phrase-audio {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: none;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.phrase-latin-text {
  font-size: var(--arabic-translit-size);
  color: var(--accent-gold);
  font-style: italic;
}

.phrase-meaning-id {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.phrase-meaning-en {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   4. Papan Darurat SOS & Kartu Identitas Jemaah
   ========================================================================== */
.sos-quick-alert-card {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #ffffff;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35);
  text-align: center;
}

.sos-alert-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.sos-alert-desc {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 12px;
}

.sos-big-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-sos-card {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 12px;
  padding: 12px 10px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.btn-sos-card:active {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0.97);
}

.pilgrim-id-card {
  background: var(--card-bg);
  border: 2px dashed var(--accent-gold);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.pilgrim-id-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.pilgrim-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}

.pilgrim-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.pilgrim-input {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  font-weight: 600;
}

.pilgrim-input:focus {
  border-color: var(--accent-gold);
}

.emergency-contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.contact-info-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
}

.contact-info-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-call-emergency {
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Full Screen SOS Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.sos-modal-content {
  background: #ffffff;
  border-radius: 24px;
  padding: 24px 20px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  border: 4px solid var(--danger-red);
  animation: zoomIn 0.2s ease-out;
}

@keyframes zoomIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.sos-modal-arabic {
  font-family: "Amiri", serif;
  font-size: 2.2rem;
  color: #b91c1c;
  line-height: 1.6;
  margin: 16px 0;
  direction: rtl;
  font-weight: 700;
}

.sos-modal-latin {
  font-size: 1.15rem;
  color: var(--accent-gold);
  font-style: italic;
  margin-bottom: 12px;
}

.sos-modal-id {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 20px;
}

.btn-close-modal {
  background: #374151;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

/* ==========================================================================
   5. Virtual Arabic Keyboard
   ========================================================================== */
.arabic-keyboard-dock {
  background: var(--card-bg);
  border-top: 2px solid var(--border-color);
  box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
  padding: 10px;
  margin-top: 10px;
  border-radius: 14px;
}

.arabic-keyboard-dock.hidden {
  display: none;
}

.arabic-kb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.arabic-kb-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
}

.arabic-kb-close-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.arabic-quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.arabic-chip {
  background: rgba(6, 95, 70, 0.1);
  color: var(--primary-dark);
  border: 1px solid rgba(6, 95, 70, 0.2);
  border-radius: 12px;
  padding: 4px 10px;
  font-family: "Amiri", serif;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.arabic-kb-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.arabic-kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.arabic-key {
  flex: 1;
  min-width: 24px;
  height: 40px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: "Amiri", serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.arabic-key:active {
  background: var(--primary);
  color: #fff;
  transform: translateY(1px);
}

.arabic-key.key-harakat {
  color: var(--accent-gold);
  font-size: 1.4rem;
}

.arabic-key.key-backspace, .arabic-key.key-space, .arabic-key.key-done {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.arabic-key.key-space {
  flex: 3;
}

.arabic-key.key-done {
  background: var(--primary);
  color: #fff;
  flex: 2;
}

/* ==========================================================================
   6. Bottom Navigation Bar (Mobile Native Look)
   ========================================================================== */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--bottom-nav-height);
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
}

.nav-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  gap: 3px;
  transition: all 0.2s;
}

.nav-tab-btn .nav-icon {
  font-size: 1.35rem;
}

.nav-tab-btn.active {
  color: var(--primary);
}

.nav-tab-btn.active .nav-icon {
  transform: translateY(-2px);
}

.nav-tab-btn.sos-tab {
  color: var(--danger-red);
}

/* ==========================================================================
   7. App Footer
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 20px 10px 24px 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.app-footer p {
  margin: 0;
}

.app-footer strong {
  color: var(--primary);
  font-weight: 700;
}

body.dark-theme .app-footer strong {
  color: #34d399;
}

/* ==========================================================================
   8. Splash Screen (Layar Pembuka)
   ========================================================================== */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #044332, #065f46 50%, #032b20);
  color: #ffffff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 50px 20px 35px 20px;
  box-sizing: border-box;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
  pointer-events: auto;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  animation: splashFadeUp 0.8s ease-out;
}

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

.splash-logo-wrapper {
  position: relative;
  margin-bottom: 22px;
}

.splash-logo-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.55) 0%, rgba(217, 119, 6, 0) 70%);
  border-radius: 50%;
  animation: pulseGlow 2.2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.35); opacity: 1; }
}

.splash-logo-box {
  position: relative;
  width: 86px;
  height: 86px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.splash-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.splash-subtitle {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 26px 0;
  font-weight: 500;
}

.splash-loader-bar {
  width: 140px;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.splash-loader-progress {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 4px;
  animation: splashLoading 1.5s ease-in-out infinite;
}

@keyframes splashLoading {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(100%); }
}

.splash-footer {
  text-align: center;
  animation: splashFadeUp 1s ease-out;
}

.splash-by {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.65);
  display: block;
  margin-bottom: 3px;
}

.splash-author {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbbf24;
  margin: 0;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   9. Multi-Device Responsive System (Mobile, Tablet, Desktop)
   ========================================================================== */

/* Safe Area Inset Support */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header {
    padding-top: max(12px, calc(env(safe-area-inset-top) + 6px));
  }
  body {
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 14px);
  }
  .bottom-nav-bar {
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Modern Dynamic Viewport Unit for Conversation Mode */
@supports (height: 100dvh) {
  .conversation-view-container {
    height: calc(100dvh - 165px);
  }
}

/* 1. Ultra Small Mobile Screens (< 375px, e.g., iPhone SE, Galaxy Fold outer screen) */
@media (max-width: 375px) {
  .app-header {
    padding: 10px 12px;
  }
  .app-title-box h1 {
    font-size: 0.98rem;
  }
  .app-title-box p {
    font-size: 0.68rem;
  }
  .btn-header-action {
    padding: 4px 7px;
    font-size: 0.72rem;
  }
  .app-container {
    padding: 10px 10px;
  }
  .lang-btn {
    font-size: 0.8rem;
    padding: 6px 4px;
  }
  .btn-swap-lang {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .nav-tab-btn {
    font-size: 0.65rem;
  }
  .nav-tab-btn .nav-icon {
    font-size: 1.2rem;
  }
  .btn-mic-primary {
    padding: 6px 12px;
    font-size: 0.82rem;
  }
  .sos-big-btn-grid {
    grid-template-columns: 1fr;
  }
  .btn-sos-card {
    padding: 10px 8px;
    font-size: 0.82rem;
  }
  .convo-mic-btn {
    width: 58px;
    height: 58px;
    font-size: 1.5rem;
  }
}

/* 2. Standard Mobile & Phablet (376px - 600px) */
@media (min-width: 376px) and (max-width: 600px) {
  .app-container {
    padding: 12px 14px;
  }
}

/* 3. Tablets, Laptops & Desktops (> 600px) */
@media (min-width: 601px) {
  body {
    background-color: #0f172a;
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 20px 20px;
  }

  .app-header {
    max-width: 640px;
    margin: 0 auto;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  }

  .offline-banner {
    max-width: 640px;
    margin: 0 auto;
    border-radius: 0 0 8px 8px;
  }

  .app-container {
    max-width: 640px;
    margin: 12px auto;
    padding: 16px;
    background: var(--bg-main);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    min-height: calc(100vh - 120px);
  }

  .bottom-nav-bar {
    max-width: 640px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 22px 22px 0 0;
    border-left: 1.5px solid var(--border-color);
    border-right: 1.5px solid var(--border-color);
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.18);
  }

  .conversation-view-container {
    height: 580px;
  }
}

/* 4. Ultra Wide Desktop Screens (> 1200px) */
@media (min-width: 1201px) {
  .app-container {
    max-width: 680px;
  }
  .app-header {
    max-width: 680px;
  }
  .bottom-nav-bar {
    max-width: 680px;
  }
}
