/* IDEA Regulations Library Styles */

/* Root Variables */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f2f5;
  --text-primary: #000000;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border-color: #e9ecef;
  --accent: #000000;
  --accent-hover: #1a1a1a;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark {
  --bg-primary: #000000;
  --bg-secondary: #0f0f0f;
  --bg-tertiary: #141414;
  --text-primary: #ffffff;
  --text-secondary: #a8a8a8;
  --text-muted: #6c6c6c;
  --border-color: #2a2a2a;
  --accent: #ffffff;
  --accent-hover: #e6e6e6;
  --card-shadow: 0 1px 3px rgba(255, 255, 255, 0.05);
  --card-shadow-hover: 0 4px 12px rgba(255, 255, 255, 0.08);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.2s ease;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - 64px);
  padding: 2rem 0;
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.content-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

/* Locked Overlay */
.locked-overlay {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.locked-content {
  background-color: var(--bg-primary);
  border-radius: 20px;
  padding: 3rem 2rem;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.locked-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.locked-icon svg {
  width: 32px;
  height: 32px;
  color: #ffffff;
}

.locked-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.locked-description {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.locked-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background-color: var(--accent);
  color: var(--bg-primary);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
}

.locked-btn:hover {
  background-color: var(--accent-hover);
}

.locked-btn svg {
  width: 18px;
  height: 18px;
}

/* Page Header */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
  line-height: 1;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Search Section */
.search-section {
  margin-bottom: 2rem;
}

.search-box {
  position: relative;
  max-width: 600px;
}

.search-box svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.9375rem;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.dark .search-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Error State */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.error-state svg {
  width: 64px;
  height: 64px;
  color: #dc3545;
  margin-bottom: 1.5rem;
  opacity: 0.7;
}

.error-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.error-state p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

/* Regulations Tree */
.regulations-tree {
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Subpart */
.subpart {
  border-bottom: 1px solid var(--border-color);
}

.subpart:last-child {
  border-bottom: none;
}

.subpart-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--bg-primary);
}

.subpart-header:hover {
  background-color: var(--bg-secondary);
}

.subpart-toggle {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.subpart-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.subpart.expanded .subpart-toggle svg {
  transform: rotate(90deg);
}

.subpart-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.subpart-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subpart-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.subpart-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 0.5rem;
  background-color: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Sections List */
.sections-list {
  display: none;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.subpart.expanded .sections-list {
  display: block;
}

/* Section Item */
.section-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem 1rem 4rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.section-item:last-child {
  border-bottom: none;
}

.section-item:hover {
  background-color: var(--bg-tertiary);
  padding-left: 4.25rem;
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 32px;
  padding: 0 0.625rem;
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.section-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.section-excerpt {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.5;
}

.section-arrow {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background-color: var(--bg-primary);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s ease;
  overflow: hidden;
  box-sizing: border-box;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modalSlideUpMobile {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  flex-shrink: 0;
}

.modal-header > div {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.breadcrumbs-section {
  padding: 0.75rem 2rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-separator svg {
  width: 14px;
  height: 14px;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.modal-search-section {
  padding: 1rem 2rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-search-box {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 100%;
}

.modal-search-box svg {
  position: absolute;
  left: 0.75rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.modal-search-input {
  flex: 1;
  padding: 0.625rem 2.5rem 0.625rem 2.5rem;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-search-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--bg-primary);
}

.modal-search-clear {
  position: absolute;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border: none;
  background-color: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.modal-search-clear:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-search-clear svg {
  width: 14px;
  height: 14px;
  position: static;
}

.modal-search-results {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.search-count {
  font-weight: 500;
}

.search-nav-buttons {
  display: flex;
  gap: 0.25rem;
}

.search-nav-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.search-nav-btn:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.search-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.search-nav-btn svg {
  width: 14px;
  height: 14px;
}

.highlight-match {
  background-color: #ffd700;
  color: #000000;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 500;
}

.dark .highlight-match {
  background-color: #ffeb3b;
  color: #000000;
}

.highlight-current {
  background-color: #ff6b35;
  color: #ffffff;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
}

.dark .highlight-current {
  background-color: #ff6b35;
  color: #ffffff;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background-color: var(--bg-tertiary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  width: 100%;
  box-sizing: border-box;
}

/* Section Detail Content */
.section-detail {
  line-height: 1.8;
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.copy-citation-btn {
  width: 32px;
  height: 32px;
  border: none;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.copy-citation-btn:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.copy-citation-btn svg {
  width: 16px;
  height: 16px;
}

.section-detail-body {
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.7;
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.section-detail-body p {
  margin-bottom: 1rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.section-detail-body p:hover {
  background-color: #ffefbb;
}

.dark .section-detail-body p:hover {
  background-color: rgba(255, 235, 59, 0.15);
}

.section-detail-body p:last-child {
  margin-bottom: 0;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.external-link:hover {
  text-decoration: underline;
}

.external-link svg {
  width: 16px;
  height: 16px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* Responsive */
@media (max-width: 768px) {
  .content-container {
    padding: 0 1rem;
    max-width: 100%;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .subpart-header {
    padding: 1rem;
    overflow: hidden;
  }

  .section-item {
    padding: 0.875rem 1rem 0.875rem 3rem;
    overflow: hidden;
  }

  .section-item:hover {
    padding-left: 3.25rem;
  }

  .section-number {
    min-width: 44px;
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }

  .section-title {
    font-size: 0.875rem;
  }

  .section-excerpt {
    font-size: 0.75rem;
  }

  .subpart-title {
    font-size: 0.9375rem;
  }

  /* Mobile Modal - Bottom Sheet Style */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-height: 80vh;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    animation: modalSlideUpMobile 0.3s ease;
    height: 92vh;
  }

  .modal-header {
    padding: 1rem 1rem 1rem 1.25rem;
    position: relative;
  }

  .modal-header::before {
    content: '';
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
  }

  .modal-header > div {
    padding-top: 0.75rem;
  }

  .modal-title {
    font-size: 1.125rem;
    line-height: 1.3;
    -webkit-line-clamp: 3;
  }

  .modal-subtitle {
    font-size: 0.8125rem;
    white-space: normal;
    overflow: visible;
  }

  .breadcrumbs-section {
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
  }

  .modal-search-section {
    padding: 0.75rem 1rem;
  }

  .modal-search-input {
    font-size: 0.8125rem;
    padding: 0.5rem 2.25rem 0.5rem 2.25rem;
  }

  .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
  }

  .section-detail-body {
    font-size: 0.875rem;
  }

  .section-detail-body p {
    padding: 0.375rem;
    margin-bottom: 0.75rem;
  }
}
