/* Layout & Container Styles */

/* Ensure full viewport height */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  scroll-padding-top: 80px; /* Accounts for sticky header when using anchor links */
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: auto; /* Allow growing beyond viewport when content is long */
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease;
  padding-bottom: 0; /* Ensure no extra padding */
}

p {
  color: rgb(var(--color-text-primary));
}

span {
  color: rgb(var(--color-text-primary));
}

/* Content containers with layout containment */
.content-container {
  max-width: var(--max-content-width);
  margin-left: auto; 
  margin-right: auto;
  padding-left: var(--space); 
  padding-right: var(--space);
  padding-top: calc(var(--space) * 2); 
  padding-bottom: calc(var(--space) * 2);
  contain: layout style;
  min-height: 60vh; /* Prevent layout shift */
  background: var(--surface);
  transition: background-color 0.3s ease;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* Mobile responsive adjustments for content containers */
@media (max-width: 768px) {
  .content-container {
    width: 95%;
    max-width: none;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    margin: 0.5rem auto;
  }
}

@media (max-width: 480px) {
  .content-container {
    width: 98%;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin: 0.25rem auto;
  }
}

/* Special styling for different content types */
.card-content-section[data-type="summary"] {
  border-color: rgb(var(--color-primary-lighter));
    border-color: rgb(var(--color-primary-dark));
  background: linear-gradient(135deg, rgb(239 246 255 / 0.5), rgb(var(--color-bg-primary)));
}

.card-content-section[data-type="summary"] .card-content-section-title {
  background-color: rgb(var(--color-bg-accent));
    background-color: rgba(var(--color-primary), 0.3);
    border-color: rgb(var(--color-primary-lighter));
    border-color: rgb(var(--color-primary-dark));
}

.card-content-section[data-type="headnotes"] {
  border-color: rgb(var(--color-success-light));
    border-color: rgb(var(--color-success-dark));
  background: linear-gradient(135deg, rgb(240 253 244 / 0.5), rgb(var(--color-bg-primary)));
}

.card-content-section[data-type="headnotes"] .card-content-section-title {
  background-color: rgb(var(--color-success-light));
    background-color: rgba(var(--color-success), 0.3);
    border-color: rgb(var(--color-success-light));
    border-color: rgb(var(--color-success-dark));
}

.card-content-section[data-type="keywords"] {
  border-color: rgb(250 245 255);
    border-color: rgb(147 51 234);
  background: linear-gradient(135deg, rgb(250 245 255 / 0.5), rgb(var(--color-bg-primary)));
}


  /* Main layout patterns */
  .main-container {
    flex: 1 1 0%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex item to shrink */
    background-color: rgb(var(--color-bg-primary));
    transition: background-color 0.3s ease;
    flex-grow: 1; /* Ensure it grows to fill available space */
    flex-shrink: 0; /* Don't shrink the main container */
  }
  /* Main content area should expand to fill available space */
  .main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: var(--max-content-width);
    width: 100%;
    margin: 1rem auto;
    transition: background-color 0.3s ease, color 0.3s ease;
  }

  /* Mobile-first responsive adjustments for main content area */
  @media (max-width: 768px) {
    .main-content-area {
      width: 95%; /* Take 95% of screen width on mobile */
      max-width: none; /* Remove max-width constraint on mobile */
      margin: 0.5rem auto;
      padding: 0.75rem; /* Reduced padding for mobile */
    }
  }

  @media (max-width: 480px) {
    .main-content-area {
      width: 98%; /* Take 98% on very small screens */
      margin: 0.25rem auto;
      padding: 0.5rem; /* Minimal padding for very small screens */
    }
  }


  .main-content-area .section-hero {
    text-align: center;
    margin-bottom: 3rem;
  }

  .main-content-area .section-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
  }

  .main-content-area .section-subtitle {
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
  }



  /* Ensure section hero maintains its styling even when dynamically loaded */
  .page-container .section-hero {
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    margin-bottom: 0.5rem;
    text-align: center;
  }

  /* Ensure section titles maintain their styling even when dynamically loaded */
  .page-container .section-title,
  .page-container h1.section-title {
    font-size: 2.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: rgb(var(--color-text-primary));
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    font-size: 2.25rem;
    text-align: center;
    font-weight: 500 !important;
  }

.editor-tabs {
  display: flex;
    border-bottom: 1px solid rgb(var(--color-border));
    border-color: rgb(var(--color-border-light));
    border-color: rgb(var(--color-border));
}

.tab-button {
  padding-left: 1rem; padding-right: 1rem;
    padding-top: 0.5rem; padding-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(var(--color-text-secondary));
    color: rgb(var(--color-text-muted));
    color: rgb(var(--color-text-primary));
    color: rgb(var(--color-text-secondary));
    border-bottom: 2px solid rgb(var(--color-border));
    border-color: transparent;
    /* Unknown: hover:border-gray-300 */;
    border-color: rgb(var(--color-border));
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms;
}

.tab-button.active {
  color: rgb(var(--color-primary));
    color: rgb(var(--color-primary-light));
    border-color: rgb(var(--color-primary));
    border-color: rgb(var(--color-primary-light));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}


.editor-toolbar {
  display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgb(var(--color-bg-muted));
    background-color: rgb(var(--color-bg-tertiary));
    border-top: 1px solid rgb(var(--color-border));
    border-color: rgb(var(--color-border-light));
    border-color: rgb(var(--color-border));
}

