/* ============================================================
   SUBJECT GRID
   ============================================================ */

.subjects-grid {
  display: grid;

  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 18px;

  align-items: start;
}

/* ============================================================
   SUBJECT CARD
   ============================================================ */

.subject-card {
  position: relative;

  min-width: 0;

  overflow: hidden;

  border: 1px solid var(--border);

  border-radius: var(--radius-lg);

  background: linear-gradient(180deg,
      rgba(14, 18, 29, 0.94),
      rgba(12, 16, 28, 0.94));

  box-shadow: var(--shadow);

  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition);
}

.subject-card:hover {
  border-color: var(--border-strong);

  background: linear-gradient(180deg,
      rgba(22, 29, 47, 0.97),
      rgba(13, 17, 29, 0.97));
}

.subject-card.editing {
  border-color: rgba(102, 128, 255, 0.36);

  box-shadow: 0 18px 65px rgba(48, 58, 130, 0.17);
}

/* ============================================================
   CARD TOP ACCENT
   ============================================================ */

.subject-card::before {
  content: "";

  position: absolute;

  left: 0;
  top: 0;

  width: 100%;
  height: 2px;

  background: var(--gradient);

  opacity: 0.65;
}

/* ============================================================
   CARD HEADER
   ============================================================ */

.card-header {
  display: flex;

  align-items: flex-start;
  justify-content: space-between;

  gap: 14px;

  padding: 20px 20px 16px;
}

.card-title-area {
  min-width: 0;
}

.card-title {
  margin: 0;

  overflow: hidden;

  color: var(--text-primary);

  font-size: 17px;
  font-weight: 720;

  line-height: 1.25;

  letter-spacing: -0.025em;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.card-code {
  margin: 5px 0 0;

  color: var(--text-secondary);

  font-size: 12px;

  font-weight: 600;

  letter-spacing: 0.06em;
}

.card-meta {
  display: flex;

  align-items: center;

  flex-wrap: wrap;

  gap: 7px;

  margin-top: 12px;
}

.credit-pill {
  display: inline-flex;

  align-items: center;

  padding: 5px 8px;

  border: 1px solid var(--border);

  border-radius: 7px;

  color: var(--text-secondary);

  font-size: 11px;
  font-weight: 650;
}

.complexity-badge {
  display: inline-flex;

  align-items: center;

  padding: 5px 8px;

  border-radius: 7px;

  font-size: 10px;
  font-weight: 750;

  text-transform: uppercase;

  letter-spacing: 0.06em;
}

.complexity-easy {
  color: #69e0aa;

  background: rgba(79, 211, 154, 0.1);

  border: 1px solid rgba(79, 211, 154, 0.16);
}

.complexity-medium {
  color: #f2cc78;

  background: rgba(244, 199, 109, 0.1);

  border: 1px solid rgba(244, 199, 109, 0.16);
}

.complexity-hard {
  color: #ff7c92;

  background: rgba(255, 14, 14, 0.547);

  border: 1px solid rgba(255, 111, 134, 0.16);
}

/* ============================================================
   CARD BODY
   ============================================================ */

.card-body {
  padding: 0 20px;
}

.lane {
  margin-bottom: 15px;
}

.lane-header {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-bottom: 8px;
}

.lane-title {
  display: flex;

  align-items: center;

  gap: 7px;

  color: var(--text-secondary);

  font-size: 11px;
  font-weight: 750;

  text-transform: uppercase;

  letter-spacing: 0.075em;
}

.lane-title::before {
  content: "";

  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: var(--blue);

  box-shadow: 0 0 10px rgba(91, 140, 255, 0.7);
}

.lane-count {
  color: var(--text-muted);

  font-size: 11px;
  font-weight: 650;
}

/* ============================================================
   DROP ZONE
   ============================================================ */

.lesson-lane {
  display: flex;

  align-items: flex-start;

  flex-wrap: wrap;

  gap: 7px;

  min-height: 42px;

  padding: 8px;

  border: 1px dashed rgba(255, 255, 255, 0.075);

  border-radius: 11px;

  background: rgba(0, 0, 0, 0.1);

  transition:
    background var(--transition),
    border-color var(--transition);
}

.lesson-lane.sortable-ghost-container {
  border-color: rgba(91, 140, 255, 0.35);
}

.lesson-lane:empty::after {
  content: "Drop lessons here";

  color: var(--text-muted);

  font-size: 11px;

  padding: 6px;
}

/* ============================================================
   LESSON CHIP
   ============================================================ */

.lesson-chip {
  display: inline-flex;

  align-items: center;

  justify-content: center;

  min-width: 39px;

  min-height: 34px;

  padding: 7px 10px;

  border: 1px solid rgba(255, 255, 255, 0.085);

  border-radius: 9px;

  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.055),
      rgba(255, 255, 255, 0.025));

  color: var(--text-primary);

  font-size: 12px;
  font-weight: 700;

  cursor: grab;

  user-select: none;

  touch-action: none;

  transition:
    border-color var(--transition),
    transform var(--transition),
    background var(--transition);
}

.lesson-chip:hover {
  border-color: rgba(111, 143, 255, 0.35);

  background: rgba(91, 140, 255, 0.08);
}

.lesson-chip:active {
  cursor: grabbing;
}

.lesson-chip.pool-chip {
  border-color: rgba(151, 117, 255, 0.18);

  background: rgba(151, 117, 255, 0.07);
}

.lesson-chip.studied-chip {
  border-color: rgba(79, 211, 154, 0.17);

  background: rgba(79, 211, 154, 0.07);
}

