/* ─────────────────────────────────────────────────────────────
   AgenToDo — Documentation Styles
   For doc pages with DocLayout.astro
   Builds on styles.css with doc-specific layout and typography
   ───────────────────────────────────────────────────────────── */

/* ─────────────────────────────────────────  DOCS LAYOUT  ──── */

.docs-layout {
  display: flex;
  min-height: calc(100vh - 80px); /* Account for nav height */
  background: var(--white);
}

.docs-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--gray-50);
  border-right: 1px solid var(--gray-200);
  position: sticky;
  top: 64px; /* Height of main nav */
  height: calc(100vh - 64px);
  overflow-y: auto;
  z-index: 10;
}

.docs-sidebar-content {
  padding: 20px 16px;
}

.docs-main {
  flex: 1;
  min-width: 0; /* Allow flexbox to shrink below content width */
}

.docs-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 64px 32px;
}

/* ─────────────────────────────────────────  SIDEBAR NAV  ──── */

.docs-nav-section {
  margin-bottom: 24px;
  padding: 0;
}

.docs-nav-title {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', var(--text);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin: 0 0 8px 0;
  padding: 0 12px;
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--white);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.docs-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--gray-700);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', var(--text);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.3;
  transition: background 0.15s ease;
  text-decoration: none;
  border-bottom: 1px solid var(--gray-100);
}

.docs-nav a:last-child {
  border-bottom: none;
}

.docs-nav a:hover {
  background: var(--gray-50);
  color: var(--ink);
}

.docs-nav a.active {
  background: var(--pink);
  color: var(--white);
  font-weight: 500;
}

.docs-nav a svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
}

.docs-nav a.active svg {
  stroke: var(--white);
  opacity: 1;
}

.docs-nav a .external-icon {
  margin-left: auto;
  width: 13px;
  height: 13px;
  opacity: 0.5;
}

/* ─────────────────────────────────────────  MOBILE NAV  ──── */

.nav-mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
}

.nav-mobile-toggle span {
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: all 0.3s ease;
}

.nav-mobile-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-mobile-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-mobile-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* ─────────────────────────────────────────  DOCS TYPOGRAPHY  ──── */

.docs-content h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0 0 16px 0;
}

.docs-content h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 48px 0 20px 0;
  border-top: 1px solid var(--gray-200);
  padding-top: 48px;
}

.docs-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.docs-content h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 32px 0 16px 0;
}

.docs-content h4 {
  font-family: var(--text);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  margin: 24px 0 12px 0;
}

.docs-content p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-700);
  margin: 0 0 16px 0;
}

.docs-content .lead {
  font-size: 20px;
  line-height: 1.5;
  color: var(--gray-600);
  margin: 0 0 32px 0;
  font-weight: 400;
}

/* ─────────────────────────────────────────  LISTS  ──── */

.docs-content ul,
.docs-content ol {
  margin: 16px 0;
  padding-left: 20px;
}

.docs-content li {
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-700);
  margin: 8px 0;
}

.docs-content li strong {
  color: var(--ink);
  font-weight: 600;
}

/* ─────────────────────────────────────────  CODE  ──── */

.docs-content code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
  background: var(--gray-100);
  color: var(--ink);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.docs-content pre {
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin: 24px 0;
  overflow-x: auto;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--gray-900);
}

.docs-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
  font-weight: 400;
}

/* Syntax highlighting for terminal examples */
.docs-content pre .comment { color: #6B7280; }
.docs-content pre .keyword { color: #F59E0B; }
.docs-content pre .string { color: #10B981; }
.docs-content pre .number { color: #3B82F6; }
.docs-content pre .operator { color: #EF4444; }
.docs-content pre .function { color: #8B5CF6; }

/* ─────────────────────────────────────────  TABLES  ──── */

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
}

.docs-content th {
  background: var(--gray-50);
  color: var(--ink);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border: 1px solid var(--gray-200);
}

.docs-content td {
  padding: 12px 16px;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.docs-content tr:nth-child(even) td {
  background: var(--gray-50);
}

.docs-content td code {
  font-size: 13px;
}

/* ─────────────────────────────────────────  BLOCKQUOTES & CALLOUTS  ──── */

.docs-content blockquote {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--gray-50);
  border-left: 4px solid var(--pink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.docs-content blockquote p {
  color: var(--gray-600);
  margin: 0;
  font-style: italic;
}

.doc-callout {
  margin: 24px 0;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  border: 1px solid;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.doc-callout.tip {
  background: #FFF0F7;
  border-color: var(--pink);
  color: #880055;
}

.doc-callout.warning {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #92400E;
}

.doc-callout.note {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.doc-callout-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.doc-callout-content p {
  margin: 0;
  color: inherit;
}

/* ─────────────────────────────────────────  LINKS  ──── */

.docs-content a {
  color: var(--pink);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.docs-content a:hover {
  color: var(--pink-hover);
  text-decoration: underline;
}

.docs-content a[href^="http"]::after {
  content: "↗";
  font-size: 0.8em;
  margin-left: 4px;
  opacity: 0.6;
}

/* ─────────────────────────────────────────  FOOTER  ──── */

.docs-footer {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 32px 0;
}

.docs-footer-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.docs-footer-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.docs-footer-brand .brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.docs-footer-brand p {
  font-size: 14px;
  color: var(--gray-500);
  margin: 0;
}

.docs-footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.docs-footer-links a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.docs-footer-links a:hover {
  color: var(--ink);
}

.docs-footer-links svg {
  width: 18px;
  height: 18px;
}

/* ─────────────────────────────────────────  RESPONSIVE  ──── */

@media (max-width: 1024px) {
  .docs-content {
    padding: 48px 24px;
  }
}

@media (max-width: 900px) {
  .nav-mobile-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
  }

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

  .docs-sidebar {
    position: fixed;
    top: 80px;
    left: -260px;
    width: 260px;
    height: calc(100vh - 80px);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 100;
  }

  .docs-sidebar.mobile-open {
    left: 0;
  }

  .docs-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .docs-sidebar-overlay.visible {
    display: block;
  }

  .docs-main {
    width: 100%;
  }

  .docs-content {
    padding: 32px 20px;
    max-width: none;
  }

  .docs-content h2 {
    margin-top: 40px;
    padding-top: 32px;
  }

  .docs-footer-content {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
}

@media (max-width: 480px) {
  .docs-content {
    padding: 24px 16px;
  }

  .docs-content h1 {
    font-size: 28px;
  }

  .docs-content h2 {
    font-size: 24px;
  }

  .docs-content h3 {
    font-size: 20px;
  }

  .docs-content pre {
    padding: 16px;
    font-size: 13px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .docs-content table {
    font-size: 14px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .docs-content th,
  .docs-content td {
    padding: 8px 12px;
  }
}
/* ─────────────────────────────────────────  PREV / NEXT NAV  ──── */

.docs-prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--gray-200);
}

.docs-prev-next-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  text-decoration: none;
  transition: all 0.2s ease;
}

.docs-prev-next-link:hover {
  border-color: var(--pink);
  background: #FFF0F7;
}

.docs-prev-next-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.docs-prev {
  align-items: flex-start;
}

.docs-next {
  align-items: flex-end;
  text-align: right;
}

.docs-prev-next-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

.docs-prev-next-link:hover .docs-prev-next-title {
  color: var(--pink);
}

@media (max-width: 480px) {
  .docs-prev-next {
    grid-template-columns: 1fr;
  }
}