.toolbar-btn {
  padding-left: 0.5rem; padding-right: 0.5rem;
    padding-top: 0.25rem; padding-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgb(var(--color-text-secondary));
    color: rgb(var(--color-text-muted));
    color: rgb(var(--color-text-primary));
    color: rgb(var(--color-text-secondary));
    background-color: rgb(var(--color-bg-quaternary));
    background-color: rgb(var(--color-bg-quaternary));
    border-radius: 0.25rem;
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms;
}

@media (max-width: 768px) {
  .editor-toolbar {
    flex-wrap: wrap;
  }
  
  .toolbar-btn {
    font-size: 0.75rem;
    /* Unknown: px-1 */;
    padding-top: 0.25rem; padding-bottom: 0.25rem;
  }
}

/* Feature container styling for all sections */
.section-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 1rem;
  background-color: rgb(var(--color-bg-primary));
  transition: background-color 0.3s ease;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.section-container > * {
  flex: 1 1 0;
  min-width: 0;
  padding: 1rem;
}

.section-container-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: rgb(var(--color-text-primary));
}

  .section-content {
    padding-top: 0.5rem; padding-bottom: 0.5rem;
    width: 100%;
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
    display: block;
  }

/* Mobile-first approach for section content */
@media (max-width: 640px) {
  .section-content {
    width: 95%;
    max-width: none;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

@media (min-width: 640px) {
  .section-content {
    width: 100%;
    max-width: var(--max-content-width);
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .section-content {
    width: 100%;
    max-width: var(--max-content-width);
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Interface container - general container for interface components */
.page-container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto; 
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Judgments search interface - add vertical spacing between components */
.page-container > div {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  
}


/* ==========================================================================
   ROLE-BASED VISIBILITY
   ========================================================================== */

/* 
 * Role-based visibility system:
 * 
 * 1. Add role-specific classes to elements you want to hide from users without that role
 * 2. Elements are hidden by default (display: none)
 * 3. When a user has a specific role, the 'data-role="rolename"' attribute is set on the body
 * 4. This makes all role-specific elements visible to users with that role
 * 
 * Usage examples:
 * <button class="admin-only btn-symbol">Admin Button</button>
 * <div class="moderator-only">Moderator Content</div>
 * <span class="editor-only inline">Editor Text</span>
 */

/* Hide role-specific elements by default */
.admin-only,
.moderator-only,
.editor-only {
  display: none !important;
}

/* Show admin-only elements when user is admin */
body[data-role="admin"] .admin-only {
  display: revert !important;
}

/* Show moderator-only elements when user is moderator */
body[data-role="moderator"] .moderator-only {
  display: revert !important;
}

/* Show editor-only elements when user is editor */
body[data-role="editor"] .editor-only {
  display: revert !important;
}

/* ==========================================================================
   SKELETON LOADING STATES
   ========================================================================== */

/* Base skeleton animation */
.skel {
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
}

@keyframes sk {
  to { background-position: 240px 0; }
}

/* Skeleton line - for text content */
.skel-line {
  height: 1em;
  border-radius: 8px;
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
}

/* Skeleton row - for table rows and list items */
.skel-row {
  height: 2.4rem;
  border-radius: 8px;
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
}

/* Skeleton card - for card layouts */
.skel-card {
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* Skeleton button */
.skel-btn {
  height: 2.5rem;
  width: 6rem;
  border-radius: 6px;
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
}

/* Skeleton avatar/circle */
.skel-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
}

/* Skeleton table */
.skel-table {
  width: 100%;
  border-collapse: collapse;
}

.skel-table .skel-row {
  height: 3rem;
  margin-bottom: 0.5rem;
}

/* Skeleton list */
.skel-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skel-list .skel-row {
  height: 2.5rem;
}

/* Skeleton grid */
.skel-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Specific skeleton components for different content types */

/* Law card skeleton */
.skel-laws-card {
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
}

.skel-laws-card .skel-line {
  margin-bottom: 0.75rem;
}

.skel-laws-card .skel-line:first-child {
  width: 60%;
  height: 1.25em;
}

.skel-laws-card .skel-line:nth-child(2) {
  width: 40%;
  height: 1em;
}

.skel-laws-card .skel-line:nth-child(3) {
  width: 100%;
  height: 0.875em;
}

.skel-laws-card .skel-line:nth-child(4) {
  width: 85%;
  height: 0.875em;
}

/* Post card skeleton */
.skel-post-card {
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
}

.skel-post-card .skel-line {
  margin-bottom: 0.75rem;
}

.skel-post-card .skel-line:first-child {
  width: 70%;
  height: 1.5em;
}

.skel-post-card .skel-line:nth-child(2) {
  width: 50%;
  height: 1em;
}

.skel-post-card .skel-line:nth-child(3) {
  width: 100%;
  height: 0.875em;
}

.skel-post-card .skel-line:nth-child(4) {
  width: 90%;
  height: 0.875em;
}

.skel-post-card .skel-line:nth-child(5) {
  width: 75%;
  height: 0.875em;
}

/* Tag skeleton */
.skel-tag {
  display: inline-block;
  height: 1.75rem;
  width: 4rem;
  border-radius: 9999px;
  background: linear-gradient(90deg, #0000 30%, #0002 45%, #0000 60%) var(--surface);
  background-size: 240px 100%;
  animation: sk 1.2s linear infinite;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Search results skeleton */
.skel-search-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skel-search-results .skel-laws-card {
  margin-bottom: 0;
}

/* Loading state transitions */
.skeleton-loading {
  opacity: 0.7;
  pointer-events: none;
}

.skeleton-loaded {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

/* Responsive skeleton adjustments */
@media (max-width: 768px) {
  .skel-grid {
    grid-template-columns: 1fr;
  }
  
  .skel-laws-card,
  .skel-post-card {
    padding: 1rem;
  }
}