/* ================================================================
   Markdown Styles & Colored Typography System
   CUST Portal — Student Dashboard & Admin Console
   ================================================================ */

/* ── Base Markdown Body Container ── */
.markdown-body {
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text, #e6edf3);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Headings — Distinct Hues & Clear Hierarchy */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  font-size: 1.45rem;
  background: linear-gradient(135deg, #a78bfa 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-body h2 {
  font-size: 1.25rem;
  color: #38bdf8; /* Cyan accent */
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.2);
}

.markdown-body h3 {
  font-size: 1.1rem;
  color: #c084fc; /* Violet accent */
}

.markdown-body h4 {
  font-size: 1rem;
  color: #34d399; /* Emerald accent */
}

.markdown-body h5,
.markdown-body h6 {
  font-size: 0.9375rem;
  color: #fbbf24; /* Amber accent */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Paragraphs & Text */
.markdown-body p {
  margin-top: 0;
  margin-bottom: 0.85rem;
  color: inherit;
  line-height: 1.65;
}

.markdown-body strong,
.markdown-body b {
  font-weight: 700;
  color: var(--text-strong, #ffffff);
}

.markdown-body em,
.markdown-body i {
  color: var(--text-secondary, #cbd5e1);
  font-style: italic;
}

.markdown-body del,
.markdown-body s {
  color: var(--text-3, #64748b);
  text-decoration: line-through;
}

/* ── Light Theme Overrides for Markdown Body & Elements ── */
[data-theme] .markdown-body {
  color: #1e293b;
  --text-strong: #0f172a;
}

[data-theme] .markdown-body strong,
[data-theme] .markdown-body b {
  color: #0f172a;
  font-weight: 700;
}

[data-theme] .markdown-body em,
[data-theme] .markdown-body i {
  color: #334155;
}

[data-theme] .markdown-body h1 {
  background: linear-gradient(135deg, #6d28d9 0%, #0284c7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme] .markdown-body h2 {
  color: #0284c7;
  border-bottom-color: rgba(2, 132, 199, 0.2);
}

[data-theme] .markdown-body h3 {
  color: #7c3aed;
}

[data-theme] .markdown-body h4 {
  color: #059669;
}

[data-theme] .markdown-body h5,
[data-theme] .markdown-body h6 {
  color: #d97706;
}

[data-theme] .markdown-body ol > li::marker {
  color: #7c3aed;
}

[data-theme] .markdown-body a {
  color: #2563eb;
  border-bottom-color: rgba(37, 99, 235, 0.35);
}

[data-theme] .markdown-body a:hover {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

[data-theme] .markdown-body code {
  color: #db2777;
  background: rgba(219, 39, 119, 0.08);
  border-color: rgba(219, 39, 119, 0.2);
}

[data-theme] .markdown-body pre {
  background: #f8fafc;
  border-color: rgba(203, 213, 225, 0.8);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme] .markdown-body pre code {
  color: #0f172a;
}

[data-theme] .markdown-body blockquote {
  background: rgba(139, 92, 246, 0.05);
  border-left-color: #7c3aed;
  color: #334155;
}

[data-theme] .markdown-alert-note {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}
[data-theme] .markdown-alert-note .markdown-alert-title { color: #1d4ed8; }

[data-theme] .markdown-alert-tip {
  border-color: #10b981;
  background: #f0fdf4;
  color: #166534;
}
[data-theme] .markdown-alert-tip .markdown-alert-title { color: #15803d; }

[data-theme] .markdown-alert-important {
  border-color: #8b5cf6;
  background: #faf5ff;
  color: #581c87;
}
[data-theme] .markdown-alert-important .markdown-alert-title { color: #6b21a8; }

[data-theme] .markdown-alert-warning {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}
[data-theme] .markdown-alert-warning .markdown-alert-title { color: #b45309; }

[data-theme] .markdown-alert-caution {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}
[data-theme] .markdown-alert-caution .markdown-alert-title { color: #b91c1c; }

[data-theme] .markdown-body table {
  border-color: rgba(203, 213, 225, 0.8);
}

[data-theme] .markdown-body th {
  background: #f1f5f9;
  color: #0f172a;
  border-bottom-color: rgba(203, 213, 225, 0.8);
}

[data-theme] .markdown-body td {
  border-bottom-color: rgba(226, 232, 240, 0.8);
  color: #334155;
}

[data-theme] .markdown-body tr:nth-child(even) td {
  background: #f8fafc;
}

[data-theme] .markdown-body hr {
  background: rgba(203, 213, 225, 0.8);
}

/* Distinct Colored Lists */
.markdown-body ul {
  list-style: none;
  padding-left: 1.25rem;
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
}

.markdown-body ul > li {
  position: relative;
  margin-bottom: 0.45rem;
  line-height: 1.6;
}

.markdown-body ul > li::before {
  content: "•";
  position: absolute;
  left: -1rem;
  top: -0.1rem;
  color: #38bdf8; /* Vibrant cyan bullet */
  font-weight: 800;
  font-size: 1.2rem;
  line-height: 1;
}

/* Nested List Markers with Harmonious Accent Colors */
.markdown-body ul ul > li::before {
  content: "◦";
  color: #c084fc; /* Violet bullet for level 2 */
  font-size: 1.1rem;
}

.markdown-body ul ul ul > li::before {
  content: "▪";
  color: #34d399; /* Emerald bullet for level 3 */
  font-size: 0.85rem;
  top: 0.15rem;
}

.markdown-body ol {
  padding-left: 1.4rem;
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
}

.markdown-body ol > li {
  margin-bottom: 0.45rem;
  line-height: 1.6;
}

.markdown-body ol > li::marker {
  color: #a78bfa; /* Violet/purple number marker */
  font-weight: 700;
}

/* Task Checklists */
.markdown-body input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid #8b5cf6;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.1);
  display: inline-block;
  vertical-align: middle;
  position: relative;
  margin-right: 8px;
  cursor: default;
}

.markdown-body input[type="checkbox"]:checked {
  background: #8b5cf6;
}

.markdown-body input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Vibrant Links with Hover Animations */
.markdown-body a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed rgba(96, 165, 250, 0.4);
  padding-bottom: 1px;
  transition: all 0.2s ease;
  word-break: break-all;
}

.markdown-body a:hover {
  color: #93c5fd;
  border-bottom: 1px solid #93c5fd;
  text-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
}

/* Inline Code & Block Code */
.markdown-body code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.85em;
  color: #f472b6; /* Distinct pink/magenta for inline code */
  background: rgba(244, 114, 182, 0.1);
  border: 1px solid rgba(244, 114, 182, 0.2);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  word-break: break-word;
}

.markdown-body pre {
  margin: 1rem 0;
  padding: 1rem 1.15rem;
  background: #080c16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow-x: auto;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.markdown-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Blockquotes */
.markdown-body blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  border-radius: 0 8px 8px 0;
  color: #cbd5e1;
  font-style: italic;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

/* GitHub-Style Alert Callout Boxes */
.markdown-alert {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border-left: 4px solid;
  background: rgba(255, 255, 255, 0.02);
}

.markdown-alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.markdown-alert-body p:last-child {
  margin-bottom: 0;
}

.markdown-alert-note {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  color: #bfdbfe;
}
.markdown-alert-note .markdown-alert-title { color: #60a5fa; }

.markdown-alert-tip {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  color: #a7f3d0;
}
.markdown-alert-tip .markdown-alert-title { color: #34d399; }

.markdown-alert-important {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  color: #ddd6fe;
}
.markdown-alert-important .markdown-alert-title { color: #a78bfa; }

.markdown-alert-warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  color: #fde68a;
}
.markdown-alert-warning .markdown-alert-title { color: #fbbf24; }

.markdown-alert-caution {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
}
.markdown-alert-caution .markdown-alert-title { color: #f87171; }

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.875rem;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  font-weight: 700;
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-body td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-2, #94a3b8);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

/* Horizontal Rule */
.markdown-body hr {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  margin: 1.5rem 0;
}

/* ── Long Description Clamping & Detail Modals ── */
.card-summary.clamped,
.view-all-item p.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  line-height: 1.5;
  margin-bottom: var(--space-2, 0.5rem);
}

.card-read-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent, #8b5cf6);
  margin-bottom: var(--space-3, 0.75rem);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.card-read-more:hover {
  opacity: 0.85;
  text-decoration: underline;
}

/* Detail modal scroll container */
.detail-modal-body-scroll {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  margin-right: -6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.detail-modal-body-scroll::-webkit-scrollbar {
  width: 6px;
  display: block;
}

.detail-modal-body-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* ── Admin Markdown Editor Component ── */
.md-editor-container {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #090d16;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s;
}

.md-editor-container:focus-within {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 1px var(--accent, #6366f1), 0 4px 16px rgba(0, 0, 0, 0.35);
}

.md-editor-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 8px;
}

.md-editor-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px;
  border-radius: 6px;
}

.md-editor-tab-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-2, #8b949e);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.md-editor-tab-btn:hover {
  color: #fff;
}

.md-editor-tab-btn.active {
  background: var(--accent, #6366f1);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
}

.md-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

.md-tb-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-2, #8b949e);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.md-tb-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
}

.md-tb-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 3px;
}

.md-template-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.md-template-select {
  font-size: 0.75rem;
  font-weight: 500;
  height: 26px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #111726;
  color: #cbd5e1;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.md-template-select:hover,
.md-template-select:focus {
  border-color: var(--accent, #6366f1);
  color: #fff;
}

.md-editor-pane {
  min-height: 180px;
  max-height: 380px;
}

.md-editor-textarea {
  width: 100%;
  min-height: 180px;
  max-height: 380px;
  padding: 12px 14px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text, #e6edf3);
  background: transparent;
  border: none;
  resize: vertical;
  outline: none;
  display: block;
}

.md-editor-preview {
  padding: 14px 16px;
  min-height: 180px;
  max-height: 380px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.25);
}

.md-editor-preview.hidden,
.md-editor-textarea.hidden {
  display: none;
}

.md-editor-footer {
  padding: 6px 12px;
  font-size: 0.7rem;
  color: var(--text-3, #4f5666);
  background: rgba(255, 255, 255, 0.015);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
