/* ============================================
   Custom Scrollbar - Thin & Modern
   ============================================ */

/* Firefox */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* Webkit browsers (Chrome, Safari, Edge) */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.custom-scrollbar::-webkit-scrollbar-thumb:active {
  background: #64748b;
}

/* ============================================
   Tutorial Content Styling
   Fixes ul/li rendering issues
   ============================================ */

/* Reset and Base Styles */
.tutorial-content {
  color: #374151;
  line-height: 1.75;
  width: 100%;
  /* ✨ Full width */
  max-width: 100%;
  /* ✨ Never exceed parent */
  overflow-x: visible;
  /* ✨ Allow horizontal scroll for tables */
  overflow-y: visible;
  /* ✨ Allow vertical scroll */
  box-sizing: border-box;
  /* ✨ Include padding in width */
}

/* ✨ Ensure all direct children respect container width */
.tutorial-content>* {
  max-width: 100%;
  box-sizing: border-box;
}

/* Headings */
.tutorial-content h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: #111827;
}

.tutorial-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-right: 1rem;
  color: #111827;
}

@media (min-width: 1024px) {
  .tutorial-content h2 {
    padding-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content h2 {
    padding-right: 2rem;
  }
}

.tutorial-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-left: 1rem;
  padding-right: 1rem;
  color: #1f2937;
}

@media (min-width: 1024px) {
  .tutorial-content h3 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content h3 {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.tutorial-content h4 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #1f2937;
}

.tutorial-content h5,
.tutorial-content h6 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #374151;
}

/* Paragraphs */
.tutorial-content p {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  color: #374151;
  font-size: 14px;
  line-height: 1.75;
}

