:root {
  --primary: #1B5E20;
  --primary-light: #2E7D32;
  --primary-dark: #0D3B13;
  --bg: #F5F5F5;
  --white: #FFFFFF;
  --grey: #757575;
  --light-grey: #E0E0E0;
  --text: #212121;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

body[dir="rtl"] { direction: rtl; text-align: right; font-family: 'Tajawal', sans-serif; }
body[dir="rtl"] input, body[dir="rtl"] textarea, body[dir="rtl"] select, body[dir="rtl"] button { font-family: 'Tajawal', sans-serif; }
body[dir="rtl"] .lang-btn { font-family: 'Tajawal', sans-serif; }

header {
  background: var(--primary);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 { font-size: 1.4rem; font-weight: 600; }
header a { color: white; text-decoration: none; }
header a:hover { opacity: 0.9; }

.lang-switcher {
  display: flex;
  gap: 0.5rem;
}

.lang-btn {
  padding: 0.4rem 1rem;
  border: 2px solid white;
  background: transparent;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.lang-btn.active, .lang-btn:hover {
  background: white;
  color: var(--primary);
}

.container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.survey-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 4px solid var(--primary);
}

body[dir="rtl"] .survey-card { border-left: none; border-right: 4px solid var(--primary); }

.survey-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.survey-card h2 { color: var(--primary); margin-bottom: 0.5rem; font-size: 1.2rem; }
.survey-card p { color: var(--grey); font-size: 0.95rem; }

.survey-card .actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.btn:hover { background: var(--primary-light); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn:disabled { background: var(--grey); cursor: not-allowed; }

.section-title {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  margin: 1.5rem 0 1rem;
  font-size: 1.05rem;
}

.question-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.question-card .q-text {
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.question-card .q-text .required { color: red; margin-left: 4px; }

.option-group { display: flex; flex-direction: column; gap: 0.5rem; }

.option-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--light-grey);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.option-label:hover { background: #E8F5E9; }
.option-label input { accent-color: var(--primary); }

textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--light-grey);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

textarea:focus { outline: none; border-color: var(--primary); }

.submit-area {
  text-align: center;
  margin: 2rem 0;
}

.success-msg {
  background: #E8F5E9;
  color: var(--primary);
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  display: none;
}

/* Results */
.result-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.result-card .q-text { font-weight: 600; margin-bottom: 1rem; }
.result-card .total { color: var(--grey); font-size: 0.85rem; margin-bottom: 0.75rem; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.bar-label { min-width: 120px; font-size: 0.9rem; text-align: right; }
body[dir="rtl"] .bar-label { text-align: left; }

.bar-track {
  flex: 1;
  height: 28px;
  background: var(--light-grey);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: fit-content;
}

.open-answers { list-style: none; }
.open-answers li {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--light-grey);
  font-size: 0.9rem;
}
.open-answers li:last-child { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--grey);
}
.empty-state h2 { margin-bottom: 0.5rem; }

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--grey);
}

footer {
  text-align: center;
  padding: 2rem;
  color: var(--grey);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  header { padding: 0.75rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
  header h1 { font-size: 1.1rem; }
  .container { padding: 0 0.75rem; margin: 1rem auto; }
  .bar-label { min-width: 80px; font-size: 0.8rem; }
  .bar-row { gap: 0.4rem; }
}

/* Arabic font rendering - Amiri + Tajawal */
[lang="ar"], [lang="ar"] * {
    font-family: 'Amiri', 'Tajawal', 'Segoe UI', sans-serif !important;
}
html[lang="ar"] { direction: rtl; text-align: right; }
[lang="ar"] .question-text, [lang="ar"] h1, [lang="ar"] h2, [lang="ar"] h3 {
    font-family: 'Amiri', serif !important;
    line-height: 2;
}
[lang="ar"] input, [lang="ar"] textarea, [lang="ar"] select, [lang="ar"] button, [lang="ar"] label {
    font-family: 'Tajawal', sans-serif !important;
}
