/* Admin Layout Styles */
:root {
  --admin-bg: var(--color-bg);
  --admin-sidebar-bg: var(--color-panel);
  --admin-content-bg: var(--color-bg);
  --admin-border: var(--color-border);
  --admin-sidebar-width: 260px;
}

[data-theme='light'] {
  --admin-bg: #f1f5f9;
  --admin-sidebar-bg: #ffffff;
  --admin-content-bg: #f8fafc;
}

body {
  background-color: var(--admin-bg);
}

.admin-layout {
  display: grid;
  grid-template-columns: var(--admin-sidebar-width) 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background-color: var(--admin-sidebar-bg);
  border-right: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
}

.admin-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.admin-sidebar .brand .brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 16px 8px;
}

.admin-sidebar .brand img {
  width: 36px;
}
.admin-sidebar .brand .name {
  font-weight: 700;
  letter-spacing: 0.2px;
}
.admin-sidebar .brand .sub {
  color: var(--color-muted);
  font-size: 14px;
  display: block;
}

.admin-nav {
  flex-grow: 1;
}

.admin-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--color-muted);
}

.admin-nav a:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--color-text);
}

.admin-nav a.active {
  background: var(--brand-blue);
  color: white;
  font-weight: 600;
}

[data-theme='light'] .admin-nav a {
  color: var(--color-muted);
}

[data-theme='light'] .admin-nav a:hover {
  background-color: #f1f5f9;
  color: var(--color-text);
}

[data-theme='light'] .admin-nav a.active {
  background: var(--brand-blue);
  color: white;
}

.admin-nav a .icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--admin-border);
}

.sidebar-footer .action-btn {
  display: flex;
  width: 100%;
  justify-content: center;
}

.admin-main {
  padding: 32px;
  background-color: var(--admin-content-bg);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.page-header h1 {
  font-size: 28px;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header p {
  color: var(--color-muted);
  margin: 0;
}

.icon-btn {
  background: none;
  border: 1px solid var(--admin-border);
  color: var(--color-muted);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}
.icon-btn .material-icons {
  font-size: 20px;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 1000;
}

.mobile-nav-toggle .hamburger-icon {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text);
  position: relative;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.mobile-nav-toggle .hamburger-icon::before,
.mobile-nav-toggle .hamburger-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-text);
  transition: transform 0.3s ease, top 0.3s ease;
}

.mobile-nav-toggle .hamburger-icon::before {
  top: -8px;
}

.mobile-nav-toggle .hamburger-icon::after {
  top: 8px;
}

.mobile-menu-open .mobile-nav-toggle .hamburger-icon {
  background-color: transparent;
}

.mobile-menu-open .mobile-nav-toggle .hamburger-icon::before {
  transform: rotate(45deg);
  top: 0;
}

.mobile-menu-open .mobile-nav-toggle .hamburger-icon::after {
  transform: rotate(-45deg);
  top: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--admin-border);
    padding: 12px 20px;
    z-index: 999;
  }
  .admin-sidebar-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .admin-sidebar .brand .brand-link {
    padding-bottom: 0;
  }
  .admin-sidebar .brand .sub {
    display: none;
  }
  .mobile-nav-toggle {
    display: block;
  }
  .sidebar-nav-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--admin-sidebar-bg);
    border-bottom: 1px solid var(--admin-border);
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }
  .mobile-menu-open .sidebar-nav-container {
    display: block;
  }
  .admin-nav {
    flex-grow: 0;
    margin-bottom: 20px;
  }
  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .admin-main {
    padding: 20px;
  }
}

.mobile-menu-open .sidebar-nav-container {
  display: block;
}

/* Chapter list in course table */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

/* Editor Page Styles */
.editor-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.version-control,
.main-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  height: calc(100vh - 100px); /* Adjust based on header/footer */
}

/* When sections are hidden, the panel disappears and the editor takes full space */
body.sections-hidden .lab-sections-panel {
  display: none;
}

body.sections-hidden .editor-layout {
  grid-template-columns: 1fr;
}

.lab-sections-panel,
.editor-panel {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}
.lab-sections-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
}
.lab-sections-list li {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-sections-list li:hover {
  background: rgba(255, 255, 255, 0.03);
}
.lab-sections-list li.active {
  background: var(--brand-blue);
  color: white;
}
.editor-panel textarea {
  flex-grow: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  background: #020617; /* Darker background for editor */
  color: #e2e8f0;
  border: 1px solid var(--color-border);
  resize: none; /* Disable manual resize */
}
.editor-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}
.editor-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}
.editor-field label {
  font-weight: 600;
}
.editor-actions {
  margin-top: 16px;
  text-align: right;
}

#selectPrompt {
  text-align: center;
  margin: auto;
  color: var(--color-muted);
}

@media (max-width: 900px) {
  .editor-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .lab-sections-panel {
    max-height: 300px;
  }
}

.lab-sections-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--admin-border);
}

.lab-sections-panel .panel-header h4 {
  margin: 0;
  font-size: 16px;
}

.lab-sections-panel .btn.small {
  padding: 4px 8px;
  font-size: 12px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--admin-border);
  background: var(--admin-sidebar-bg);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  margin-right: 8px;
  border-right: 1px solid var(--admin-border);
}
.toolbar-group:last-child {
  border-right: none;
}

