/* Admin Panel Styles — RTL layout (Hebrew) */

/* ── Login ────────────────────────────────────────── */

.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  direction: rtl;
}

.login-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 2.5rem;
  width: 380px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  direction: rtl;
}

.login-input:focus {
  border-color: #0071E3;
}

.login-error {
  color: #dc3545;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.login-btn {
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  background: #0071E3;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: #005bb5;
}

/* ── Layout ───────────────────────────────────────── */

.admin-layout {
  display: flex;
  min-height: 100vh;
  direction: rtl;
  text-align: right;
}

.admin-sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #ccc;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  flex-shrink: 0;
  direction: ltr;
  text-align: left;
}

.admin-brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.brand-link {
  font-family: "Helvetica Neue", sans-serif;
  font-weight: 100;
  font-size: 1.5rem;
  color: #fff;
  text-decoration: none;
}

.brand-label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.admin-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  color: #aaa;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.admin-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.admin-nav-link.active {
  color: #fff;
  background: rgba(0, 113, 227, 0.25);
}

.admin-nav-link i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
}

.admin-logout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  margin: 0 0.75rem;
  color: #888;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-logout:hover {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.08);
}

.admin-main {
  flex: 1;
  background: #f5f6fa;
  padding: 2rem;
  overflow-y: auto;
  min-height: 100vh;
}

/* ── Shared Admin Components ──────────────────────── */

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.admin-search {
  position: relative;
  display: flex;
  align-items: center;
}

.admin-search .fa-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  font-size: 0.8rem;
  pointer-events: none;
}

.admin-search input {
  padding-left: 30px;
  padding-right: 28px;
  width: 220px;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 0.8rem;
  padding: 2px 4px;
  line-height: 1;
}

.search-clear:hover {
  color: #333;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  color: #333;
}

.btn:hover {
  border-color: #bbb;
}

.btn-primary {
  background: #0071E3;
  color: #fff;
  border-color: #0071E3;
}

.btn-primary:hover {
  background: #005bb5;
}

.btn-danger {
  color: #dc3545;
  border-color: #dc3545;
}

.btn-danger:hover {
  background: #dc3545;
  color: #fff;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 0.35rem 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: #eee;
  color: #333;
}

.btn-icon.danger:hover {
  background: #fee;
  color: #dc3545;
}

/* ── Table ────────────────────────────────────────── */

.admin-table {
  width: 100%;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  padding: 0.75rem 1rem;
  text-align: right;
  font-weight: 600;
  color: #666;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #eee;
  background: #fafafa;
}

.admin-table th:first-child {
  border-radius: 0 8px 0 0;
}

.admin-table th:last-child {
  border-radius: 8px 0 0 0;
}

.admin-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  color: #444;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f8f9ff;
}

/* ── Toggle Switch ────────────────────────────────── */

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 20px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: #0071E3;
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ── Badge ────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-published {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-draft {
  background: #fff3e0;
  color: #e65100;
}

.badge-archived {
  background: #f5f5f5;
  color: #999;
}

/* ── Modal ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #eee;
}

/* ── Form ─────────────────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.35rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  direction: rtl;
  text-align: right;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #0071E3;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Metadata List Editor ─────────────────────────── */

.meta-list {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 0.75rem;
}

.meta-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.meta-list-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
}

.meta-item {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  position: relative;
}

.meta-item:last-child {
  margin-bottom: 0;
}

.meta-item-remove {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
}

.meta-item .form-group {
  margin-bottom: 0.5rem;
}

.meta-item .form-group:last-child {
  margin-bottom: 0;
}

/* ── Curriculum Tree ──────────────────────────────── */

