/* ===================================================================
   Kamus Arab Indonesia - Annimah Web Edition
   Modern Responsive Design System (Mobile & Desktop)
   =================================================================== */

@font-face {
  font-family: 'Kitab';
  src: url('fonts/Kitab-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kitab';
  src: url('fonts/Kitab-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-arabic: 'Kitab', 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.15), 0 2px 4px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.2), 0 4px 6px -2px rgba(0,0,0,0.15);
}

/* Dark Theme (Default) */
body.theme-dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #27354a;
  --bg-input: #0b1120;
  
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-arabic: #38bdf8;
  --text-arabic-alt: #f1f5f9;
  
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-light: rgba(56, 189, 248, 0.15);
  
  --badge-bg: rgba(56, 189, 248, 0.2);
  --badge-text: #7dd3fc;
  
  --harakat-bg: #1e293b;
  --harakat-hover: #334155;
  --harakat-border: #334155;
}

/* Light Theme */
body.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-arabic: #0369a1;
  --text-arabic-alt: #0f172a;
  
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-light: rgba(2, 132, 199, 0.1);
  
  --badge-bg: #e0f2fe;
  --badge-text: #0369a1;
  
  --harakat-bg: #f1f5f9;
  --harakat-hover: #e2e8f0;
  --harakat-border: #cbd5e1;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

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

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  object-fit: cover;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

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

.app-badge {
  font-size: 0.72rem;
  color: var(--badge-text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.icon-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Main Navigation Tabs */
.main-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 16px 8px;
  gap: 8px;
}

.main-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.tab-btn.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* --- Search Section --- */
.search-section {
  padding: 12px 16px 8px;
  background-color: var(--bg-primary);
}

.search-box-wrapper {
  position: relative;
  width: 100%;
}

.search-input-container {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  width: 22px;
  height: 22px;
  margin-left: 14px;
  fill: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 14px 12px;
  font-size: 1.05rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
}

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

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.clear-btn:hover {
  color: var(--text-primary);
}

/* Sub-filter Bar */
.sub-filter-bar {
  display: flex;
  align-items: center;
  padding: 8px 0 4px;
  overflow-x: auto;
  gap: 8px;
  scrollbar-width: none;
}

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

.filter-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--badge-text);
  background: var(--badge-bg);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip:hover {
  color: var(--text-primary);
}

.chip.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--text-arabic);
  font-weight: 600;
}

/* Virtual Arabic Harakat Toolbar */
.harakat-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.harakat-toolbar::-webkit-scrollbar {
  display: none;
}

.h-btn {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--harakat-bg);
  border: 1px solid var(--harakat-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.h-btn:hover {
  background: var(--harakat-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.h-btn:active {
  transform: translateY(1px);
}

/* --- Content Container --- */
.content-container {
  flex: 1;
  padding: 12px 16px 32px;
}

.status-box {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 0.88rem;
  text-align: center;
}

.status-box.loading {
  background: var(--accent-light);
  color: var(--text-arabic);
}

.status-box.empty {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* Results List */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Entry Card */
.entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.entry-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.arabic-word {
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  line-height: 1.4;
  color: var(--text-arabic);
  direction: rtl;
  text-align: right;
  word-break: break-word;
}

.entry-root {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.root-badge {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.entry-meaning {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.entry-meaning.arabic-text {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  direction: rtl;
  text-align: right;
  line-height: 1.7;
  color: var(--text-primary);
}

.entry-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dict-source-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Welcome Card */
.welcome-card {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: 20px;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.welcome-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 500px;
  margin: 0 auto 20px;
}

.quick-samples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sample-tag {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.sample-tag[data-query*="كتاب"],
.sample-tag[data-query*="مدرسة"],
.sample-tag[data-query*="استغفر"] {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  padding: 2px 14px;
}

.sample-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Load More */
.load-more-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.load-more-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.load-more-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* --- Modals & Drawers --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  overflow: hidden;
}

.modal-card.modal-large {
  max-width: 720px;
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  line-height: 1.6;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.action-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.action-btn:hover {
  background: var(--accent-hover);
}

.icon-small {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Detail Word Styling in Modal */
.detail-arabic {
  font-family: var(--font-arabic);
  font-size: 2.4rem;
  color: var(--text-arabic);
  direction: rtl;
  text-align: right;
  line-height: 1.4;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-color);
}

.detail-root-box {
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.detail-meaning {
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.7;
}

.detail-meaning.arabic-content {
  font-family: var(--font-arabic);
  font-size: 1.35rem;
  direction: rtl;
  text-align: right;
}

/* About Modal Styling */
.about-hero {
  text-align: center;
  margin-bottom: 24px;
}

.about-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

.about-hero h4 {
  font-size: 1.25rem;
  font-weight: 700;
}

.about-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.about-section {
  margin-bottom: 22px;
}

.about-section h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-arabic);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.about-section p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.info-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.88rem;
  margin: 10px 0;
  color: var(--text-secondary);
}

.info-card a {
  color: var(--accent);
  text-decoration: none;
}

.info-card a:hover {
  text-decoration: underline;
}

.sources-list {
  padding-left: 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doa-text {
  font-family: var(--font-arabic);
  font-size: 1.35rem;
  direction: rtl;
  text-align: center;
  color: var(--text-arabic);
  margin: 16px 0 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid #334155;
  z-index: 100;
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Responsive Breakpoints */
@media (min-width: 640px) {
  .app-title {
    font-size: 1.3rem;
  }
  .search-input {
    font-size: 1.15rem;
  }
  .arabic-word {
    font-size: 1.85rem;
  }
}
