/* ==========================================================================
   TOEFL Bel Arabi — Enhanced Interactive Tools Stylesheet (2026 Edition)
   ========================================================================== */

.tbat, .tbat-contact {
  margin-block: 1.4rem 2rem;
  --t-teal: #16A6A1;
  --t-teal-d: #118783;
  --t-teal-light: #E6F7F6;
  --t-navy: #172D4B;
  --t-navy-d: #0F1D31;
  --t-line: #E8EDF3;
  --t-muted: #5A6A7E;
  --t-bg-card: #FFFFFF;
  --t-success: #10B981;
  --t-warning: #F59E0B;
  --t-danger: #EF4444;
  --t-info: #3B82F6;
}

.tbat-loading, .tbat-noscript { color: var(--t-muted); font-size: 1rem; padding: 20px 0; }
.tbat-card {
  background: var(--t-bg-card);
  border: 1px solid var(--t-line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(23, 45, 75, 0.05), 0 1px 3px rgba(23, 45, 75, 0.08);
  margin-bottom: 24px;
}

/* Tabs & Navigation */
.tbat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tbat-tab {
  font: inherit;
  font-weight: 700;
  font-size: 0.94rem;
  border: 1px solid var(--t-line);
  background: #F8FAFC;
  color: var(--t-navy);
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tbat-tab:hover { background: #EDF2F7; }
.tbat-tab.is-active {
  background: var(--t-navy);
  color: #FFFFFF;
  border-color: var(--t-navy);
  box-shadow: 0 2px 6px rgba(23, 45, 75, 0.2);
}

/* Form Controls */
.tbat-label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: var(--t-navy); font-size: 0.95rem; }
.tbat-input {
  font: inherit;
  font-size: 1rem;
  padding: 8px 14px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--t-navy);
  max-width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tbat-input:focus {
  outline: none;
  border-color: var(--t-teal);
  box-shadow: 0 0 0 3px rgba(22, 166, 161, 0.15);
}
.tbat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--t-line);
}

