* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Tahoma', Arial, sans-serif;
  background: #f1f5fb;
  color: #17233c;
  direction: rtl;
}

.page {
  min-height: 100vh;
  direction: rtl;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 230px;
  height: 100vh;
  z-index: 1000;
  background: white;
  padding: 30px 22px;
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.08);
  overflow-y: auto;
}

.sidebar h2 {
  text-align: center;
  margin-bottom: 40px;
  color: #0f2d5c;
  font-size: 20px;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  text-decoration: none;
  color: #334155;
  font-weight: bold;
  transition: 0.2s;
}

.sidebar a:hover,
.sidebar a.active {
  background: #eaf3ff;
  color: #2563eb;
}

.sidebar .logout {
  color: #ef4444;
  margin-top: 30px;
}

/* ===== Main ===== */
.main {
  padding: 35px;
  margin-right: 230px;
}

.main > h1 {
  margin-bottom: 25px;
  color: #0f2d5c;
  font-size: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== Cards Grid ===== */
.cards {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  margin-bottom: 30px;
  align-items: start;
}

.card {
  background: white;
  padding: 28px;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
  border: 1px solid #e8edf5;
}

/* Card Header */
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f1f5fb;
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
  color: #0f2d5c;
}

.card-icon {
  font-size: 28px;
  color: #2563eb;
  background: #eff6ff;
  padding: 8px;
  border-radius: 12px;
  line-height: 1;
}

/* ===== Form Groups ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea,
.card input,
.card select,
.card textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  background: #fafbfc;
  color: #1e293b;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.card input:focus,
.card select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: white;
}

/* ===== Section Boxes (inside story card) ===== */
.section-box {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.section-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-box-header i {
  font-size: 20px;
  color: #2563eb;
}

.section-box-header h4 {
  margin: 0;
  font-size: 14px;
  color: #1e293b;
  font-weight: 700;
  flex: 1;
}

.badge {
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  border: 1px solid #fde68a;
}

.badge-optional {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.divider {
  height: 1px;
  background: #e2e8f0;
  margin: 18px 0;
}

/* ===== Buttons System ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

.btn i {
  font-size: 18px;
}

/* Sizes */
.btn-sm {
  padding: 9px 16px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-sm i {
  font-size: 16px;
}

.btn-lg {
  padding: 15px 20px;
  font-size: 16px;
  border-radius: 12px;
}

.btn-lg i {
  font-size: 20px;
}

/* Full width */
.btn-full {
  width: 100%;
}

/* Colors */
.btn-primary {
  background: #2563eb;
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.4);
}

.btn-dark {
  background: #1e293b;
  color: white;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}
.btn-dark:hover {
  background: #0f172a;
  transform: translateY(-1px);
}

.btn-purple {
  background: #7c3aed;
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.28);
}
.btn-purple:hover {
  background: #6d28d9;
  transform: translateY(-1px);
}

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}

/* ===== Page Builder Block ===== */
.page-builder-block {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}

.page-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.page-block-title {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

/* ===== Quiz Question Block ===== */
.quiz-question-block {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}

/* ===== Boxes (teachers/stories lists) ===== */
.box {
  background: white;
  padding: 24px;
  border-radius: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid #e8edf5;
}

.box h3 {
  margin: 0 0 18px;
  color: #0f2d5c;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.box h3 i {
  font-size: 22px;
  color: #2563eb;
}

/* Lists */
#teachersList,
#storiesList {
  display: grid;
  gap: 10px;
}

.item {
  background: #f8fbff;
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e8edf5;
  transition: box-shadow 0.2s;
}

.item:hover {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.item button {
  border: none;
  background: #ef4444;
  color: white;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: 0.2s;
}

.item button:hover {
  background: #dc2626;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 25px;
  left: 25px;
  background: #0f2d5c;
  color: white;
  padding: 14px 22px;
  border-radius: 16px;
  font-weight: bold;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(-15px);
  pointer-events: none;
  transition: 0.3s;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: #16a34a; }
.toast.error   { background: #ef4444; }
.toast.warning { background: #f59e0b; }

/* ===== Block Elements (page builder & quiz builder) ===== */
.block-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-family: inherit;
  font-size: 14px;
  height: 80px;
  resize: vertical;
  background: #fafbfc;
  color: #1e293b;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.block-textarea:focus {
  border-color: #2563eb;
  background: white;
}

.block-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.block-col {
  flex: 1;
  min-width: 140px;
}

.block-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 5px;
}

.block-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  background: #fafbfc;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s;
}

.block-input:focus {
  border-color: #2563eb;
  background: white;
}

.block-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  background: white;
  color: #1e293b;
  outline: none;
  cursor: pointer;
}

.existing-image-preview {
  font-size: 12px;
  color: #10b981;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.existing-image-preview.hidden {
  display: none;
}

input[type="file"] {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  padding: 6px 0;
  color: #475569;
}

/* ===== Responsive ===== */
@media (max-width: 1000px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    min-height: auto;
    box-shadow: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .main {
    margin-right: 0;
    padding: 20px;
  }
}

/* ===== Language Toggle Button ===== */
.lang-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 11px 14px;
  margin-top: 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  color: #334155;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.lang-toggle-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
  transform: translateY(-1px);
}

.lang-toggle-btn .lang-flag {
  font-size: 18px;
  line-height: 1;
}

/* ===== LTR Overrides ===== */
html[dir="ltr"] body {
  direction: ltr;
}

html[dir="ltr"] .sidebar {
  right: auto;
  left: 0;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

html[dir="ltr"] .main {
  margin-right: 0;
  margin-left: 230px;
}

@media (max-width: 900px) {
  html[dir="ltr"] .main {
    margin-left: 0;
  }
}