/* Layout principal */
.page-container {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease-in-out;
  width: 100%;
}

.main-content.sidebar-open {
  margin-right: 280px;
}

.main-content.chat-open {
  margin-right: 380px;
}

/* Sidebar */
.sidebar-container {
  width: 280px;
  border-left: 1px solid var(--ntabs-border);
  background: var(--ntabs-bg-primary);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease-in-out, background-color 0.2s ease;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  transform: translateX(100%);
}

.sidebar-container.open {
  transform: translateX(0);
}

.sidebar {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  color: var(--ntabs-text-secondary);
  border-radius: 0.375rem;
  margin-bottom: 0.25rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar li:hover {
  background: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

.sidebar li.back {
  color: var(--ntabs-text-secondary);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--ntabs-border);
  padding-bottom: 1rem;
}

.sidebar li a {
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  flex: 1;
}

/* Header - main page header with logo, breadcrumbs, and actions */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ntabs-border);
  background: var(--ntabs-header-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.back-button {
  display: flex;
  align-items: center;
  color: var(--ntabs-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s ease;
}

.back-button:hover {
  color: var(--ntabs-text-primary);
}

/* Conteúdo */
.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Turbo-frame styling - layout rules are in empty_state.css for consistency */
.page-content > turbo-frame {
  background-color: var(--ntabs-bg-secondary);
  transition: background-color 0.2s ease;
}

.lesson-navigation {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ntabs-bg-primary);
  border-bottom: 1px solid var(--ntabs-border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.lesson-count {
  color: var(--ntabs-text-secondary);
  font-size: 0.875rem;
}

.lesson-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--ntabs-text-primary);
  margin-bottom: 1.5rem;
}

.lesson-navigation .sidebar-actions {
  display: flex;
  align-items: center;
}

/* Editor Content - layout rules in empty_state.css, styling here */
.content {
  padding: 2rem;
  background-color: var(--ntabs-bg-secondary);
  transition: background-color 0.2s ease;
}

.editorjs-container {
  background: var(--ntabs-bg-primary);
  padding: 2em;
  transition: background-color 0.2s ease;
}

/* Mark editor container
   !important needed to override Mark.js library defaults for ntabs integration */
.mark-container {
  background: var(--ntabs-bg-primary) !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  min-height: 400px;
  transition: background-color 0.2s ease;
}

.mark-container.mark-dark {
  background: var(--mark-bg-primary, #0d1117) !important;
}

/* DocMap positioning fix for delegateScroll mode
   Layout: [content + scrollbar] [DocMap at viewport edge]

   We need to:
   1. Add padding-right to page-content to make room for DocMap
   2. Position DocMap fixed to the viewport right edge
   3. Remove the mark-panels margin since DocMap is now outside the scroll container */

/* Add right padding to page-content to reserve space for DocMap */
.page-content {
  transition: padding-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed state (default when visible) = 24px */
.page-content:has(.mark-container.mark-delegate-scroll.mark-docmap-visible) {
  padding-right: 24px;
}

/* Preview state (on hover) = 60px */
.page-content:has(.mark-container.mark-delegate-scroll.mark-docmap-visible[data-docmap-state="preview"]) {
  padding-right: 60px;
}

/* Expanded state (on click) = 280px */
.page-content:has(.mark-container.mark-delegate-scroll.mark-docmap-visible[data-docmap-state="expanded"]) {
  padding-right: 280px;
}

/* Position DocMap fixed to viewport right edge */
.mark-container.mark-delegate-scroll .mark-docmap {
  position: fixed;
  right: 0;
  top: 60px; /* Height of .page-header (0.75rem padding * 2 + line-height) */
  bottom: 0;
  height: auto;
  z-index: 50;
}

/* Remove mark-panels margin when DocMap is fixed (DocMap is now outside content flow) */
.mark-container.mark-delegate-scroll.mark-docmap-visible .mark-panels {
  margin-right: 0;
}

/* Bottom breathing room for Mark editor form - matches EditorJS spacing */
div[data-controller="mark"] > form {
  padding-bottom: 2rem;
}

.trix-content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  font-size: 1.125rem;
  line-height: 1.75;
  padding: 0 1rem;
}

/* Trix editor - !important needed to override trix defaults */
trix-editor {
  width: 100% !important;
  max-width: 900px !important;
  margin: 0 auto !important;
  padding: 2rem !important;
  background: var(--ntabs-bg-primary) !important;
  border: none !important;
  outline: none !important;
}

.trix-content .attachment-gallery > .attachment,
.trix-content .attachment-gallery > * {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 > .attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > * {
  flex-basis: 50%;
  max-width: 50%;
}

.trix-content .attachment-gallery.attachment-gallery--4 > .attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > * {
  flex-basis: 25%;
  max-width: 25%;
}

/* Trix Toolbar - !important needed to override trix defaults */
.trix-toolbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  background: var(--ntabs-bg-primary) !important;
  border-bottom: 1px solid var(--ntabs-border) !important;
  padding: 0.5rem 0 !important;
  margin-bottom: 1rem !important;
}

.trix-toolbar .trix-button-group {
  border-color: var(--ntabs-border) !important;
  margin-bottom: 0 !important;
}

.trix-toolbar .trix-button {
  border-color: var(--ntabs-border) !important;
}

.trix-toolbar .trix-button:hover {
  background: var(--ntabs-bg-secondary) !important;
}

.trix-toolbar .trix-button.trix-active {
  background: var(--ntabs-bg-secondary) !important;
}

/* Trix Editor Container */
.trix-editor-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Chat Sidebar */
.chat-sidebar {
  width: 380px;
  border-left: 1px solid var(--ntabs-border);
  background: var(--ntabs-bg-primary);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease-in-out, background-color 0.2s ease, border-color 0.2s ease;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--ntabs-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s ease;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.chat-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  overflow: hidden;
}

.chat-message-content {
  flex: 1;
}

.chat-message-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.chat-author {
  font-weight: 500;
  color: var(--ntabs-text-primary);
}

.chat-time {
  font-size: 0.75rem;
  color: var(--ntabs-text-secondary);
}

.chat-text {
  color: var(--ntabs-text-primary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.chat-action-button {
  color: var(--ntabs-text-secondary);
  font-size: 0.75rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.chat-action-button:hover {
  color: var(--ntabs-text-primary);
}

.chat-input-container {
  padding: 1rem;
  border-top: 1px solid var(--ntabs-border);
  transition: border-color 0.2s ease;
}

.chat-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: var(--ntabs-bg-secondary);
  border: 1px solid var(--ntabs-border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  min-height: 1.5rem;
  resize: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
}

.chat-toolbar {
  display: flex;
  gap: 0.5rem;
}

.chat-toolbar-button {
  padding: 0.25rem;
  color: var(--ntabs-text-secondary);
  border-radius: 0.25rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-toolbar-button:hover {
  background: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

/* Utilitários */
.icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Chat Visibility */
.chat-sidebar.hidden {
  transform: translateX(100%);
}

/* Ajustes de navegação */
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--ntabs-text-secondary);
  border-radius: 0.375rem;
  transition: all 0.2s;
}

.nav-button:hover {
  background-color: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

.nav-button + .nav-button {
  margin-left: 0.5rem;
}

/* Ajustes do header */
.page-header h1 {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--ntabs-text-primary);
  margin: 0;
}

.page-header .icon {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s;
  color: var(--ntabs-text-secondary);
}

.page-header .icon:hover {
  background-color: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

/* Ícones de ação */
.action-icon {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  color: var(--ntabs-text-secondary);
  transition: all 0.2s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.action-icon:hover {
  background-color: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

.action-icon.active {
  color: var(--ntabs-text-primary);
  background-color: var(--ntabs-bg-secondary);
}

.action-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Indicadores de estado */
.chat-toggle.active,
.folder-toggle.active {
  color: var(--ntabs-text-primary);
  background-color: var(--ntabs-bg-secondary);
}

/* Chat toggle */
.chat-toggle {
  position: relative;
}

.chat-toggle::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  top: 6px;
  right: 6px;
  display: none;
}

.chat-toggle.has-unread::after {
  display: block;
}

/* Responsividade */
@media (max-width: 768px) {
  .main-content.chat-open {
    margin-right: 0;
  }

  .sidebar-container {
    width: 100%;
    max-width: 280px;
  }

  .chat-sidebar {
    width: 100%;
    max-width: 380px;
  }

  .content {
    padding: 1rem;
  }

  .trix-content,
  trix-editor {
    max-width: 100% !important;
    padding: 1rem !important;
  }

  .trix-editor-container {
    padding: 0 1rem;
  }
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--ntabs-border);
  transition: border-color 0.2s ease;
}

.sidebar-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ntabs-text-primary);
  margin: 0;
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ntabs-text-secondary);
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-close:hover {
  background-color: var(--ntabs-bg-secondary);
  color: var(--ntabs-text-primary);
}

.sidebar-close svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Tags - visibility indicators */
.tag {
  background: var(--ntabs-bg-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--ntabs-text-secondary);
  border: 1px solid var(--ntabs-border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.tag--public {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.tag--private {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.lock-icon {
  color: #3b82f6;
}

.globe-icon {
  color: #10b981;
}


.page-header .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header .menu-toggle {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--ntabs-text-secondary);
}

.page-header .logo {
  font-weight: bold;
  color: var(--ntabs-text-primary);
  text-decoration: none;
}

.page-header .breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow-x: auto;
  font-size: 0.95rem;
}

.breadcrumb-link {
  color: var(--ntabs-text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.breadcrumb-link:hover {
  color: var(--ntabs-text-primary);
}

.breadcrumb-separator {
  color: var(--ntabs-text-secondary);
  opacity: 0.6;
}

.page-header .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-link-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-children {
  padding-left: 16px;
}

/* Share Actions */
.share-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.share-button {
  position: relative;
}

.share-button svg {
  width: 18px;
  height: 18px;
}

.share-button.copied {
  color: #10b981;
}

.share-button .hidden {
  display: none;
}

/* Utility classes */
.hidden {
  display: none !important;
}
