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

/* ─── Variables ──────────────────────────────────────────────── */
:root {
  --bg:          #f4e8d1;
  --surface:      #faf6ee;
  --text:         #3d2b1f;
  --accent:       #d4622a;
  --accent-teal:  #2a6d7a;
  --highlight:    #ffb347;
  --border:       #c9b99a;
  --shadow:       rgba(61, 43, 31, 0.25);
}

/* ─── Body ───────────────────────────────────────────────────── */
body {
  font-family: 'Inter', 'Anek Bangla', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ─── Header ─────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 3px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 8px var(--shadow);
}

header h1 {
  font-family: 'Tajawal', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* ─── Buttons ────────────────────────────────────────────────── */
button {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border), 0 4px 6px var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--border), 0 6px 10px var(--shadow);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border), 0 2px 4px var(--shadow);
}

button.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

/* ─── Inputs ────────────────────────────────────────────────── */
input, textarea {
  font-family: 'Inter', 'Tajawal', 'Anek Bangla', sans-serif;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 2px 4px rgba(61, 43, 31, 0.15);
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(61, 43, 31, 0.15), 0 0 0 3px rgba(212, 98, 42, 0.2);
}

#root-input {
  font-family: 'Tajawal', serif;
  font-size: 1.5rem;
  text-align: right;
  max-width: 140px;
}

/* ─── Cards ─────────────────────────────────────────────────── */
section {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem;
  box-shadow: 0 6px 16px var(--shadow);
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.search-tabs, .form-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.form-tabs {
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
}

.form-tab {
  font-family: 'Tajawal', serif;
  font-weight: 700;
  font-size: 1rem;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px 8px 0 0;
}

.mood-tabs, .voice-toggle {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.mood-tab, .voice-btn {
  font-size: 0.875rem;
  padding: 0.4rem 0.875rem;
  border-radius: 20px;
}

/* ─── Conjugation Table ──────────────────────────────────────── */
.conjugation-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Tajawal', serif;
  font-size: 1.125rem;
  margin-top: 0.5rem;
}

.conjugation-table th {
  background: var(--accent-teal);
  color: var(--surface);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
}

.conjugation-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.conjugation-table tr:nth-child(even) {
  background: rgba(201, 185, 154, 0.15);
}

.conjugation-table tr:hover {
  background: rgba(255, 179, 71, 0.15);
}

.person-cell {
  font-family: 'Inter', 'Anek Bangla', sans-serif;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.8;
  white-space: nowrap;
}

.arabic-cell {
  font-family: 'Tajawal', serif;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

/* ─── Chat ──────────────────────────────────────────────────── */
#chat-section {
  position: fixed;
  right: 0; top: 0;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 3px solid var(--border);
  box-shadow: -4px 0 16px var(--shadow);
  display: flex;
  flex-direction: column;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: 85%;
  line-height: 1.5;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--surface);
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(42, 109, 122, 0.15);
  color: var(--text);
  border-bottom-left-radius: 4px;
  font-family: 'Tajawal', serif;
  font-size: 1rem;
}

#chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 2px solid var(--border);
}

#chat-input-area textarea { flex: 1; resize: none; min-height: 60px; }

/* ─── Result items ───────────────────────────────────────────── */
.result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: right;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
}

.result-item:hover { background: rgba(255, 179, 71, 0.2); }

/* ─── Utilities ──────────────────────────────────────────────── */
[dir="rtl"] { font-family: 'Tajawal', serif; }
.hidden { display: none !important; }

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header h1 { font-size: 1.5rem; }
  section { margin: 0.5rem; padding: 1rem; }
  .form-tab { min-width: 36px; font-size: 0.875rem; }
  #chat-section { width: 100vw; }
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