.tree-node {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.tree-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.tree-header:hover {
  background: #f8f9ff;
}

.tree-expand {
  color: #bbb;
  transition: transform 0.2s;
  font-size: 0.75rem;
  width: 20px;
  text-align: center;
}

.tree-expand.open {
  transform: rotate(-90deg);
  color: #0071E3;
}

.tree-title {
  flex: 1;
  font-weight: 500;
  color: #333;
  font-size: 0.9rem;
}

.tree-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.tree-header:hover .tree-actions {
  opacity: 1;
}

.tree-children {
  padding: 0.5rem 2rem 0.75rem 0.75rem;
  border-top: 1px solid #f0f0f0;
}

.tree-children--subjects {
  padding-right: 3.5rem;
  margin-left: 0.5rem;
  border-left: 2px solid #e8e8e8;
  border-top: none;
}

.tree-order {
  color: #bbb;
  font-size: 0.8rem;
  font-weight: 600;
  width: 20px;
  text-align: center;
}

.tree-description {
  margin: 0 0.75rem 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.79rem;
  color: #555;
  line-height: 1.5;
  background: #f5f6f8;
  border-radius: 4px;
}

.tree-description:has(.inline-edit-desc) {
  padding: 0;
  margin: 0;
  background: none;
}

/* ── Filter bar ───────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
}

.filter-label {
  font-size: 0.85rem;
  color: #888;
  font-weight: 500;
}

/* ── Empty state ──────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #aaa;
}

/* ── Toast / flash messages ───────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: #333;
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 2000;
  animation: fadeInUp 0.25s ease;
}

.toast.success {
  background: #2e7d32;
}

.toast.error {
  background: #dc3545;
}

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

/* ── Drag and Drop ───────────────────────────────── */

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  cursor: grab;
  color: #ccc;
  font-size: 0.85rem;
  transition: color 0.15s;
  flex-shrink: 0;
  user-select: none;
}

.drag-handle:hover {
  color: #666;
}

.drag-handle:active {
  cursor: grabbing;
}

/* Active drag item highlight */
.tree-header.drag-active,
tr.drag-active {
  opacity: 0.6;
  background: rgba(0, 113, 227, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 113, 227, 0.3);
  border-radius: 4px;
}

/* Smooth reorder animation via Vue TransitionGroup */
.drag-reorder-move {
  transition: transform 0.2s ease;
}

/* ── Inline Editing ──────────────────────────────── */

.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.inline-edit-input {
  flex: 1;
  min-width: 0;
  padding: 0.2rem 0.5rem;
  border: 1px solid #0071E3;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  color: #333;
  outline: none;
  background: #fff;
}

.inline-edit-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.inline-edit-confirm {
  color: #2e7d32 !important;
  flex-shrink: 0;
}

.inline-edit-confirm:hover {
  background: #e8f5e9 !important;
  color: #1b5e20 !important;
}

.inline-edit-cancel {
  color: #dc3545 !important;
  flex-shrink: 0;
}

.inline-edit-cancel:hover {
  background: #fee !important;
  color: #b71c1c !important;
}

.inline-edit-desc {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
  width: 100%;
}

.inline-edit-desc-input {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid #0071E3;
  border-radius: 4px;
  font-size: 0.79rem;
  font-family: inherit;
  color: #333;
  outline: none;
  background: #fff;
  resize: vertical;
  line-height: 1.5;
}

.inline-edit-desc-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.inline-edit-desc-actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-shrink: 0;
}

/* ── Rich Text Editor ────────────────────────────── */

.rich-editor {
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.rich-editor:focus-within {
  border-color: #0071E3;
}

.rich-editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 0.3rem 0.5rem;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}

.rich-editor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: none;
  color: #666;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.rich-editor-btn:hover {
  background: #e8e8e8;
  color: #333;
}

.rich-editor-btn.active {
  background: #0071E3;
  color: #fff;
}

.rich-editor-content {
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.5;
  color: #333;
  outline: none;
  direction: rtl;
  text-align: right;
  overflow-y: auto;
  max-height: 200px;
}

.rich-editor-content:empty::before {
  content: '';
  color: #aaa;
}

.rich-editor-content ul {
  margin: 0.25rem 0;
  padding-right: 1.5rem;
  padding-left: 0;
}

.rich-editor-content li {
  margin-bottom: 0.15rem;
}