@media (min-width: 1024px) {
  .tutorial-content p {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content p {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Links */
.tutorial-content a {
  color: #dc2626;
  text-decoration: underline;
  font-weight: 500;
}

.tutorial-content a:hover {
  color: #991b1b;
}

/* ============================================
   LISTS - UL/OL/LI CRITICAL FIX
   ============================================ */

/* Unordered Lists (ul) */
.tutorial-content ul {
  list-style-type: disc !important;
  list-style-position: outside !important;
  padding-left: 1.5rem !important;
  margin-left: 1rem;
  margin-right: 1rem;
  margin-top: 1rem !important;
  margin-bottom: 1rem !important;
  color: #374151;
}

@media (min-width: 1024px) {
  .tutorial-content ul {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content ul {
    margin-left: 2rem;
    margin-right: 2rem;
  }
}

/* Nested ul */
.tutorial-content ul ul {
  list-style-type: circle !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  padding-left: 1.5rem !important;
}

.tutorial-content ul ul ul {
  list-style-type: square !important;
}

/* Ordered Lists (ol) */
.tutorial-content ol {
  list-style-type: decimal !important;
  list-style-position: outside !important;
  padding-left: 1.5rem !important;
  margin-left: 1rem;
  margin-right: 1rem;
  margin-top: 1rem !important;
  margin-bottom: 1rem !important;
  color: #374151;
}

@media (min-width: 1024px) {
  .tutorial-content ol {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content ol {
    margin-left: 2rem;
    margin-right: 2rem;
  }
}

/* Nested ol */
.tutorial-content ol ol {
  list-style-type: lower-alpha !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  padding-left: 1.5rem !important;
}

.tutorial-content ol ol ol {
  list-style-type: lower-roman !important;
}

/* List Items (li) */
.tutorial-content li {
  display: list-item !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
  padding-left: 0.25rem !important;
  color: #374151;
  line-height: 1.75;
}

/* First li in list */
.tutorial-content ul>li:first-child,
.tutorial-content ol>li:first-child {
  margin-top: 0 !important;
}

/* Last li in list */
.tutorial-content ul>li:last-child,
.tutorial-content ol>li:last-child {
  margin-bottom: 0 !important;
}

/* Li with nested lists */
.tutorial-content li>ul,
.tutorial-content li>ol {
  margin-top: 0.5rem !important;
  margin-bottom: 0.25rem !important;
}

/* ✨ OVERRIDE: Remove center alignment from any element in tables */
.tutorial-content table * {
  text-align: inherit !important;
  /* Inherit from parent (left) */
}

.tutorial-content table th,
.tutorial-content table td,
.tutorial-content table p,
.tutorial-content table div,
.tutorial-content table span,
.tutorial-content table ul,
.tutorial-content table ol,
.tutorial-content table li {
  text-align: left !important;
  /* Force left align */
  margin-left: 0 !important;
  /* ✨ No left margin */
}

/* ============================================
   IMAGES - Support Tiptap Editor Alignment & Width
   ============================================ */

.tutorial-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  display: block;
  /* Required for margin auto to work */
}

/* ✨ Tiptap Image Alignment Support in Blog/Tutorial Display */
.tutorial-content img[data-align="left"],
.tutorial-content .tiptap-image[data-align="left"] {
  margin-left: 0;
  margin-right: auto;
  display: block;
}

.tutorial-content img[data-align="center"],
.tutorial-content .tiptap-image[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.tutorial-content img[data-align="right"],
.tutorial-content .tiptap-image[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
  display: block;
}

/* ✨ Respect width attribute from Tiptap editor */
.tutorial-content img[width],
.tutorial-content .tiptap-image[width] {
  /* Width is set inline via HTML attribute, respect it */
  max-width: 100%;
  /* But never exceed container */
}

/* ✨ Figure caption support (if added later) */
.tutorial-content figure {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.tutorial-content figure img {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.tutorial-content figcaption {
  font-size: 0.875rem;
  color: #6b7280;
  text-align: center;
  font-style: italic;
  margin-top: 0.5rem;
}

/* ============================================
   CODE BLOCKS
   ============================================ */

.tutorial-content pre {
  background-color: #1f2937;
  color: #f3f4f6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-left: 1rem;
  margin-right: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

@media (min-width: 1024px) {
  .tutorial-content pre {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content pre {
    margin-left: 2rem;
    margin-right: 2rem;
  }
}

.tutorial-content code {
  background-color: #f3f4f6;
  color: #dc2626;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: 'Monaco', 'Courier New', monospace;
}

.tutorial-content pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */

.tutorial-content blockquote {
  padding-right: 1rem;
  margin-right: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  color: #6b7280;
  font-style: italic;
}

@media (min-width: 1024px) {
  .tutorial-content blockquote {
    margin-right: 1.5rem;
  }
}

@media (min-width: 1280px) {
  .tutorial-content blockquote {
    margin-right: 2rem;
  }
}

/* ============================================
   TABLES - Enhanced Beautiful Styling (Thin Borders)
   ============================================ */

/* Mobile table scroll wrapper - ALWAYS ACTIVE */
.tutorial-content .table-scroll-wrapper {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  /* ✨ Always allow horizontal scroll */
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  /* ✨ Smooth scroll on iOS */
  margin: 1.5rem 0;
  border-radius: 0.375rem;
  position: relative;
  /* ✨ Scroll hint shadow - indicates scrollable content */
  background:
    linear-gradient(90deg, white 30%, rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(255, 255, 255, 0), white 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .15), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .15), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
  /* ✨ Touch action for mobile */
  touch-action: pan-x pan-y;
  /* ✨ Prevent content from breaking out */
  contain: layout;
}

/* ✨ Scroll indicator hint on mobile */
@media (max-width: 767px) {
  .tutorial-content .table-scroll-wrapper {
    margin: 1rem 0;
    /* ✨ Add padding bottom for scrollbar visibility */
    padding-bottom: 4px;
  }

  .tutorial-content .table-scroll-wrapper::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.03));
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
  }

  .tutorial-content .table-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
    /* ✨ Larger scrollbar on mobile for touch */
  }
}

.tutorial-content .table-scroll-wrapper::-webkit-scrollbar {
  height: 6px;
}

.tutorial-content .table-scroll-wrapper::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 3px;
}

.tutorial-content .table-scroll-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.tutorial-content .table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Keep scroll on all sizes - table is wide */
@media (min-width: 768px) {
  .tutorial-content .table-scroll-wrapper {
    overflow-x: auto !important;
    /* ✨ Keep scroll even on desktop */
    margin: 1.5rem 0;
  }
}

.tutorial-content table {
  width: 100% !important;
  min-width: 600px !important;
  max-width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto !important;
  margin-top: 0;
  margin-bottom: 0;
  border: none;
  border-radius: 1rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(229, 231, 235, 0.5);
  display: table !important;
  overflow: hidden !important;
  background: #ffffff;
}

/* When inside wrapper, remove margin (wrapper handles it) */
.tutorial-content .table-scroll-wrapper>table {
  margin: 0;
}

/* ✨ Flexible column sizing with smart distribution */
.tutorial-content table th,
.tutorial-content table td {
  width: auto !important;
}

/* ✨ First column (Quy trình) - compact */
.tutorial-content table th:first-child,
.tutorial-content table td:first-child {
  width: 24% !important;
  min-width: 140px !important;
  max-width: 180px !important;
  white-space: normal !important;
}

/* ✨ Middle columns (Hướng dẫn) - expanded, take most space */
.tutorial-content table th:not(:first-child):not(:last-child),
.tutorial-content table td:not(:first-child):not(:last-child) {
  width: 58% !important;
  min-width: 300px !important;
}

/* ✨ Last column (Demo/Images) - compact for images */
.tutorial-content table th:last-child,
.tutorial-content table td:last-child {
  width: 18% !important;
  min-width: 250px !important;
  max-width: 260px !important;
  text-align: center !important;
}

/* Responsive - keep border-radius on all sizes */
@media (min-width: 768px) {
  .tutorial-content table {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    border-radius: 1rem;
  }
}

@media (min-width: 1024px) {
  .tutorial-content table {
    width: 100%;
  }
}

@media (min-width: 1280px) {
  .tutorial-content table {
    width: 100%;
  }
}

.tutorial-content th {
  background: linear-gradient(135deg, #ff3333 0%, #ffcc99 100%);
  padding: 1rem 1.25rem;
  text-align: center !important;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffffff !important;
  border-bottom: none;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal !important;
  vertical-align: middle;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tutorial-content th:last-child {
  border-right: none;
}

/* ✨ First row as header (when no thead) */
.tutorial-content tbody tr:first-child td {
  background: #ff6666;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center !important;
  padding: 1rem 1.25rem;
  border-bottom: none;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tutorial-content tbody tr:first-child td:last-child {
  border-right: none;
}

.tutorial-content tbody tr:first-child td p,
.tutorial-content tbody tr:first-child td strong {
  color: #ffffff !important;
  text-align: center !important;
}

/* ✨ Rounded corners for header row */
.tutorial-content tbody tr:first-child td:first-child {
  border-top-left-radius: 1rem;
}

.tutorial-content tbody tr:first-child td:last-child {
  border-top-right-radius: 1rem;
}

/* ✨ Rounded corners for last row */
.tutorial-content tbody tr:last-child td:first-child {
  border-bottom-left-radius: 1rem;
}

.tutorial-content tbody tr:last-child td:last-child {
  border-bottom-right-radius: 1rem;
}

/* ✨ Step number styling in first column */
.tutorial-content tbody tr:not(:first-child) td:first-child {
  font-weight: 500;
  color: #1f2937;
}

.tutorial-content td {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  border-right: 1px solid #f3f4f6;
  background-color: #ffffff;
  transition: all 0.3s ease;
  text-align: left !important;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal !important;
  hyphens: auto;
  white-space: normal !important;
  vertical-align: middle;
  line-height: 1.7;
  font-size: 0.95rem;
  color: #374151;
}

/* ✨ Zebra stripes - skip first row (header) */
.tutorial-content tbody tr:nth-child(even):not(:first-child) td {
  background-color: #fafafa;
}

.tutorial-content tbody tr:nth-child(odd):not(:first-child) td {
  background-color: #ffffff;
}

/* ✨ CRITICAL: Remove any default margins from p/div in cells */
.tutorial-content td>p:first-child,
.tutorial-content td>div:first-child,
.tutorial-content td>ul:first-child,
.tutorial-content td>ol:first-child {
  margin-top: 0 !important;
}

.tutorial-content td>p:last-child,
.tutorial-content td>div:last-child,
.tutorial-content td>ul:last-child,
.tutorial-content td>ol:last-child {
  margin-bottom: 0 !important;
}

/* ✨ Remove ALL padding/margin from paragraphs in table cells */
.tutorial-content table p {
  margin: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}

/* ✨ Spacing between multiple p tags */
.tutorial-content table p+p {
  margin-top: 0.5rem !important;
}

/* ✨ Remove padding from divs in table cells */
.tutorial-content table div {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  text-align: left !important;
}

/* ✨ Inline elements in table cells */
.tutorial-content table strong,
.tutorial-content table span,
.tutorial-content table em,
.tutorial-content table a {
  margin: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}

.tutorial-content td:last-child {
  border-right: none;
}

.tutorial-content tr:last-child td {
  border-bottom: none;
}

/* ✨ Enhanced hover effect - skip header row */
.tutorial-content tbody tr:not(:first-child):hover td {
  background-color: #fff5f5 !important;
  color: #1f2937;
}

/* ============================================
   LISTS IN TABLES - Special handling
   ============================================ */

/* UL/OL inside table cells */
.tutorial-content table ul,
.tutorial-content table ol {
  margin: 0.5rem 0 0 0 !important;
  /* ✨ Remove left margin */
  padding-left: 1.1rem !important;
  /* ✨ Minimal indent for bullets */
  list-style-position: outside !important;
}

.tutorial-content table ul {
  list-style-type: disc !important;
  /* ✨ Standard bullet */
}

.tutorial-content table ol {
  list-style-type: decimal !important;
  /* ✨ Standard numbers */
}

/* LI inside table cells */
.tutorial-content table li {
  display: list-item !important;
  /* ✨ CRITICAL: Show as list item */
  margin: 0.25rem 0 !important;
  /* ✨ Compact spacing */
  padding-left: 0.15rem !important;
  /* ✨ Minimal padding for tighter left align */
  line-height: 1.6 !important;
  color: #374151;
  text-align: left !important;
  /* ✨ Left align list content */
}

/* First/last li in table lists */
.tutorial-content table ul>li:first-child,
.tutorial-content table ol>li:first-child {
  margin-top: 0 !important;
}

.tutorial-content table ul>li:last-child,
.tutorial-content table ol>li:last-child {
  margin-bottom: 0 !important;
}

/* Nested lists in table cells */
.tutorial-content table ul ul,
.tutorial-content table ol ol,
.tutorial-content table ul ol,
.tutorial-content table ol ul {
  margin-top: 0.25rem !important;
  margin-bottom: 0.25rem !important;
  padding-left: 1rem !important;
}

/* ✨ Enhanced Images in tables */
.tutorial-content table img {
  max-width: min(100%, 200px);
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.5rem;
  margin: 0.25rem auto;
  display: block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.25s ease;
  cursor: zoom-in;
  background: #ffffff;
}

.tutorial-content table img:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

/* Responsive table - mobile optimizations */
@media (max-width: 767px) {
  .tutorial-content table {
    font-size: 0.875rem;
    min-width: 600px !important;
    /* ✨ Wider than viewport = scroll */
  }

  .tutorial-content th,
  .tutorial-content td {
    padding: 0.75rem 0.5rem;
    white-space: normal !important;
    text-align: left !important;
    /* ✨ Maintain left align on mobile */
  }

  /* ✨ First column responsive - compact */
  .tutorial-content table th:first-child,
  .tutorial-content table td:first-child {
    width: 18% !important;
    min-width: 100px !important;
    max-width: 140px !important;
  }

  /* ✨ Middle columns responsive - expanded */
  .tutorial-content table th:not(:first-child):not(:last-child),
  .tutorial-content table td:not(:first-child):not(:last-child) {
    width: 58% !important;
    min-width: 220px !important;
  }

  /* ✨ Last column responsive - compact for images */
  .tutorial-content table th:last-child,
  .tutorial-content table td:last-child {
    width: 24% !important;
    min-width: 140px !important;
    max-width: 180px !important;
  }

  .tutorial-content table img {
    max-width: 140px !important;
    max-height: 100px !important;
  }

  /* Mobile header row styling */
  .tutorial-content tbody tr:first-child td {
    padding: 0.6rem 0.4rem;
    font-size: 0.75rem;
  }

  /* ✨ Lists in tables on mobile */
  .tutorial-content table ul,
  .tutorial-content table ol {
    padding-left: 0.9rem !important;
    /* ✨ Tighter on mobile */
    margin-left: 0 !important;
    font-size: 0.875rem;
  }

  .tutorial-content table li {
    margin: 0.2rem 0 !important;
    padding-left: 0.1rem !important;
    /* ✨ Minimal padding */
  }
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */

.tutorial-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* ============================================
   STRONG & EMPHASIS
   ============================================ */

.tutorial-content strong {
  font-weight: 700;
  color: #111827;
}

.tutorial-content em {
  font-style: italic;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
  .tutorial-content {
    font-size: 0.9375rem;
  }

  .tutorial-content h1 {
    font-size: 1.875rem;
  }

  .tutorial-content h2 {
    font-size: 1.5rem;
  }

  .tutorial-content h3 {
    font-size: 1.25rem;
  }

  .tutorial-content ul,
  .tutorial-content ol {
    padding-left: 1.25rem !important;
  }
}