/* ==========================================================================
   Clinical CMS & Data Entry Dashboard Styles
   تنسيقات لوحة تحكم مدخل البيانات وبنك البطاقات العلاجية
   ========================================================================== */

.admin-viewport {
  min-height: 100vh;
  background-color: #f1f5f9;
  display: flex;
  flex-direction: column;
}

/* Admin Top Bar */
.admin-navbar {
  background: #0f172a;
  color: #fff;
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.admin-brand-text h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
}

.admin-brand-text p {
  font-size: 0.75rem;
  color: #94a3b8;
}

.admin-nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-tab-btn {
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.admin-tab-btn:hover, .admin-tab-btn.active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #fff;
}

.btn-back-to-session {
  background: #10b981;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main CMS Workspace */
.admin-container {
  max-width: 1540px;
  width: 95%;
  margin: 1.5rem auto;
  flex: 1;
}

.admin-tab-pane {
  display: none;
}

.admin-tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

/* Stats Header Summary */
.cms-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cms-stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 15px;
}

.cms-stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.cms-stat-icon.blue { background: #eff6ff; color: #2563eb; }
.cms-stat-icon.green { background: #ecfdf5; color: #059669; }
.cms-stat-icon.amber { background: #fffbeb; color: #d97706; }
.cms-stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

.cms-stat-info h3 {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-main);
}

.cms-stat-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Action Toolbar & Search Bar */
.cms-toolbar {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toolbar-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 280px;
}

.search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-500);
}

.filter-select {
  padding: 9px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.btn-add-word {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Two-Column Editor Layout: Form on Right, Live Clinical Preview on Left */
.cms-editor-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
}

.cms-form-card {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

.cms-form-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary-900);
  border-bottom: 2px solid var(--primary-50);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Form Groups & Sections */
.form-section-header {
  font-size: 0.95rem;
  font-weight: 800;
  color: #475569;
  background: #f8fafc;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0 0.85rem 0;
  border-right: 4px solid var(--primary-600);
}

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

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

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

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.form-label span.cue-tag {
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-right: 4px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* Live Word Card & Ladder Preview Drawer */
.cms-preview-card {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--primary-200);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.preview-badge-live {
  background: #10b981;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.preview-word-header {
  text-align: center;
  padding: 1rem;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f0fdf4 100%);
  border-radius: var(--radius-lg);
  border: 1px dashed #86efac;
  margin-bottom: 1rem;
}

.preview-svg-box {
  width: 130px;
  height: 130px;
  margin: 0 auto 0.5rem auto;
}

.preview-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #1e293b;
}

/* Preview Generated Cue Ladder Prompts */
.preview-cues-ladder-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.preview-ladder-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-cue-item {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-cue-tag {
  font-weight: 800;
  color: #2563eb;
  white-space: nowrap;
  font-size: 0.72rem;
}

.preview-cue-text {
  color: #334155;
  font-weight: 600;
  flex: 1;
}

/* Database Table View */
.cms-table-wrapper {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.cms-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.cms-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-color);
}

.cms-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
}

.cms-table tr:hover {
  background: #f8fafc;
}

.word-cell-flex {
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-cell-icon {
  font-size: 1.6rem;
}

.table-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-table-action {
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-table-action.edit:hover { background: #eff6ff; color: #2563eb; border-color: #93c5fd; }
.btn-table-action.delete:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }

/* JSON Editor & Backup Panel */
.json-backup-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.json-textarea {
  width: 100%;
  height: 300px;
  font-family: 'Consolas', 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  font-size: 0.85rem;
  padding: 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #38bdf8;
  margin-top: 1rem;
}
