:root {
  --primary: #0f172a;
  --primary-rgb: 15, 23, 42;
  --primary-light: #1e293b;
  --accent: #3b82f6;
  --accent-rgb: 59, 130, 246;
  --accent-hover: #2563eb;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #1e293b;
  --sidebar-text: #f8fafc;
  --sidebar-hover: #334155;
  --sidebar-active: #3b82f6;
  --header-height: 70px;
  --sidebar-width: 320px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --highlight: #fef08a;
}

body.dark-theme {
  --bg: #020617;
  --card-bg: #0f172a;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --highlight: #854d0e;
  --primary-rgb: 15, 23, 42;
  --accent-rgb: 59, 130, 246;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

header {
  height: var(--header-height);
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}

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

.back-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
}

.back-link:hover {
  color: white;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-container {
  flex: 1;
  max-width: 500px;
  position: relative;
  margin: 0 20px;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

#search {
  width: 100%;
  padding: 10px 15px 10px 45px;
  border-radius: 9999px;
  border: 1px solid #334155;
  background-color: #1e293b;
  color: white;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.switch-buttons {
  display: flex;
  background-color: #1e293b;
  padding: 4px;
  border-radius: 8px;
}

.switch-buttons button {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.switch-buttons button.active {
  background-color: var(--accent);
  color: white;
}

#theme-toggle {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px;
  transition: color 0.2s;
}

#theme-toggle:hover {
  color: white;
}

.app-container {
  display: flex;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

aside {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  transition: transform 0.3s ease;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #334155;
}

.sidebar-header h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

.nav-links {
  padding: 15px 0;
}

.nav-cap {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: background-color 0.2s;
  color: #cbd5e1;
  border-left: 3px solid transparent;
}

.nav-cap:hover {
  background-color: var(--sidebar-hover);
  color: white;
}

.nav-cap.active {
  background-color: #0f172a;
  color: var(--accent);
  border-left-color: var(--accent);
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  scroll-behavior: smooth;
}

#active-source-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 30px;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

.cap-section {
  margin-bottom: 60px;
}

.cap-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  margin-bottom: 30px;
  padding: 15px 20px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--shadow);
}

.cap-nr {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.cap-name {
  font-size: 1.3rem;
}

.sect-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin: 40px 0 20px 0;
  padding: 12px 18px;
  background: rgba(var(--accent-rgb), 0.05);
  border-left: 5px solid var(--accent);
  border-radius: 0 10px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sect-nr {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.sect-name {
  color: var(--primary);
  opacity: 0.9;
}

.articol-card {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.articol-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.art-nr {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: block;
}

.art-text {
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 15px;
  line-height: 1.6;
}

.alineat {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-left: 20px;
  margin-bottom: 8px;
  position: relative;
  line-height: 1.6;
}

.art-text a, .alineat a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dashed var(--accent);
  transition: all 0.2s;
}

.art-text a:hover, .alineat a:hover {
  background-color: var(--highlight);
  border-bottom-style: solid;
}

.alineat::before {
  content: "•";
  position: absolute;
  left: -15px;
  color: var(--accent);
}

.abrogat {
  font-style: italic;
  text-decoration: line-through;
  opacity: 0.7;
}

.art-actions {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

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

.highlight {
  background-color: var(--highlight);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* Accordion Styles */
.articol-card {
  cursor: pointer;
  overflow: hidden;
}

.art-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0;
  transition: margin-bottom 0.3s;
}

.articol-card.expanded .art-header {
  margin-bottom: 15px;
}

.art-nr-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-icon {
  color: var(--accent);
  transition: transform 0.3s ease;
  font-size: 0.9rem;
}

.articol-card.expanded .toggle-icon {
  transform: rotate(180deg);
}

.summary-trigger {
  background: var(--primary);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, background-color 0.2s;
}

.summary-trigger:hover {
  transform: scale(1.1);
  background-color: var(--accent);
}

.art-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 0.3s;
}

.articol-card.expanded .art-body {
  max-height: 2000px; /* Large enough to fit content */
  opacity: 1;
  transition: max-height 0.4s ease-in, opacity 0.3s;
}

/* Repealed Text styling */
.abrogat {
  font-style: italic;
  text-decoration: line-through;
  opacity: 0.6;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: var(--card-bg);
  width: 100%;
  max-width: 600px;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--primary);
  color: white;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.close-modal {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 25px;
  max-height: 60vh;
  overflow-y: auto;
}

#modal-summary-text {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
}

.modal-full-text-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  text-align: center;
}

.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.primary-btn {
  background-color: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

#mobile-menu-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 2000;
  cursor: pointer;
}

#mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 900;
}

@media (max-width: 1024px) {
  aside {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 1100;
    transform: translateX(-100%);
  }

  aside.open {
    transform: translateX(0);
  }

  main {
    padding: 20px;
  }

  #mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #mobile-overlay.open {
    display: block;
  }

  header {
    padding: 0 10px;
  }

  .header-left h1 span {
    display: none;
  }

  .search-container {
    margin: 0 10px;
  }
}

@media (max-width: 640px) {
  .controls .switch-buttons button {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  header h1 {
    font-size: 1rem;
  }

  .back-link span {
    display: none;
  }
}