/* Buttons */
.tbat-btn {
  font: inherit;
  font-weight: 800;
  font-size: 0.96rem;
  padding: 9px 18px;
  border-radius: 12px;
  border: 2px solid var(--t-teal);
  background: var(--t-teal);
  color: #FFFFFF;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.tbat-btn:hover { background: var(--t-teal-d); border-color: var(--t-teal-d); transform: translateY(-1px); }
.tbat-btn:active { transform: translateY(0); }
.tbat-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.tbat-btn--ghost { background: #FFFFFF; color: var(--t-teal-d); border-color: #CBD5E1; }
.tbat-btn--ghost:hover { background: var(--t-teal-light); border-color: var(--t-teal); color: var(--t-teal-d); }
.tbat-btn--danger { background: #EF4444; border-color: #EF4444; color: #FFFFFF; }
.tbat-btn--danger:hover { background: #DC2626; border-color: #DC2626; }
.tbat-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 16px; }
.tbat-actions--center { justify-content: center; }

/* Ratings / Review Buttons (SM-2) */
.tbat-rating-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; width: 100%; }
@media (max-width: 600px) { .tbat-rating-btns { grid-template-columns: 1fr 1fr; } }
.tbat-btn--again { background: #FEE2E2; border-color: #F87171; color: #991B1B; }
.tbat-btn--again:hover { background: #FCA5A5; color: #7F1D1D; }
.tbat-btn--hard { background: #FEF3C7; border-color: #FBBF24; color: #92400E; }
.tbat-btn--hard:hover { background: #FDE68A; color: #78350F; }
.tbat-btn--good { background: #E0F2FE; border-color: #38BDF8; color: #075985; }
.tbat-btn--good:hover { background: #BAE6FD; color: #0369A1; }
.tbat-btn--easy { background: #DCFCE7; border-color: #4ADE80; color: #166534; }
.tbat-btn--easy:hover { background: #BBF7D0; color: #14532D; }

/* 3D Flashcard Component */
.tbat-flashcard-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 640px;
  margin: 18px auto;
  cursor: pointer;
}
.tbat-flashcard {
  position: relative;
  width: 100%;
  min-height: 290px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(23, 45, 75, 0.08);
}
.tbat-flashcard.is-flipped { transform: rotateY(180deg); }
.tbat-flashcard__face {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}
.tbat-flashcard__front {
  background: linear-gradient(145deg, #172D4B 0%, #0F1D31 100%);
  color: #FFFFFF;
  border: 1px solid #2A4365;
}
.tbat-flashcard__back {
  background: #FFFFFF;
  color: var(--t-navy);
  transform: rotateY(180deg);
  border: 2px solid var(--t-teal);
}
.tbat-flashcard__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  opacity: 0.9;
}
.tbat-flashcard__word {
  font-size: 2.3rem;
  font-weight: 800;
  text-align: center;
  margin: 20px 0;
  letter-spacing: 0.5px;
}
.tbat-flashcard__pos {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(22, 166, 161, 0.2);
  color: #16A6A1;
  font-weight: 700;
  font-size: 0.85rem;
}
.tbat-flashcard__trans {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--t-teal-d);
  text-align: center;
  margin: 10px 0;
}
.tbat-flashcard__def {
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 10px 0;
  color: #334155;
  text-align: left;
  direction: ltr;
}
.tbat-flashcard__ex {
  background: #F8FAFC;
  border-right: 4px solid var(--t-teal);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.96rem;
  line-height: 1.6;
  color: #1E293B;
  text-align: left;
  direction: ltr;
  font-style: italic;
  margin-top: 8px;
}
.tbat-flashcard__syn {
  font-size: 0.9rem;
  color: var(--t-muted);
  text-align: left;
  direction: ltr;
  margin-top: 6px;
}
.tbat-flashcard__hint {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.75;
  margin-top: 12px;
}

/* Statistics & Progress Bars */
.tbat-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.tbat-stat-box {
  background: #F8FAFC;
  border: 1px solid var(--t-line);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}
.tbat-stat-box__num { font-size: 1.6rem; font-weight: 900; color: var(--t-navy); line-height: 1.1; }
.tbat-stat-box__lbl { font-size: 0.82rem; color: var(--t-muted); font-weight: 700; margin-top: 4px; }
.tbat-progress-bar {
  width: 100%;
  height: 8px;
  background: #E2E8F0;
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
}
.tbat-progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--t-teal) 0%, #10B981 100%);
  transition: width 0.3s ease;
}

/* Writing Simulator Elements */
.tbat-timer-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
  border: 2px solid var(--t-line);
  border-radius: 14px;
  padding: 12px 20px;
  margin-bottom: 18px;
}
.tbat-timer {
  font-size: 2rem;
  font-weight: 900;
  font-family: monospace;
  color: var(--t-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tbat-timer.is-urgent {
  color: #DC2626;
  animation: tbatPulse 1s infinite alternate;
}
@keyframes tbatPulse { from { opacity: 1; } to { opacity: 0.5; } }
.tbat-editor-area {
  width: 100%;
  min-height: 280px;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  line-height: 1.7;
  border: 2px solid #CBD5E1;
  border-radius: 14px;
  background: #FFFFFF;
  color: #0F172A;
  direction: ltr;
  text-align: left;
  box-sizing: border-box;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tbat-editor-area:focus {
  outline: none;
  border-color: var(--t-teal);
  box-shadow: 0 0 0 3px rgba(22, 166, 161, 0.15);
}
.tbat-word-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--t-navy);
  background: #E2E8F0;
  padding: 4px 12px;
  border-radius: 20px;
}
.tbat-word-badge.is-good { background: #DCFCE7; color: #15803D; }

/* Sentence Builder Tiles & Slots */
.tbat-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  background: #F8FAFC;
  border: 2px dashed #94A3B8;
  border-radius: 12px;
  padding: 10px;
  margin: 14px 0;
  align-items: center;
  direction: ltr;
  transition: border-color 0.2s, background-color 0.2s;
}
.tbat-slots.is-dragover {
  border-color: var(--t-teal);
  background: var(--t-teal-light);
}
.tbat-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  direction: ltr;
}
.tbat-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  color: var(--t-navy);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.15s ease;
}
.tbat-chip:hover {
  border-color: var(--t-teal);
  background: var(--t-teal-light);
  transform: translateY(-2px);
}
.tbat-chip.is-dragging {
  opacity: 0.4;
  transform: scale(0.95);
}
.tbat-chip--slotted {
  background: var(--t-navy);
  color: #FFFFFF;
  border-color: var(--t-navy);
}
.tbat-chip--slotted:hover {
  background: #DC2626;
  border-color: #DC2626;
  color: #FFFFFF;
}

/* Feedback Box */
.tbat-feedback {
  border-radius: 12px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 1rem;
  line-height: 1.7;
}
.tbat-feedback--correct {
  background: #DCFCE7;
  border: 1px solid #86EFAC;
  color: #14532D;
}
.tbat-feedback--incorrect {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
}

/* Score Concordance Card & Tables */
.tbat-table-wrap { overflow-x: auto; margin: 16px 0; }
.tbat-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.95rem;
}
.tbat-table th {
  background: #F1F5F9;
  color: var(--t-navy);
  font-weight: 800;
  padding: 10px 14px;
  border-bottom: 2px solid #CBD5E1;
}
.tbat-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #E2E8F0;
  color: #334155;
}
.tbat-table tr:hover td { background: #F8FAFC; }

.tbat-cite-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.86rem;
  color: var(--t-muted);
  margin-top: 14px;
}
.tbat-cite-badge a { color: var(--t-teal-d); font-weight: 700; text-decoration: underline; }