.lesson-chip .delete-target {
  display: grid;

  place-items: center;

  width: 18px;
  height: 18px;

  margin-left: 5px;

  border-radius: 50%;

  color: var(--text-muted);

  background: rgba(255, 255, 255, 0.04);

  cursor: pointer;

  font-size: 13px;

  touch-action: manipulation;
}

.lesson-chip .delete-target:hover {
  color: white;

  background: rgba(255, 111, 134, 0.18);
}

/* ============================================================
   SORTABLE STATES
   ============================================================ */

.sortable-ghost {
  opacity: 0.3;
}

.sortable-chosen {
  transform: scale(1.03);
}

.sortable-drag {
  opacity: 0.95;

  transform: rotate(2deg) scale(1.04);

  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   REMAINING LANE
   ============================================================ */

.remaining-lane {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 12px;

  min-height: 53px;

  padding: 10px 12px;

  border: 1px solid rgba(91, 140, 255, 0.1);

  border-radius: 11px;

  background: linear-gradient(135deg,
      rgba(91, 140, 255, 0.065),
      rgba(151, 105, 255, 0.045));
}

.remaining-value {
  display: flex;

  align-items: baseline;

  gap: 7px;
}

.remaining-number {
  font-size: 21px;
  font-weight: 800;

  letter-spacing: -0.04em;
}

.remaining-label {
  color: var(--text-muted);

  font-size: 11px;
}

/* ============================================================
   SUBJECT CARD FOOTER
   ============================================================ */

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: auto;
  padding: 18px;
  min-height: 48px;
}

/*
 * Ascending Order stays on the left.
 */
.card-footer .sort-toggle-area {
  margin-right: auto;
}

/*
 * Edit button ALWAYS stays at the bottom-right.
 */
.card-footer .icon-button {
  margin-left: auto;
  flex-shrink: 0;
}

/* ============================================================
   ICON BUTTONS
   ============================================================ */

.icon-button {
  display: grid;

  place-items: center;

  width: 34px;
  height: 34px;

  flex: 0 0 auto;

  border: 1px solid var(--border);

  border-radius: 9px;

  background: rgba(255, 255, 255, 0.025);

  color: var(--text-secondary);

  cursor: pointer;

  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition);
}

.icon-button:hover {
  color: white;

  border-color: rgba(104, 132, 255, 0.32);

  background: rgba(91, 140, 255, 0.08);
}

.edit-icon {
  width: 15px;
  height: 15px;
}

/* ============================================================
   EDIT MODE
   ============================================================ */

.edit-mode-panel {
  margin: 0 20px 16px;

  padding: 12px;

  border: 1px solid rgba(151, 117, 255, 0.14);

  border-radius: 12px;

  background: rgba(151, 117, 255, 0.045);
}

.edit-mode-heading {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-bottom: 9px;
}

.edit-mode-heading strong {
  font-size: 11px;

  text-transform: uppercase;

  letter-spacing: 0.07em;
}

.edit-mode-heading span {
  color: var(--text-muted);

  font-size: 10px;
}

.lesson-pool {
  display: flex;

  flex-wrap: wrap;

  gap: 7px;

  min-height: 40px;
}

/* ============================================================
   EMPTY POOL
   ============================================================ */

.pool-empty {
  width: 100%;

  padding: 9px;

  color: var(--text-muted);

  font-size: 11px;

  text-align: center;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: grid;

  place-items: center;

  min-height: 360px;

  padding: 30px;

  border: 1px dashed var(--border);

  border-radius: var(--radius-lg);

  text-align: center;
}

.empty-icon {
  display: grid;

  place-items: center;

  width: 50px;
  height: 50px;

  margin-bottom: 14px;

  border-radius: 15px;

  background: var(--gradient);

  font-size: 25px;
}

.empty-state h2 {
  margin: 0 0 7px;

  font-size: 20px;
}

.empty-state p {
  max-width: 360px;

  margin: 0 0 18px;

  color: var(--text-secondary);

  font-size: 13px;

  line-height: 1.6;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.primary-button,
.secondary-button {
  min-height: 40px;

  padding: 0 15px;

  border-radius: 9px;

  font-size: 12px;
  font-weight: 750;

  cursor: pointer;

  transition:
    transform var(--transition),
    opacity var(--transition),
    background var(--transition);
}

.primary-button {
  color: white;

  background: var(--gradient);

  box-shadow: 0 8px 22px rgba(86, 96, 255, 0.2);
}

.primary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.55;

  cursor: wait;

  transform: none;
}

.secondary-button {
  color: var(--text-secondary);

  border: 1px solid var(--border);

  background: rgba(255, 255, 255, 0.025);
}

.secondary-button:hover {
  color: white;

  background: rgba(255, 255, 255, 0.055);
}

/* ============================================================
   FAB
   ============================================================ */

.fab {
  position: fixed;

  left: auto;
  right: 24px;
  bottom: 24px;

  z-index: 50;

  display: grid;

  place-items: center;

  width: 56px;
  height: 56px;

  border-radius: 17px;

  color: white;

  background: var(--gradient);

  box-shadow: 0 16px 35px rgba(59, 70, 190, 0.35);

  cursor: pointer;

  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.fab:hover {
  transform: translateY(-2px) scale(1.02);

  box-shadow: 0 20px 42px rgba(59, 70, 190, 0.42);
}

.fab span {
  font-size: 27px;
  font-weight: 350;

  line-height: 1;
}

@media (max-width: 600px) {
  .fab {
    right: 18px;
    left: auto;
    bottom: 18px;
  }
}