.editor-toolbar button,
.editor-toolbar select {
  background: none;
  border: 1px solid transparent;
  color: var(--color-muted);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  height: 34px;
}

.editor-toolbar button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  border-color: var(--admin-border);
}

.editor-toolbar select {
  padding: 5px;
}

.editor-toolbar .material-icons {
  font-size: 20px;
  vertical-align: middle;
}

.editor-content {
  height: calc(100% - 65px); /* Adjust based on toolbar height */
  overflow-y: auto;
  padding: 20px;
  outline: none;
}

.editor-content[contenteditable='false'] {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Styles for elements inside the editor */
.editor-content h2 {
  font-size: 24px;
  margin: 16px 0;
}
.editor-content h3 {
  font-size: 20px;
  margin: 12px 0;
}
.editor-content p {
  margin: 8px 0;
  line-height: 1.6;
}
.editor-content hr {
  border: none;
  border-top: 1px solid var(--admin-border);
  margin: 24px 0;
}
.editor-content .vertical-spacer {
  height: 24px;
}

/* Note boxes */
.note {
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
  border-left: 4px solid;
}
.note.note-pq {
  /* info */
  background-color: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}
.note.note-note {
  /* primary */
  background-color: rgba(14, 165, 233, 0.1);
  border-color: #0ea5e9;
}
.note.note-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
}
.note.note-task {
  /* danger */
  background-color: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}
.note.note-solution {
  /* success */
  background-color: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
}

/* Modal Styles */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 1001; /* Ensure it's above other content */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background-color: var(--color-panel);
  margin: 10vh auto;
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease-out;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.close-button {
  color: var(--color-muted);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s ease;
  line-height: 1;
}

.close-button:hover,
.close-button:focus {
  color: var(--color-text);
  text-decoration: none;
}

.modal-body {
  overflow-y: auto;
}

.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  color: var(--color-text);
}

.form-group input[type='text'],
.form-group input[type='number'],
.form-group textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-body .btn {
  align-self: flex-start;
  margin-top: 8px;
}
.roi-percentage .value {
  display: block;
  font-size: 40px;
  font-weight: 700;
  color: var(--color-text);
}

/* New Dashboard Styles */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

.dashboard-main-col,
.dashboard-side-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.stat-card {
  /* Now uses .panel styles, so padding is inherited */
}

.stat-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--color-muted);
  font-weight: 500;
}

.stat-number {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.actions-grid.compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions-grid.compact .action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--admin-border);
  transition: all 0.2s ease;
  color: var(--color-text);
}

.actions-grid.compact .action-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--color-muted);
}

.actions-grid.compact .action-card .icon {
  font-size: 24px;
}

.actions-grid.compact .action-card h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.activity-item .icon {
  font-size: 20px;
  background-color: rgba(255, 255, 255, 0.03);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-content p {
  margin: 0 0 4px 0;
  font-weight: 500;
}

.activity-content .activity-time {
  font-size: 14px;
  color: var(--color-muted);
}

.chart-container {
  padding: 20px;
  height: 400px;
  position: relative;
}

.chart-container h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
}

/* Status badge styles for stocks */
.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.status-in-stock {
  background-color: rgba(0, 183, 122, 0.15); /* brand-mint */
  color: #00ef9f;
}

.status-badge.status-low-stock {
  background-color: rgba(249, 115, 22, 0.15); /* orange */
  color: #f97316;
}

.status-badge.status-out-of-stock {
  background-color: rgba(239, 68, 68, 0.15); /* red */
  color: #ef4444;
}

/* Theme Switch Styles */
.sidebar-footer {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.theme-switch-wrapper {
  display: flex;
  align-items: center;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #8ab4f8; /* Light mode background */
  transition: 0.4s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: '';
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #202124; /* Dark mode background */
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.slider .sun {
  left: 6px;
  opacity: 1;
}

.slider .moon {
  right: 6px;
  opacity: 0;
}

input:checked + .slider .sun {
  opacity: 0;
}

input:checked + .slider .moon {
  opacity: 1;
}

/* API & Integration Page Styles */
.integration-link-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
}

.integration-link-wrapper code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  color: var(--color-text);
  word-break: break-all;
}

.panel pre {
  background-color: #020617; /* A dark slate color, matches editor */
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 20px;
  position: relative;
  overflow-x: auto;
  margin-top: 12px;
}

.panel pre code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  color: #e2e8f0; /* Light gray/blue for text, matches editor */
  white-space: pre;
  background: none; /* Override any default background */
  padding: 0; /* Override any default padding */
}

.panel pre .copy-snippet-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--admin-border);
  opacity: 0.6;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.panel pre:hover .copy-snippet-btn {
  opacity: 1;
}

.panel pre .copy-snippet-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Manage Users Page Styles */
.filters {
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
}

.filter-select {
  min-width: 200px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.data-table th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.data-table .actions {
  display: flex;
  gap: 10px;
}

.action-button {
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
  font-size: 14px;
}

.action-button.edit {
  color: #3b82f6; /* Blue */
}

.action-button.edit:hover {
  background-color: rgba(59, 130, 246, 0.1);
}

.action-button.delete {
  color: #ef4444; /* Red */
}

.action-button.delete:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.role-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  margin-right: 6px;
}

.role-badge.admin {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.role-badge.instructor {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.role-badge.student {
  background-color: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  margin-top: 12px;
  align-items: center;
}

.checkbox-group {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-group input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-blue);
}
