:root {
  --primary: #90ee90;
  --primary-dark: #064d21;
  --bg: linear-gradient(135deg, #000000, #013220);
  --card-bg: rgba(255, 255, 255, 0.07);
  --text: #ffffff;
  --correct: #2ecc71;
  --wrong: #e74c3c;
  --skipped: #f39c12;
  --star: #f1c40f;
}

html,
body,
#root {
  min-height: 100vh;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

#root {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.app-header {
  padding: 15px;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 4px solid var(--primary-dark);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.container {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  flex-grow: 1;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(144, 238, 144, 0.15);
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.btn {
  background: var(--primary);
  color: #000;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  font-size: 1rem;
  transition: 0.3s;
  margin-top: 10px;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.9rem;
  width: auto;
  margin-top: 0;
  border-radius: 8px;
}

.btn-danger {
  background: #ff4d4d;
  color: white;
}

.btn-star {
  background: var(--star);
  color: #000;
}

.btn-backup {
  background: #3498db;
  color: white;
  margin-top: 5px;
}

.input-group {
  margin-bottom: 15px;
  text-align: right;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: bold;
}

.home-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.home-top-bar h3 {
  margin: 0;
}

.home-bookmarks-btn {
  width: auto;
  margin-top: 0;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--star);
  color: #1a1400;
  border: 1px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  font-weight: 700;
}

.home-bookmarks-btn:hover {
  background: #f3ce2f;
  transform: translateY(-1px);
}

.home-bookmarks-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.auth-card {
  max-width: 460px;
  margin: 32px auto;
}

.auth-subtitle {
  opacity: 0.9;
  margin-bottom: 18px;
}

.auth-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(144, 238, 144, 0.3);
  background: rgba(0, 0, 0, 0.45);
  color: white;
  outline: none;
  box-sizing: border-box;
  font-size: 1rem;
}

.auth-error {
  margin: 8px 0 0;
  color: #ff8a8a;
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-hint {
  margin: 10px 0 0;
  opacity: 0.85;
  font-size: 0.82rem;
}

.search-container {
  position: relative;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-options-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(144, 238, 144, 0.3);
  color: var(--primary);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.3s;
  flex-shrink: 0;
}

.search-options-btn:hover, .search-options-btn.active {
  background: var(--primary);
  color: #000;
  box-shadow: 0 0 15px rgba(144, 238, 144, 0.4);
}

.search-options-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0); /* شفافة تماماً ولكنها تحجب النقرات */
  cursor: default;
}

.search-options-popup {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 300;
  background: #1a1a1a;
  border: 1px solid var(--primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 15px;
  animation: slideDown 0.3s ease-out;
  max-height: 80vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.search-options-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
  font-weight: bold;
  color: var(--primary);
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.6;
}

.close-btn:hover {
  opacity: 1;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(144, 238, 144, 0.3);
  background: rgba(0, 0, 0, 0.4);
  color: white;
  outline: none;
  box-sizing: border-box;
  font-size: 1rem;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--primary);
  opacity: 0.7;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #333;
  max-height: 300px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.search-item {
  padding: 12px;
  border-bottom: 1px solid #333;
  cursor: pointer;
  transition: 0.2s;
}

.search-item:hover {
  background: rgba(144, 238, 144, 0.1);
}

.search-item .q-meta {
  font-size: 0.7rem;
  color: var(--primary);
  margin-bottom: 4px;
  opacity: 0.8;
}

.search-item .q-txt {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.selection-grid .input-group {
  flex: 1;
  min-width: 140px;
  margin-bottom: 5px;
}

.button-group-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.selector-btn {
  padding: 10px 15px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
}

.selector-btn.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: bold;
}

.add-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-dark);
  color: var(--primary);
  border: 1px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.4rem;
}

textarea.bulk-textarea {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #444;
  color: var(--primary);
  border-radius: 8px;
  outline: none;
  min-height: 250px;
  font-family: monospace;
  direction: rtl;
  text-align: right;
  box-sizing: border-box;
}

.app-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}

.app-modal-overlay--default {
  z-index: 1000;
}

.app-modal-overlay--preview {
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  padding: 10px;
  box-sizing: border-box;
}

.app-modal-panel {
  position: relative;
}

.app-modal-panel--default {
  background: #151515;
  padding: 25px;
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--primary);
  box-shadow: 0 0 30px rgba(144, 238, 144, 0.2);
}

