@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --green-dark:  #0d4a2c;
  --green-mid:   #1a6b3c;
  --green-light: #2d9156;
  --green-pale:  #e8f5ee;
  --gold:        #c9a74d;
  --gold-light:  #f0d98a;
  --gold-pale:   #fdf8eb;
  --text:        #1e1e1e;
  --text-muted:  #6b7280;
  --bg:          #f7f5f0;
  --white:       #ffffff;
  --border:      #d1d5db;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --radius:      12px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  color: var(--white);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.header-inner { position: relative; z-index: 1; }
.header-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.6rem;
  color: var(--gold-light);
  letter-spacing: .05em;
  margin-bottom: 8px;
  display: block;
}
.header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.header p  { font-size: .9rem; opacity: .85; }
.header-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.header-line::before,
.header-line::after {
  content: '';
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: var(--gold);
  opacity: .6;
}
.header-star { color: var(--gold); font-size: 1rem; }

/* ── Container ── */
.container {
  max-width: 760px;
  margin: 32px auto;
  padding: 0 16px;
}

/* ── Card ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--gold);
  border-radius: 2px;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
select, input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(26,107,60,.12);
}
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 18px; }

/* ── Arabic display ── */
.arabic-box {
  background: var(--gold-pale);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 16px 0;
  text-align: right;
  direction: rtl;
}
.arabic-text {
  font-family: 'Amiri', serif;
  font-size: 1.7rem;
  line-height: 2;
  color: var(--green-dark);
  letter-spacing: .02em;
}
.arabic-label {
  font-size: .78rem;
  color: var(--text-muted);
  direction: ltr;
  text-align: left;
  margin-top: 8px;
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 28px;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary {
  background: var(--green-mid);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--green-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary {
  background: var(--gold);
  color: var(--green-dark);
  font-weight: 700;
}
.btn-secondary:hover { background: var(--gold-light); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* ── Score display ── */
.result-card {
  border-left: 4px solid var(--green-mid);
  padding: 20px;
}
.score-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--green-pale);
  border-radius: 10px;
}
.score-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  border: 4px solid;
}
.score-circle .score-num { font-size: 1.6rem; line-height: 1; }
.score-circle .score-pct { font-size: .65rem; opacity: .8; }
.score-excellent { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.score-good      { border-color: #ca8a04; color: #ca8a04; background: #fefce8; }
.score-average   { border-color: #ea580c; color: #ea580c; background: #fff7ed; }
.score-poor      { border-color: #dc2626; color: #dc2626; background: #fef2f2; }

.progress-bar {
  flex: 1;
}
.progress-bar-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.progress-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .6s ease;
  background: linear-gradient(90deg, var(--green-mid), var(--green-light));
}

.feedback-section { margin-bottom: 14px; }
.feedback-section h4 {
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.feedback-section p {
  font-size: .9rem;
  line-height: 1.7;
  color: #374151;
}
.tag-green { color: var(--green-mid); }
.tag-gold  { color: #92400e; }
.tag-red   { color: #b91c1c; }

/* ── Loading ── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Admin table ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--green-mid); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--green-dark);
  color: var(--white);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child  { border-radius: 0 8px 0 0; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: var(--green-pale); }
tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-excellent { background: #dcfce7; color: #15803d; }
.badge-good      { background: #fef9c3; color: #92400e; }
.badge-average   { background: #ffedd5; color: #c2410c; }
.badge-poor      { background: #fee2e2; color: #b91c1c; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--green-dark); }
.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
}
.btn-close:hover { color: var(--text); }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-icon { font-size: 2.5rem; margin-bottom: 12px; }
.login-box h2 { color: var(--green-dark); margin-bottom: 6px; }
.login-box p { font-size: .875rem; color: var(--text-muted); margin-bottom: 24px; }

/* ── Misc ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.error-msg {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 14px;
}

@media (max-width: 520px) {
  .card { padding: 18px; }
  .arabic-text { font-size: 1.35rem; }
  .score-circle { width: 64px; height: 64px; }
  .score-circle .score-num { font-size: 1.2rem; }
}
