:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --page: #f6f7fb;
  --card-bg: #ffffff;
  --radius: 16px;
  --transition: 0.25s ease;
}

/* Reset & base */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100svh;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--page);
  display: grid;
  place-items: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Card (Login) ---------- */
.card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 36px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
  text-align: center;
  animation: fade-in 0.45s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo { font-size: 2rem; font-weight: 700; margin-bottom: 8px; color: var(--primary); }
.subtitle { font-size: 0.95rem; color: #6b7280; margin-bottom: 24px; }

/* ---------- Form ---------- */
.field { position: relative; margin-bottom: 14px; }
.field input {
  width: 100%; padding: 14px 44px 14px 14px;
  border: 1px solid #e5e7eb; border-radius: 12px;
  background: #f9fafb; font-size: 0.95rem; outline: none;
  transition: all var(--transition);
}
.field input:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}
.toggle-password {
  position: absolute; top: 50%; right: 12px;
  transform: translateY(-50%); border: none; background: none;
  cursor: pointer; font-size: 1rem; color: #9ca3af;
  padding: 2px 6px; border-radius: 8px;
}
.toggle-password:hover { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  width: 100%; padding: 14px; margin-top: 6px;
  font-size: 1rem; font-weight: 700; color: #fff;
  background: var(--primary); border: none; border-radius: 12px;
  cursor: pointer; transition: background var(--transition), transform 0.05s ease;
}
.btn:hover, .btn:focus-visible { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

#message { margin-top: 14px; font-size: 0.93rem; font-weight: 500; min-height: 1.2em; }
.error { color: #d52731; } .success { color: #269f53; }

/* ---------- MAIN PAGE STYLES ---------- */
#mainPage {
  width: 100%; height: 100vh;
  display: flex; flex-direction: column;
  animation: fade-in 0.3s ease;
}

.main-header {
  height: 70px; background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: 0 32px; display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 1.25rem; font-weight: 700; color: var(--primary); }

.logout-btn-main {
  background: transparent; color: #ef4444; border: 1px solid #fee2e2;
  padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px;
}
.logout-btn-main:hover { background: #fee2e2; }

.content-wrapper {
  flex: 1; 
  display: flex; 
  flex-direction: column; /* Stack content vertically */
  align-items: center;    /* Center the list horizontally */
  justify-content: flex-start; /* Start from the top */
  overflow-y: auto;       /* Enable scrolling for long lists */
  padding: 20px;
  width: 100%;
}

.empty-state { text-align: center; color: #6b7280; }
.empty-icon { font-size: 3rem; color: #d1d5db; margin-bottom: 16px; }
.empty-state h3 { color: #1f2937; margin: 0 0 8px 0; }
.btn-create {
  /* Fixed position for bottom left */
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 100;
  
  padding: 14px 28px; font-size: 1rem;
  background: var(--primary); color: #fff; border: none; border-radius: 50px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25); transition: all 0.2s;
}

/* Add style for the task list grid */
.tasks-grid {
  display: grid;
  grid-template-columns: 1fr; /* Force exactly one column */
  gap: 20px;
  width: 100%;
  max-width: 800px; /* Set a nice readable width for the cards */
  padding-bottom: 80px; 
}

.task-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative; /* REQUIRED for positioning icons */
}

/* --- NEW ICON STYLES --- */
.task-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: none; /* Hidden by default */
  gap: 8px;
  z-index: 10;
}

.task-card:hover .task-actions {
  display: flex; /* Show on hover */
  animation: fade-in 0.2s ease;
}

.action-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

/* Blue Edit Button */
.edit-btn { background: #eff6ff; color: #1d4ed8; }
.edit-btn:hover { background: #bfdbfe; }

/* Red Trash Button */
.delete-btn { background: #fef2f2; color: #ef4444; }
.delete-btn:hover { background: #fecaca; }

.task-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  
  /* NEW: Limit height and enable scrolling */
  max-height: 60px;       /* Adjust this number to make it taller/shorter */
  overflow-y: auto;       /* Adds scrollbar if content is too tall */
  
  /* NEW: Push to bottom and add visual separation */
  margin-top: auto;       
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.level-tag {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.task-topic {
  font-size: 1rem;
  color: #374151;
  line-height: 1.5;
}
.btn-create:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ---------- EDITOR MODAL STYLES ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.5); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in 0.2s ease; z-index: 999;
}

.editor-card {
  width: 95vw;
  max-width: 1300px;
  height: 85vh; 
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 25px 50px rgba(16, 24, 40, 0.25);
  padding: 32px; 
  display: flex; flex-direction: column;
}

.editor-header {
  display: flex; justify-content: space-between; align-items: center; 
  margin-bottom: 20px; flex-shrink: 0;
}
.editor-header h3 { margin: 0; color: #111827; font-size: 1.5rem; }

.close-icon-btn {
  background: #f3f4f6; color: #6b7280; border: none;
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center;
  font-size: 1.1rem; transition: all 0.2s;
}
.close-icon-btn:hover { background: #fee2e2; color: #ef4444; transform: rotate(90deg); }

/* Upper Section: Checkbox Area */
.options-header { 
  display: flex; justify-content: space-between; align-items: center; 
  margin-bottom: 8px; flex-shrink: 0; 
}
.header-left { display: flex; align-items: center; gap: 8px; }
.section-label { font-size: 0.85rem; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: 0.5px; }

.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #e5e7eb; color: #4b5563; font-size: 0.75rem; font-weight: 700;
  height: 20px; min-width: 20px; padding: 0 6px; border-radius: 12px;
  transition: all 0.2s ease;
}

.select-all-wrapper {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; color: var(--primary);
  user-select: none; transition: color 0.2s;
}
.select-all-wrapper:hover { color: var(--primary-dark); }

.checkbox-container-scroll {
  border: 1px solid #f3f4f6; background: #fff; border-radius: 12px;
  padding: 12px; 
  max-height: 250px; min-height: 150px;
  overflow-y: auto; margin-bottom: 20px; flex-shrink: 0;
}
.checkbox-container-scroll::-webkit-scrollbar { width: 6px; }
.checkbox-container-scroll::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 10px; }

/* --- OPTIMIZED GRID LAYOUT (4 Columns Base) --- */
#classOptionsContainer {
  display: grid;
  grid-template-columns: repeat(12, 1fr); /* 12 Columns for flexibility */
  gap: 8px; /* CHANGED: Reduced gap for tighter layout */
  align-content: start;
  grid-auto-flow: dense; 
}
.group-wrapper {
  display: flex;
  align-items: stretch; 
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden; 
  background: #fff;
  transition: border-color 0.2s;
  height: 100%; 
}
.group-wrapper:hover { border-color: #d1d5db; }

/* --- SPANNING LOGIC --- */
/* Default (Small/Short items) -> Span 1 column (25% width) */
/* --- SPANNING LOGIC (12-column grid) --- */
/* 4 per row = span 3 columns (3 x 4 = 12) */
.group-wrapper.span-3 {
  grid-column: span 3;
}

/* 3 per row = span 4 columns (4 x 3 = 12) */
.group-wrapper.span-4 {
  grid-column: span 4;
}

/* 2 per row = span 6 columns (6 x 2 = 12) */
.group-wrapper.span-6 {
  grid-column: span 6;
}

/* 1 per row = span 12 columns (full width) */
.group-wrapper.span-12 {
  grid-column: span 12;
}

/* --- RESPONSIVE ADJUSTMENTS --- */

/* Tablet/Laptop: Switch to 6-column base */
@media (max-width: 1100px) {
  #classOptionsContainer {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .group-wrapper.span-3 { grid-column: span 3; }
  .group-wrapper.span-4,
  .group-wrapper.span-6,
  .group-wrapper.span-12 { 
    grid-column: span 6; /* Full width on tablet */
  }
}

/* Mobile: Switch to 1-column base */
@media (max-width: 600px) {
  #classOptionsContainer {
    grid-template-columns: 1fr;
  }
  
  .group-wrapper.span-3,
  .group-wrapper.span-4,
  .group-wrapper.span-6,
  .group-wrapper.span-12 {
    grid-column: span 1;
  }
}


/* Left Side: Title */
.group-title {
  flex: 0 0 75px; /* CHANGED: Smaller width */
  background: #f3f4f6;
  color: #374151;
  font-size: 0.7rem; /* CHANGED: Smaller font */
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px; /* CHANGED: Reduced padding */
  border-right: 1px solid #e5e7eb;
  text-transform: uppercase;
  line-height: 1.1;
  word-break: break-word; 
}

/* Right Side: Chips */
.group-items {
  flex: 1;
  padding: 6px 8px; /* CHANGED: Slightly more space inside the box */
  display: flex;
  flex-wrap: wrap;
  gap: 6px; /* CHANGED: More space between the chips */
  align-items: center;
  min-height: 34px;
}
/* Chip Styles */
.chip-label {
  padding: 5px 12px; /* CHANGED: Increased padding for bigger buttons */
  font-size: 0.85rem; /* CHANGED: Larger text size */
  font-weight: 500;
  color: #4b5563; 
  background: #fff; 
  border: 1px solid #d1d5db;
  border-radius: 6px; /* CHANGED: Slightly rounder corners */
  cursor: pointer; 
  transition: all 0.1s ease;
  user-select: none; 
  display: inline-flex; 
  align-items: center;
  line-height: 1.2;
}
.chip-label:hover { background: #f9fafb; border-color: #9ca3af; }

.group-items input[type="checkbox"] { display: none; }
.group-items input[type="checkbox"]:checked + .chip-label {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(13, 110, 253, 0.2);
}


/* Rich Text Editor */
.rich-editor-container {
  border: 1px solid #e5e7eb; border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column;
  background: #fff; flex: 1; min-height: 200px; transition: box-shadow 0.2s;
}
.rich-editor-container:focus-within {
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12); border-color: var(--primary);
}

.toolbar {
  background: #f9fafb; border-bottom: 1px solid #e5e7eb;
  padding: 8px 12px; display: flex; align-items: center; gap: 6px;
  flex-wrap: nowrap; overflow-x: auto; white-space: nowrap;
}
.toolbar::-webkit-scrollbar { height: 4px; }
.toolbar::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 10px; }

.toolbar button, .toolbar select {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; color: #4b5563; font-size: 0.95rem;
  flex-shrink: 0;
}
.toolbar button:hover { background: #e5e7eb; color: #111827; }
.separator { width: 1px; height: 20px; background: #d1d5db; margin: 0 4px; flex-shrink: 0; }

.color-btn { font-weight: 900; font-family: serif; }
.color-btn.blue { color: #0d6efd; }
.color-btn.magenta { color: #d63384; }
.color-btn.red { color: #dc3545; }

.editor-content {
  flex: 1; padding: 24px; overflow-y: auto; outline: none;
  font-size: 1.05rem; line-height: 1.7; color: #1f2937;
}
.editor-content p { margin-top: 0; }
.editor-content a { color: var(--primary); text-decoration: underline; }

.editor-content:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
  display: block;
}

#submitPost { flex-shrink: 0; margin-top: 20px; }

/* ---------- FILTER SECTION ---------- */
.filter-bar {
  width: 100%;
  max-width: 800px;
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-end; /* Align dropdown to the right */
}

.filter-bar select {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 0.95rem;
  color: #374151;
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s;
}

.filter-bar select:hover {
  border-color: #d1d5db;
}

.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
}



/* ---------- SMALL LOGOUT BUTTON ---------- */
.logout-btn-small {
  position: absolute; /* Sticks to top left */
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #fee2e2;
  background: #ffffff;
  color: #ef4444;
  font-size: 1rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  transition: all 0.2s;
  z-index: 50; /* Ensures it stays on top of content */
}

.logout-btn-small:hover {
  background: #fee2e2;
  transform: scale(1.1);
}


