/* ==========================================
   Dashboard Layout & Styles
   ========================================== */
.dashboard-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  background-color: var(--bg-secondary);
}

@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
}

/* Sidebar Styling */
.dashboard-sidebar {
  width: 260px;
  background-color: var(--bg-primary);
  border-inline-end: 1px solid var(--border-color);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .dashboard-sidebar {
    width: 100%;
    padding: 1rem;
    flex-direction: row;
    overflow-x: auto;
    gap: 1rem;
  }
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

@media (max-width: 768px) {
  .sidebar-user {
    border-bottom: none;
    padding-bottom: 0;
    flex-shrink: 0;
  }
}

.sidebar-user-avatar {
  width: 45px;
  height: 45px;
  border-radius: var(--radius-full);
  background-color: var(--accent-color);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.sidebar-user-info h4 {
  font-size: 0.95rem;
  margin-bottom: 0;
}

.sidebar-user-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .sidebar-menu {
    flex-direction: row;
    gap: 0.5rem;
  }
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.sidebar-link i {
  font-size: 1.1rem;
}

.sidebar-link:hover, .sidebar-link.active {
  color: var(--primary-color);
  background-color: var(--accent-color);
}

/* Dashboard Content Area */
.dashboard-content {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .dashboard-content {
    padding: 1rem;
  }
}

.dashboard-section {
  display: none;
}

.dashboard-section.active {
  display: block;
  animation: fadeIn 0.4s ease-in-out;
}

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

/* Dashboard Cards & stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.stat-card-info h3 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.stat-card-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-card-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-color);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
}

.data-table th, .data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-dark);
  font-weight: 700;
}

.data-table tbody tr:hover {
  background-color: var(--bg-secondary);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-info { background-color: var(--accent-color); color: var(--primary-color); }

/* Forms & UI Controls in Dashboard */
.db-form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 576px) {
  .db-form-row {
    grid-template-columns: 1fr;
  }
}

.db-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.db-form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.db-form-group input, 
.db-form-group select, 
.db-form-group textarea {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  background-color: var(--bg-primary);
  transition: var(--transition-fast);
}

.db-form-group input:focus, 
.db-form-group select:focus, 
.db-form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(32, 115, 152, 0.1);
}

/* AI Article Generator UI Box */
.ai-generator-box {
  background: linear-gradient(135deg, var(--accent-color) 0%, #FFFFFF 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.ai-generator-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.ai-generator-title i {
  font-size: 1.25rem;
}

/* My Courses Grid (For student dashboard) */
.student-courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.student-course-card {
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition-normal);
}

.student-course-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.course-card-banner {
  height: 160px;
  background-color: var(--accent-color);
  position: relative;
}

.course-card-banner img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
}

.course-card-status {
  position: absolute;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
}

.course-card-body {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.course-card-body h4 {
  font-size: 1.1rem;
  margin-bottom: 0;
}

.course-card-body p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  flex-grow: 1;
}

.course-card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Modals */
.db-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.db-modal.active {
  display: flex;
}

.db-modal-content {
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideUp 0.3s ease-out;
}

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

.db-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.db-modal-header h3 {
  margin-bottom: 0;
}

.db-modal-body {
  padding: 1.5rem;
}

.db-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Custom Rich Text & Code Editor */
.rich-editor-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  min-height: 250px;
  margin-top: 0.25rem;
}

.rich-editor-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(32, 115, 152, 0.1);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.editor-toolbar button {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  transition: var(--transition-fast);
}

.editor-toolbar button:hover {
  background-color: var(--accent-hover);
  color: var(--primary-color);
}

.editor-toolbar button.active {
  background-color: var(--primary-color);
  color: #fff;
}

.editor-body-wrapper {
  position: relative;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.editor-visual-body {
  padding: 1rem;
  min-height: 180px;
  max-height: 400px;
  flex-grow: 1;
  overflow-y: auto;
  outline: none;
  font-size: 0.95rem;
  line-height: 1.7;
}

.editor-code-body {
  width: 100%;
  min-height: 180px;
  max-height: 400px;
  flex-grow: 1;
  padding: 1rem;
  border: none;
  outline: none;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  background-color: #f8fafc;
  color: #0f172a;
}