/* ── Mobile top bar (hidden on desktop) ──────────── */

.admin-mobile-bar {
  display: none;
}

.admin-sidebar-overlay {
  display: none;
}

/* ══════════════════════════════════════════════════════
   ADMIN RESPONSIVE — Tablet (768px – 1024px)
   ══════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .admin-mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #1a1a2e;
    position: sticky;
    top: 0;
    z-index: 1010;
  }

  .admin-mobile-bar .brand-link {
    font-family: "Helvetica Neue", sans-serif;
    font-weight: 100;
    font-size: 1.3rem;
    color: #fff;
    text-decoration: none;
  }

  .admin-mobile-bar .brand-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .admin-hamburger {
    background: none;
    border: none;
    color: #ccc;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s;
  }

  .admin-hamburger:hover {
    color: #fff;
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1020;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .admin-sidebar-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    width: 240px;
    height: 100vh;
    height: 100dvh;
    z-index: 1030;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .admin-sidebar.is-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  }

  .admin-main {
    padding: 1.5rem;
    min-height: auto;
  }

  .admin-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .admin-toolbar {
    flex-wrap: wrap;
    width: 100%;
  }

  .admin-search input {
    width: 180px;
  }

  /* Tables: horizontal scroll */
  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table thead,
  .admin-table tbody,
  .admin-table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.55rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Modal adjustments */
  .modal {
    width: 90vw;
    max-height: 90vh;
  }

  .modal-body {
    padding: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Tree adjustments */
  .tree-children {
    padding: 0.5rem 1.25rem 0.75rem 0.5rem;
  }

  .tree-children--subjects {
    padding-right: 2rem;
  }

  /* Filter bar */
  .filter-bar {
    flex-wrap: wrap;
  }

  /* Toast */
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    text-align: center;
  }
}

/* ══════════════════════════════════════════════════════
   ADMIN RESPONSIVE — Phone (< 768px)
   ══════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .admin-mobile-bar {
    padding: 0.5rem 0.75rem;
  }

  .admin-sidebar {
    width: 220px;
    left: -220px;
  }

  .admin-main {
    padding: 1rem 0.75rem;
  }

  .admin-page-title {
    font-size: 1.2rem;
  }

  .admin-toolbar {
    gap: 0.5rem;
  }

  .admin-search input {
    width: 100%;
  }

  .admin-search {
    width: 100%;
  }

  .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .btn-sm {
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
  }

  /* Tables: card layout for mobile */
  .admin-table {
    font-size: 0.8rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
  }

  /* Modal: full screen on phone */
  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 0.75rem;
  }

  .modal-footer {
    padding: 0.75rem;
  }

  .form-group {
    margin-bottom: 0.75rem;
  }

  .form-label {
    font-size: 0.8rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 0.85rem;
    padding: 0.5rem 0.65rem;
  }

  /* Login */
  .login-card {
    width: 100%;
    max-width: 340px;
    padding: 1.75rem;
    margin: 0 1rem;
  }

  .login-card h1 {
    font-size: 1.3rem;
  }

  /* Tree: tighter on phone */
  .tree-header {
    padding: 0.55rem 0.65rem;
    gap: 0.5rem;
  }

  .tree-title {
    font-size: 0.82rem;
  }

  .tree-children {
    padding: 0.35rem 1rem 0.5rem 0.35rem;
  }

  .tree-children--subjects {
    padding-right: 1.25rem;
  }

  .tree-description {
    margin: 0 0.5rem 0.35rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .tree-actions {
    opacity: 1;
  }

  .drag-handle {
    font-size: 0.75rem;
  }

  /* Meta list */
  .meta-item {
    padding: 0.55rem;
  }

  /* Rich editor */
  .rich-editor-toolbar {
    flex-wrap: wrap;
  }

  .rich-editor-btn {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }

  .rich-editor-content {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
  }

  /* Empty state */
  .empty-state {
    padding: 2rem 1rem;
    font-size: 0.9rem;
  }
}
