/* === Base === */
* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: #334155;
  margin: 0;
}

/* === App Layout === */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 250px;
  min-width: 250px;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
  color: #e0e7ff;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1050;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand i {
  font-size: 1.4rem;
  color: #a5b4fc;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  margin: 2px 10px;
  color: #c7d2fe;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-group-label {
  padding: 16px 20px 6px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #818cf8;
  font-weight: 700;
}

.sidebar-footer {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 260px;
  z-index: 1060;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: left 0.3s ease, background 0.2s ease;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: #4338ca;
}

/* === Main Content === */
.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 28px 36px;
  background: #f1f5f9;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* === Sidebar Collapsed State (Desktop) === */
.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

.sidebar-collapsed .main-content {
  margin-left: 0;
}

.sidebar-collapsed .sidebar-toggle {
  left: 12px;
}

/* === Auth Wrapper (Login Page) === */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 50%, #6366f1 100%);
  padding: 20px;
}

.auth-wrapper .card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 100%;
}

.auth-wrapper h3 {
  color: #312e81;
}

.auth-wrapper .btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border: none;
  padding: 10px;
  font-weight: 600;
}

.auth-wrapper .btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
}

/* === Cards === */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  background: #fff;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* === Dashboard Stat Cards === */
.stat-card {
  border-radius: 16px;
  padding: 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.stat-card-purple {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.stat-card-emerald {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.stat-card-amber {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.stat-card-rose {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
}

.stat-card .stat-icon {
  font-size: 2.5rem;
  opacity: 0.3;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 4px;
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.8rem;
}

.stat-card a:hover {
  color: #fff;
}

/* === Page Headings === */
h2 {
  font-weight: 700;
  color: #1e293b;
  font-size: 1.5rem;
}

h2 i {
  color: #6366f1;
}

/* === Buttons === */
.btn-primary {
  background: #4f46e5;
  border-color: #4f46e5;
}

.btn-primary:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.btn-success {
  background: #10b981;
  border-color: #10b981;
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.btn-warning {
  background: #f59e0b;
  border-color: #f59e0b;
}

.btn-danger {
  background: #ef4444;
  border-color: #ef4444;
}

/* === Question Cards === */
.question-card {
  border-left: 4px solid #6366f1;
  margin-bottom: 10px;
  transition: all 0.2s ease;
  background: #fff;
}

.question-card:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
  border-left-color: #4f46e5;
}

.question-card.selected {
  border-left-color: #10b981;
  background-color: #f0fdf4;
}

/* === Tags === */
.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: #fff;
  margin: 1px 2px;
  font-weight: 500;
}

/* === Usage === */
.usage-badge {
  font-size: 0.75rem;
  color: #64748b;
}

.usage-history {
  font-size: 0.8rem;
  max-height: 150px;
  overflow-y: auto;
}

/* === Options === */
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.option-label {
  font-weight: 600;
  min-width: 30px;
}

.correct-option {
  color: #10b981;
  font-weight: 600;
}

/* === Images === */
.question-image, .option-image {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  margin-top: 4px;
}

.preview-image {
  max-width: 100px;
  max-height: 80px;
  border-radius: 6px;
}

/* === Filter Section === */
.filter-section {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
}

/* === Builder Panels === */
.builder-left {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.builder-right {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e2e8f0;
}

/* === Drag & Drop === */
.drag-handle {
  cursor: grab;
  color: #94a3b8;
}

.sortable-ghost {
  opacity: 0.4;
  background: #e0e7ff;
}

.sortable-chosen {
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.selected-q-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}

.selected-q-item .drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-size: 1.1rem;
}

.selected-q-item:hover {
  background: #f8fafc;
}

/* === Folder Sidebar === */
.folder-sidebar {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.folder-item:hover {
  background: #f1f5f9;
}

.folder-item.active {
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  font-weight: 600;
  color: #4338ca;
}

/* === Question Grid (2-column layout) === */
.question-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.question-card-compact {
  font-size: 0.85rem;
}

.question-card-compact .preview-image {
  max-width: 80px;
  max-height: 60px;
}

/* === Tables === */
.table {
  font-size: 0.875rem;
}

.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  color: #475569;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tbody tr:hover {
  background: #f8fafc;
}

/* === Badges === */
.badge.bg-info {
  background-color: #6366f1 !important;
}

.badge.bg-secondary {
  background-color: #64748b !important;
}

/* === Quick Actions === */
.quick-action-card {
  border-radius: 12px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e2e8f0;
}

.quick-action-card .btn {
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 500;
}

/* === Modals === */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
  border-bottom: 1px solid #f1f5f9;
  padding: 16px 20px;
}

.modal-title {
  font-weight: 600;
  color: #1e293b;
}

.modal-footer {
  border-top: 1px solid #f1f5f9;
}

/* === Forms === */
.form-control:focus, .form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* === Alerts === */
.alert-info {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

/* === Pagination === */
.page-link {
  color: #4f46e5;
  border-radius: 8px;
  margin: 0 2px;
}

.page-item.active .page-link {
  background: #4f46e5;
  border-color: #4f46e5;
}

/* === Stats Number (legacy) === */
.stats-number {
  font-size: 2rem;
  font-weight: 700;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 60px;
  }

  .sidebar-toggle {
    left: 12px;
    top: 12px;
  }

  .question-grid {
    grid-template-columns: 1fr;
  }

  /* On mobile, collapsed class doesn't apply - use open class instead */
  .sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

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

/* === Scrollbar Styling === */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* === Code blocks === */
code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #6366f1;
}