.app-modal-panel--preview {
  width: 94%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  background: #111;
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.app-modal-panel--preview::-webkit-scrollbar {
  width: 4px;
}

.app-modal-panel--preview::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.preview-modal-header {
  position: sticky;
  top: -20px;
  background: #111;
  z-index: 10;
  padding: 10px 0;
  border-bottom: 1px solid rgba(144, 238, 144, 0.2);
  margin-bottom: 15px;
}

.category-item-wrapper .selector-btn {
  flex: 1;
  text-align: right;
}

.category-item-wrapper .btn-danger {
  border-radius: 8px;
  opacity: 0.7;
}

.category-item-wrapper .btn-danger:hover {
  opacity: 1;
}

.category-item-wrapper {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.breadcrumb-link {
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline dotted;
  transition: 0.3s;
  padding: 2px 5px;
  border-radius: 4px;
  background: none;
  border: none;
  font: inherit;
}

.breadcrumb-link:hover {
  background: rgba(144, 238, 144, 0.2);
  text-decoration: underline solid;
}

.meta-breadcrumb {
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 12px;
  opacity: 0.9;
  line-height: 1.8;
}

.edit-btn {
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: 0.3s;
}

.edit-btn:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.q-img {
  max-width: 100%;
  border-radius: 10px;
  margin: 10px 0;
  display: block;
  border: 1px solid var(--primary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.gallery-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
}

.gallery-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 5px;
  border-radius: 10px;
  text-align: center;
  font-size: 10px;
}

.search-scope-filter {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.search-scope-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  opacity: 0.8;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(144, 238, 144, 0.1);
  transition: 0.2s;
}

.search-scope-option:hover {
  background: rgba(144, 238, 144, 0.1);
  border-color: rgba(144, 238, 144, 0.3);
}

.search-scope-option.active {
  background: rgba(144, 238, 144, 0.2);
  border-color: var(--primary);
  opacity: 1;
  font-weight: bold;
}

.search-scope-option input {
  cursor: pointer;
  accent-color: var(--primary);
}

.hidden {
  display: none !important;
}

.progress-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: 0.5s;
}

.question-container {
  animation: fadeIn 0.4s;
  margin-bottom: 25px;
  position: relative;
}

.q-text {
  font-size: 1.25rem;
  margin-bottom: 20px;
  line-height: 1.6;
  color: var(--primary);
  font-weight: bold;
  padding-left: 0;
}

.question-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 4px;
  border-radius: 12px;
  /* background: rgba(255, 255, 255, 0.04); */
  /* border: 1px solid rgba(255, 255, 255, 0.12); */
}

.question-action-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s ease;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  padding: 0;
  border-radius: 10px;
}

.question-action-btn:hover {
  transform: translateY(-1px);
  background: rgba(144, 238, 144, 0.18);
  border-color: rgba(144, 238, 144, 0.45);
  color: var(--primary);
}

.question-action-btn:active {
  transform: translateY(0);
}

.star-icon {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.42);
}

.star-icon.active {
  color: var(--star);
  background: rgba(241, 196, 15, 0.18);
  border-color: rgba(241, 196, 15, 0.45);
}

.share-icon {
  font-size: 1rem;
}

.copy-feedback {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.copy-feedback.success {
  background: rgba(46, 204, 113, 0.2);
  color: #9af3c5;
  border: 1px solid rgba(46, 204, 113, 0.5);
}

.copy-feedback.error {
  background: rgba(231, 76, 60, 0.2);
  color: #ffb3ab;
  border: 1px solid rgba(231, 76, 60, 0.5);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.options-list.locked {
  pointer-events: none;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 16px;
  border-radius: 14px;
  text-align: right;
  cursor: pointer;
  transition: 0.2s;
  font-size: 1rem;
}

.option-btn.correct {
  background: var(--correct) !important;
  color: #000;
  font-weight: bold;
}

.option-btn.wrong {
  background: var(--wrong) !important;
  color: #fff;
}

.explanation {
  margin-top: 20px;
  padding: 18px;
  background: rgba(144, 238, 144, 0.1);
  border-right: 5px solid var(--primary);
  border-radius: 12px;
  font-size: 0.95rem;
}

.question-status {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: bold;
}

.question-status.skipped {
  background: rgba(243, 156, 18, 0.2);
  color: #ffd084;
  border: 1px solid rgba(243, 156, 18, 0.5);
}

.question-status.solved {
  background: rgba(46, 204, 113, 0.2);
  color: #8af0ba;
  border: 1px solid rgba(46, 204, 113, 0.5);
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  border: none;
  color: inherit;
  font-family: inherit;
}

.tab.active {
  background: var(--primary);
  color: #000;
  font-weight: bold;
}

.review-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: 0.3s;
}

.toggle-btn.active {
  background: var(--primary);
  color: #000;
}

#results-review-anchor {
  scroll-margin-top: 80px;
}

.scroll-review-top-btn {
  position: fixed;
  right: 16px;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  left: auto;
  z-index: 200;
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #000;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.2s,
    opacity 0.2s;
}

.scroll-review-top-btn:active {
  transform: scale(0.95);
}

.backup-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-sep {
  display: block;
  height: 3px;
  margin: 15px 0;
  border-radius: 10px;
  background: rgba(144, 238, 144, 0.2);
}
