/* QALC Vocabulary Mastery — public styles.
   Design language follows the QALC flashcard reference (indigo + Hafs + Hind Siliguri). */

@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600;700&display=swap');

@font-face {
  font-family: 'Hafs';
  src: url('https://quranicarabiclearningcafe.com/wp-content/fonts/hafs/hafs.18.woff2') format('woff2');
  font-display: swap;
}

.qalc-app {
  --qalc-indigo: #4b0082;
  --qalc-indigo-2: #6a0dad;
  --qalc-bg: #e6f0ff;
  --qalc-card: #fdfdfd;
  --qalc-soft: #d1c4e9;
  --qalc-green: #1b8a4c;
  --qalc-red: #c0392b;
  --qalc-amber: #b7791f;
  font-family: 'Hind Siliguri', sans-serif;
  color: #222;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px;
  box-sizing: border-box;
}
.qalc-app *, .qalc-app *::before, .qalc-app *::after { box-sizing: border-box; }

.qalc-ar { font-family: 'Hafs', serif; direction: rtl; }
.qalc-app .bn, .qalc-answer-popup .bn { font-family: 'Hind Siliguri', sans-serif; font-weight: 400; }

/* ------------------------------------------------------------- Generic UI */
.qalc-card {
  background: #fff;
  border: 2px solid var(--qalc-soft);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .12);
  margin: 12px 0;
}
.qalc-h { color: var(--qalc-indigo); font-size: 1.4rem; font-weight: 800; margin: 0 0 14px; }
.qalc-muted { color: #555; font-size: .9rem; }
.qalc-notice { background:#fff8e6; border:1px solid #f0d589; border-radius:10px; padding:14px 16px; }
.qalc-intro { font-size: 1.05rem; color: var(--qalc-indigo); font-weight: 600; }

.qalc-btn {
  background: var(--qalc-indigo);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  min-width: 120px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .25s, transform .15s;
}
.qalc-btn:hover { background: var(--qalc-indigo-2); color:#fff; }
.qalc-btn:active { transform: scale(.97); }
.qalc-btn:disabled { opacity: .55; cursor: not-allowed; }
.qalc-btn.secondary { background: #fff; color: var(--qalc-indigo); border: 2px solid var(--qalc-indigo); }
.qalc-btn.secondary:hover { background: #f5f0ff; }
.qalc-btn.success { background: var(--qalc-green); }
.qalc-btn.small { min-width: 0; padding: 6px 14px; font-size: .9rem; }

.qalc-loading { text-align: center; padding: 40px 10px; color: var(--qalc-indigo); font-weight: 600; }
.qalc-spinner {
  display: inline-block; width: 18px; height: 18px; vertical-align: -3px;
  border: 3px solid var(--qalc-soft); border-top-color: var(--qalc-indigo);
  border-radius: 50%; animation: qalcspin .8s linear infinite;
}
@keyframes qalcspin { to { transform: rotate(360deg); } }

.qalc-form-msg { min-height: 22px; font-weight: 600; margin: 8px 0; }
.qalc-form-msg.error { color: var(--qalc-red); }
.qalc-form-msg.success { color: var(--qalc-green); }

.qalc-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; margin-bottom: 12px; }
.qalc-app label { display: flex; flex-direction: column; font-weight: 600; font-size: .92rem; color: #333; gap: 4px; }
.qalc-app input[type=text], .qalc-app input[type=email], .qalc-app input[type=password],
.qalc-app input[type=tel], .qalc-app input[type=search], .qalc-app select {
  border: 1.5px solid var(--qalc-soft); border-radius: 8px; padding: 9px 12px;
  font-family: inherit; font-size: 1rem; background: #fff; color:#222;
}
.qalc-app input:focus, .qalc-app select:focus { outline: 2px solid var(--qalc-indigo-2); border-color: var(--qalc-indigo-2); }

/* ------------------------------------------------------------- Dashboard */
.qalc-welcome { font-size: 1.5rem; font-weight: 800; color: var(--qalc-indigo); margin: 6px 0 2px; }
.qalc-welcome small { display:block; font-size: .95rem; color:#555; font-weight: 500; }

.qalc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.qalc-stat {
  background: #f8f5ff; border: 1px solid var(--qalc-soft); border-radius: 14px;
  padding: 14px; text-align: center;
}
.qalc-stat .num { display: block; font-size: 1.7rem; font-weight: 800; color: #2b0050; }
.qalc-stat .lbl { font-size: .85rem; color: #555; font-weight: 600; }

.qalc-menu { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.qalc-menu button {
  background: #fff; color: var(--qalc-indigo); border: 2px solid var(--qalc-soft);
  border-radius: 999px; padding: 8px 16px; font-family: inherit; font-weight: 600;
  font-size: .92rem; cursor: pointer; transition: all .2s;
}
.qalc-menu button:hover { border-color: var(--qalc-indigo); }
.qalc-menu button.active { background: var(--qalc-indigo); color: #fff; border-color: var(--qalc-indigo); }

/* ------------------------------------------------------------ Flashcards */
.qalc-stage { display: flex; justify-content: center; align-items: center; min-height: 440px; position: relative; }
.qalc-flashcard {
  width: 280px; height: 400px; background: var(--qalc-card);
  border: 2px solid var(--qalc-indigo); border-radius: 20px;
  box-shadow: 0 8px 18px rgba(0,0,0,.25); perspective: 1000px;
  position: relative; cursor: pointer; touch-action: manipulation;
}
@media (hover: hover) {
  .qalc-flashcard:hover { transform: scale(1.04); transition: transform .5s; }
}
.qalc-flash-inner {
  position: absolute; inset: 0; transition: transform .8s;
  -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
}
.qalc-flashcard.flipped .qalc-flash-inner { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
.qalc-face {
  position: absolute; inset: 0; border-radius: 20px; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  -webkit-backface-visibility: hidden; backface-visibility: hidden; padding: 16px;
}
.qalc-face.front { background: linear-gradient(to bottom right, #f0f8ff, #e0f0ff); }
.qalc-face.back {
  background: #fff; color: purple; font-size: 1.6rem; text-align: center;
  -webkit-transform: rotateY(180deg); transform: rotateY(180deg);
  border: 2px solid var(--qalc-soft); font-weight: 600;
}
.qalc-word {
  font-family: 'Hafs', serif; direction: rtl; font-size: 4.2rem; font-weight: 700;
  line-height: 1.3; text-align: center; width: 100%;
}
.qalc-card-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; }
.qalc-badge {
  background: var(--qalc-indigo); color: #fff; border-radius: 999px;
  font-size: .72rem; font-weight: 700; padding: 3px 10px;
}
.qalc-badge.alt { background: #fff; color: var(--qalc-indigo); border: 1px solid var(--qalc-indigo); }
.qalc-freq { color: #555; font-size: 1.05rem; font-weight: 500; margin-top: 8px; }
.qalc-example-link { margin-top: 12px; color: var(--qalc-indigo); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 1.3rem; }

.qalc-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 16px 0 28px; }
.qalc-btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.qalc-progresstxt { font-size: 1rem; color: var(--qalc-indigo); font-weight: 700; }
.qalc-keyhint { color: #555; font-size: .8rem; text-align: center; }

/* Modal */
.qalc-modal {
  display: none; position: fixed; z-index: 99999; inset: 0;
  background: rgba(0,0,0,.5); justify-content: center; align-items: center;
}
.qalc-modal.open { display: flex; }
.qalc-modal-content {
  background: #fff; padding: 24px; border-radius: 14px; width: 90%; max-width: 480px;
  text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.3); position: relative;
  animation: qalcfade .3s ease-in-out; max-height: 85vh; overflow-y: auto;
}
.qalc-modal-close { position: absolute; top: 8px; right: 14px; color: #555; font-size: 26px; cursor: pointer; background:none; border:none; }
.qalc-ayah { font-family: 'Hafs', serif; direction: rtl; font-size: 2.2rem; font-weight: 700; line-height: 1.8; color: var(--qalc-indigo); margin: 12px 0; }
.qalc-translation { color: #333; font-size: 1rem; line-height: 1.6; }
.qalc-ref { color: #777; font-size: .85rem; margin-top: 6px; }
@keyframes qalcfade { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

/* Summary */
.qalc-summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 16px; }
.qalc-review-list { text-align: left; padding-left: 18px; font-size: 1rem; }
.qalc-review-list .qalc-ar { font-size: 1.8rem; font-weight: 700; }

/* ----------------------------------------------------------------- Quiz
   UI follows the QALC sample quiz: light-blue box, big white option
   buttons, green/red instant feedback, answer popup, explanation panel. */
.qalc-qz-box {
  background: #90e0ef !important;
  color: #0F172A !important;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, .1);
  margin: 12px 0;
}
.qalc-qz-box h2, .qalc-qz-box h3, .qalc-qz-box h4, .qalc-qz-box p, .qalc-qz-box li { color: #0F172A; }
.qalc-qz-question { font-size: 1.4rem !important; font-weight: 700; margin: 0 0 20px; color: #111 !important; }
.qalc-qz-question .qalc-ar { display: block; font-size: 2.6rem; line-height: 1.7; margin-top: 8px; }
.qalc-qz-sub { font-size: 1.15rem; font-weight: 500; margin: 6px 0 0; }

.qalc-qz-options { margin: 14px 0; }
/* !important shields these from theme button styles (Astra, dark themes, etc.) */
.qalc-qz-options button {
  display: block !important;
  margin: 10px auto !important;
  padding: 16px 22px !important;
  width: 85% !important;
  min-width: 0 !important;
  background: #fff !important;
  color: #000 !important;
  border: 2px solid #ccc !important;
  border-radius: 10px !important;
  text-align: left !important;
  cursor: pointer;
  font-size: 1.3rem !important;
  line-height: 1.5 !important;
  font-family: inherit !important;
  font-weight: 400 !important;
  text-transform: none !important;
  box-shadow: none !important;
  transition: background-color .3s, border-color .3s;
  white-space: normal !important;
}
.qalc-qz-options button:hover:not(:disabled) { background: #dce2eb !important; }
.qalc-qz-options button:focus-visible { outline: 3px solid rgba(33,150,243,.65); outline-offset: 3px; }
.qalc-qz-options button.qalc-ar {
  text-align: right !important;
  font-family: 'Hafs', serif !important;
  font-size: 2.4rem !important;
  line-height: 1.8 !important;
  font-weight: 700 !important;
}
.qalc-qz-options button.correct { background: #4CAF50 !important; color: #fff !important; border-color: #388E3C !important; }
.qalc-qz-options button.wrong { background: #f44336 !important; color: #fff !important; border-color: #c62828 !important; }
.qalc-qz-options button:disabled { cursor: default; }

.qalc-qz-explanation {
  display: none;
  margin-top: 20px;
  padding: 15px;
  background: #eef3fc;
  border-left: 5px solid #2196f3;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1.6;
}
.qalc-qz-explanation .qalc-ar { font-size: 1.9rem; line-height: 1.9; color: var(--qalc-indigo); display: block; }
.qalc-qz-explanation .ref { color: #777; font-size: .9rem; }

.qalc-qz-nav { margin-top: 25px; text-align: right; }
.qalc-qz-nav button {
  padding: 10px 18px !important;
  border: none !important;
  background: #2196f3 !important;
  color: #fff !important;
  border-radius: 8px !important;
  cursor: pointer;
  font-weight: 500 !important;
  font-size: 1.3rem !important;
  font-family: inherit !important;
  text-transform: none !important;
  min-width: 0 !important;
  display: inline-block !important;
  width: auto !important;
}
.qalc-qz-nav button:disabled { background: #aaa !important; cursor: not-allowed; }
.qalc-qz-nav button[style*="display:none"], .qalc-qz-nav button[style*="display: none"] { display: none !important; }

.qalc-qz-score { margin-top: 20px; font-size: 1.2rem; font-weight: 600; }
.qalc-qz-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-weight: 600; color: #0F172A; }
.qalc-quiz-timer {
  font-weight: 800; color: #0F172A; font-size: 1.05rem;
  background: rgba(255,255,255,.6); border-radius: 999px; padding: 4px 16px; display: inline-block;
}
.qalc-quiz-timer.danger { color: #c62828; background: #ffe5e2; }

/* Match-type rows inside the sample UI */
.qalc-match-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; margin: 10px 0; }
.qalc-match-left { font-family: 'Hafs', serif; direction: rtl; font-size: 1.9rem; font-weight: 700; text-align: center; background: #fff; border: 2px solid #ccc; border-radius: 10px; padding: 8px; }
.qalc-match-row select { border: 2px solid #ccc; border-radius: 10px; padding: 12px; font-size: 1.05rem; background: #fff; font-family: inherit; }
.qalc-match-mark { font-size: 1.4rem; width: 28px; text-align: center; }

/* Correct/Wrong popup */
.qalc-answer-popup {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .28); z-index: 99999;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.qalc-answer-popup.show { opacity: 1; pointer-events: auto; }
.qalc-answer-popup-card {
  min-width: 180px; max-width: 280px; padding: 22px 26px; border-radius: 18px;
  text-align: center; color: #fff; box-shadow: 0 14px 35px rgba(0,0,0,.22);
  transform: scale(.82); transition: transform .25s ease;
}
.qalc-answer-popup.show .qalc-answer-popup-card { transform: scale(1); }
.qalc-answer-popup-card.correct { background: linear-gradient(135deg, #22c55e, #16a34a); }
.qalc-answer-popup-card.wrong { background: linear-gradient(135deg, #ef4444, #dc2626); }
.qalc-answer-popup-icon {
  width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.95); display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
}
.qalc-answer-popup-icon svg { width: 38px; height: 38px; fill: #fff; }
.qalc-answer-popup-text { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }

/* Final feedback / review screen */
.qalc-qz-result-title { font-size: 1.75rem; font-weight: 700; margin: 0 0 1rem; }
.qalc-qz-result-score { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.qalc-qz-key { margin: 0 0 1.5rem; padding: 0; list-style: none; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; }
.qalc-qz-key li { display: flex; align-items: center; padding: 1rem; color: #fff; border-bottom: 1px solid #e5e7eb; }
.qalc-qz-key li.ok { background: #16a34a; }
.qalc-qz-key li.bad { background: #dc2626; }
.qalc-qz-keyicon {
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff; border-radius: 50%; width: 1.75rem; height: 1.75rem; padding: .2rem; margin-right: .5rem; flex: none;
}
.qalc-qz-keyicon svg { width: 100%; height: 100%; fill: #fff; }
.qalc-qz-review { list-style: decimal inside; padding: 0; margin: 0 0 .5rem; }
.qalc-qz-review > li { margin: 1rem 0 1.75rem; }
.qalc-qz-review .qalc-ar { font-size: 1.9rem; }
.qalc-qz-status { margin: .5rem 0; text-align: center; text-transform: uppercase; color: #fff; font-weight: 500; padding: .35rem; border-radius: 6px; }
.qalc-qz-status.ok { background: #16a34a; }
.qalc-qz-status.bad { background: #dc2626; }
.qalc-qz-review-opts { margin: 0 0 1rem; padding: 0; list-style: none; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; }
.qalc-qz-review-opts li { display: flex; align-items: center; padding: 1rem; background: #f9fafb; border-bottom: 1px solid #e5e7eb; font-size: 1.05rem; }
.qalc-qz-review-opts li.ok { background: #16a34a; color: #fff; }
.qalc-qz-review-opts li.bad { background: #dc2626; color: #fff; }
.qalc-qz-review-opts li .qalc-ar { font-size: 2rem; line-height: 1.8; }
.qalc-qz-final-btns { text-align: center; margin-top: 1.5rem; }
.qalc-qz-final-btns button {
  padding: 12px 20px; margin: 6px; border: none; border-radius: 8px;
  cursor: pointer; font-size: 1rem; color: #fff; font-family: inherit;
}
.qalc-qz-btn-practice { background: #f44336; }
.qalc-qz-btn-retake { background: #2196f3; }

.qalc-result-big { font-size: 2.4rem; font-weight: 800; color: var(--qalc-indigo); text-align: center; }

@media (max-width: 600px) {
  .qalc-qz-box { padding: 18px; }
  .qalc-qz-options button { width: 100%; font-size: 1.15rem; }
  .qalc-answer-popup-card { min-width: 160px; max-width: 240px; padding: 18px 20px; }
  .qalc-answer-popup-icon { width: 62px; height: 62px; }
  .qalc-answer-popup-text { font-size: 1.15rem; }
}

/* --------------------------------------------------------------- Tables */
.qalc-table-wrap { overflow-x: auto; }
.qalc-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.qalc-table th, .qalc-table td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; }
.qalc-table th { background: #f8f5ff; color: var(--qalc-indigo); font-weight: 700; }
.qalc-table .qalc-ar { font-size: 1.5rem; font-weight: 700; }
.qalc-table tr.me { background: #fff8e6; font-weight: 700; }
.qalc-rank-medal { font-size: 1.1rem; }

.qalc-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.qalc-toolbar input[type=search] { flex: 1; min-width: 160px; }

/* Charts */
.qalc-chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.qalc-chart-box { background:#fff; border:1px solid var(--qalc-soft); border-radius:14px; padding:14px; min-height: 260px; }
.qalc-chart-box h4 { margin: 0 0 8px; color: var(--qalc-indigo); }

/* Achievements */
.qalc-achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qalc-ach { border: 1.5px solid var(--qalc-soft); border-radius: 12px; padding: 12px; text-align: center; }
.qalc-ach .icon { font-size: 1.8rem; }
.qalc-ach.locked { opacity: .35; filter: grayscale(1); }

/* Certificate */
.qalc-certificate {
  border: 6px double var(--qalc-indigo); border-radius: 8px; padding: 36px 28px;
  text-align: center; background: #fffdf5; margin: 16px 0;
}
.qalc-certificate h2 { color: var(--qalc-indigo); font-size: 1.8rem; margin: 4px 0 14px; }
.qalc-certificate .name { font-size: 1.9rem; font-weight: 800; color: #2b0050; border-bottom: 2px solid var(--qalc-soft); display: inline-block; padding: 0 24px 4px; }
.qalc-certificate .verify { font-size: .8rem; color: #777; margin-top: 18px; }

@media print {
  body * { visibility: hidden; }
  .qalc-print-area, .qalc-print-area * { visibility: visible; }
  .qalc-print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .qalc-noprint { display: none !important; }
}

/* ------------------------------------------------------------ Responsive */
@media (max-width: 860px) {
  .qalc-stats { grid-template-columns: repeat(2, 1fr); }
  .qalc-chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .qalc-grid-2 { grid-template-columns: 1fr; }
  .qalc-flashcard { width: 230px; height: 350px; }
  .qalc-word { font-size: 3.6rem; }
  .qalc-face.back { font-size: 1.35rem; }
  .qalc-ayah { font-size: 1.9rem; }
  .qalc-match-row { grid-template-columns: 1fr; }
  .qalc-summary-grid { grid-template-columns: 1fr; }
}
