/* ===== Schedule Page Styles ===== */

.schedule-main {
  padding: 2rem 0 4rem;
  min-height: calc(100vh - 80px);
}

.schedule-header {
  text-align: center;
  margin-bottom: 3rem;
}

.schedule-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.schedule-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* ===== Steps ===== */
.schedule-steps {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2rem;
  display: flex;
  gap: 1.5rem;
  transition: all 0.3s;
}

.step-card.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.step-card.active {
  opacity: 1;
  pointer-events: auto;
  border-color: var(--primary);
}

.step-number {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.step-content {
  flex: 1;
}

.step-content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.step-hint {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ===== Major Options ===== */
.major-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.major-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 1rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
  transition: all 0.3s;
}

.major-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.major-btn.selected {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.1);
}

.major-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

/* ===== Courses Filter ===== */
.courses-filter {
  margin-bottom: 1rem;
}

.courses-filter .search-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: "Cairo", sans-serif;
}

.courses-filter .search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Courses Selection Grid ===== */
.courses-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
  margin: -0.5rem;
}

.loading-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

.course-select-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.course-select-item:hover {
  border-color: var(--primary);
}

.course-select-item.selected {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.1);
}

.course-select-item input {
  display: none;
}

.course-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.course-checkbox svg {
  width: 14px;
  height: 14px;
  stroke: white;
  opacity: 0;
  transition: opacity 0.2s;
}

.course-select-item.selected .course-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.course-select-item.selected .course-checkbox svg {
  opacity: 1;
}

.course-select-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.course-select-code {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

.course-select-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.course-sections-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--surface-light);
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  width: fit-content;
  margin-top: 0.25rem;
}

/* ===== Selected Courses Summary ===== */
.selected-courses-summary {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface-light);
  border-radius: 0.75rem;
}

.selected-courses-summary h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.selected-courses-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.course-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.course-chip button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.course-chip button:hover {
  opacity: 1;
}

.course-chip button svg {
  stroke: white;
}

/* ===== Generate Options ===== */
.generate-options {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.option-group select {
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
}

.option-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.days-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.days-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
}

.days-checkboxes input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ===== Generate Button ===== */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 2rem;
  background: var(--gradient-primary);
  border: none;
  border-radius: 0.75rem;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
}

/* ===== Results Section ===== */
.results-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.results-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.results-info {
  color: var(--text-secondary);
  font-size: 1rem;
}

.results-info span {
  color: var(--primary);
  font-weight: 700;
}

/* ===== Schedules Navigation ===== */
.schedules-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.schedule-counter {
  font-size: 1rem;
  font-weight: 600;
}

.schedule-counter span {
  color: var(--primary);
}

/* ===== Schedule Table ===== */
.schedule-table-wrapper {
  overflow-x: auto;
  margin-bottom: 2rem;
  background: var(--surface);
  border-radius: 1rem;
  border: 1px solid var(--border);
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.schedule-table th,
.schedule-table td {
  padding: 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
  vertical-align: top;
}

.schedule-table th {
  background: var(--surface-light);
  font-weight: 700;
  font-size: 0.95rem;
}

.schedule-table .time-cell {
  background: var(--surface-light);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  width: 80px;
}

/* ===== Schedule Cell Colors ===== */
.schedule-cell {
  padding: 0.5rem;
  border-radius: 0.5rem;
  height: 100%;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}

.schedule-cell .course-code {
  font-weight: 700;
  font-size: 0.9rem;
}

.schedule-cell .course-section {
  font-size: 0.75rem;
  opacity: 0.9;
}

.schedule-cell .course-room {
  font-size: 0.7rem;
  opacity: 0.8;
}

.schedule-cell .course-time {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* Color variations */
.schedule-cell.color-1 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.schedule-cell.color-2 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; }
.schedule-cell.color-3 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: #1a1a2e; }
.schedule-cell.color-4 { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); color: #1a1a2e; }
.schedule-cell.color-5 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); color: #1a1a2e; }
.schedule-cell.color-6 { background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%); color: #1a1a2e; }
.schedule-cell.color-7 { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); color: #1a1a2e; }
.schedule-cell.color-8 { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); color: #1a1a2e; }

/* ===== Schedule Details ===== */
.schedule-details {
  margin-bottom: 2rem;
}

.schedule-details h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.sections-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.section-detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  border-right: 4px solid var(--primary);
}

.section-detail-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.section-detail-card p,
.section-detail-card div {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Export Options ===== */
.export-options {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-export:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== No Results ===== */
.no-results {
  text-align: center;
  padding: 4rem 2rem;
  margin-top: 2rem;
}

.no-results svg {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.no-results h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.no-results p {
  color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .schedule-header h1 {
    font-size: 1.75rem;
  }

  .step-card {
    flex-direction: column;
    padding: 1.5rem;
  }

  .step-number {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 1rem;
  }

  .major-options {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .major-btn {
    flex-direction: row;
    justify-content: flex-start;
    padding: 1rem;
  }

  .major-icon {
    width: 40px;
    height: 40px;
  }

  .courses-selection-grid {
    grid-template-columns: 1fr;
    max-height: 300px;
  }

  .generate-options {
    flex-direction: column;
    gap: 1rem;
  }

  .results-header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .schedules-navigation {
    gap: 1rem;
  }

  .sections-details-grid {
    grid-template-columns: 1fr;
  }

  .export-options {
    flex-direction: column;
  }

  .btn-export {
    justify-content: center;
  }
}

/* ===== Print Styles ===== */
@media print {
  .navbar,
  .schedule-steps,
  .schedules-navigation,
  .export-options,
  .schedule-details {
    display: none !important;
  }

  .schedule-table-wrapper {
    border: none;
    box-shadow: none;
  }

  .schedule-table {
    font-size: 10pt;
  }

  .schedule-cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.course-badge{
  display:inline-block;
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  margin-bottom:8px;
}
.course-badge.closed{
  background: rgba(239,68,68,.18);
  color:#ffb4b4;
}
.course-badge.open{
  background: rgba(16,185,129,.16);
  color:#b6ffe6;
}
.schedule-cell.closed{
  outline: 1px dashed rgba(239,68,68,.35);
}

/* ===== Open-only toggle (Step 3) ===== */
.option-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
}

.option-title{
  font-weight:600;
  color: var(--text-primary);
}

/* Toggle switch */
.toggle{
  position:relative;
  display:inline-flex;
  align-items:center;
  cursor:pointer;
  user-select:none;
}

.toggle input{
  position:absolute;
  opacity:0;
  width:0;
  height:0;
}

.toggle-ui{
  width:44px;
  height:24px;
  border-radius:999px;
  background: rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.14);
  display:inline-block;
  position:relative;
  transition: .2s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}

.toggle-ui::after{
  content:"";
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  right:3px;            /* RTL */
  width:18px;
  height:18px;
  border-radius:50%;
  background: rgba(255,255,255,.92);
  transition: .2s ease;
}

.toggle input:checked + .toggle-ui{
  background: rgba(124, 92, 255, .35);
  border-color: rgba(124, 92, 255, .55);
}

.toggle input:checked + .toggle-ui::after{
  right:23px;           /* RTL */
}
.toggle-wrap{
  display:flex;
  align-items:center;
  gap:10px;
}

.toggle-state{
  font-size:13px;
  font-weight:700;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.75);
}

.toggle-state.on{
  background: rgba(16,185,129,.14);
  border-color: rgba(16,185,129,.28);
  color: rgba(178,255,235,.95);
}

.toggle-state.off{
  background: rgba(239,68,68,.14);
  border-color: rgba(239,68,68,.28);
  color: rgba(255,190,190,.95);
}

/* ===== Custom Scrollbar (Chrome/Edge/Safari) ===== */
#coursesGrid::-webkit-scrollbar{
  width: 10px;
}

#coursesGrid::-webkit-scrollbar-track{
  background: rgba(255,255,255,.06);
  border-radius: 999px;
}

#coursesGrid::-webkit-scrollbar-thumb{
  background: rgba(124,92,255,.55); /* لون الشريط */
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,.15); /* يعطيه فصل عن الخلفية */
}

#coursesGrid::-webkit-scrollbar-thumb:hover{
  background: rgba(124,92,255,.75);
}

/* ===== Firefox ===== */
#coursesGrid{
  scrollbar-width: thin;
  scrollbar-color: rgba(124,92,255,.55) rgba(255,255,255,.06);
}


/* ===== Table look like (image 2) ===== */
.schedule-table {
  border-collapse: separate;
  border-spacing: 0;
}

.schedule-table td {
  padding: 10px;
  vertical-align: top;
}

.schedule-block{
  height: 100%;
  min-height: 82px;
  border-radius: 12px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: none;
  border: 0;
  color: #fff;
  text-align: center;
}

/* top line: instructor */
.sb-top{
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  opacity: .95;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sb-top .pin{ font-size: 14px; opacity: .9; }

/* main code line */
.sb-code{
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
}

/* sub line: type + section */
.sb-sub{
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  opacity: .92;
}

/* remove old gradient look if exists */
.schedule-cell{
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* ===== Solid colors like image 2 (pick your palette) ===== */
.schedule-block.color-1 { background: #0ea5e9; } /* blue */
.schedule-block.color-2 { background: #f59e0b; } /* orange */
.schedule-block.color-3 { background: #7c3aed; } /* purple */
.schedule-block.color-4 { background: #84cc16; } /* lime */
.schedule-block.color-5 { background: #ef4444; } /* red */
.schedule-block.color-6 { background: #10b981; } /* green */
.schedule-block.color-7 { background: #06b6d4; } /* cyan */
.schedule-block.color-8 { background: #ec4899; } /* pink */

/* On mobile: tighten a bit */
@media (max-width: 768px){
  .schedule-block{ padding: 10px; min-height: 74px; border-radius: 10px; }
  .sb-top{ font-size: 14px; }
  .sb-code{ font-size: 18px; }
  .sb-sub{ font-size: 14px; }
}

.schedule-block { padding: 10px 12px; border-radius: 10px; }
.sb-teacher { font-size: 14px; opacity: .95; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-code { font-size: 18px; font-weight: 800; line-height: 1.2; }
.sb-sub { font-size: 14px; font-weight: 700; opacity: .95; margin-top: 4px; }
.sb-time { font-size: 13px; opacity: .9; margin-top: 6px; }


.open-only-row{
  display:flex;
  align-items:flex-start;
  gap:14px;
  margin-top:10px;
}

.open-only-title{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
}

.open-only-badge{
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  border:1px solid rgba(255,255,255,.12);
}

.open-only-badge.on{
  background: rgba(16, 185, 129, .14);
  color:#34d399;
}

.open-only-badge.off{
  background: rgba(239, 68, 68, .14);
  color:#f87171;
}

/* Toggle switch */
.toggle{ display:inline-flex; cursor:pointer; user-select:none; }
.toggle input{ display:none; }

.toggle-track{
  width:46px;
  height:24px;
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.14);
  border-radius:999px;
  position:relative;
  transition:.2s;
}

.toggle-track::after{
  content:"";
  width:18px; height:18px;
  background:#fff;
  border-radius:50%;
  position:absolute;
  top:50%;
  transform: translateY(-50%);
  right:3px;
  transition:.2s;
}

.toggle input:checked + .toggle-track{
  background: rgba(99,102,241,.35);
  border-color: rgba(99,102,241,.45);
}

.toggle input:checked + .toggle-track::after{
  right:25px;
}


/* ===== Days chips ===== */
.days-checkboxes{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* hide native checkbox */
.day-chip input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* chip base */
.day-chip{
  position: relative;
  cursor: pointer;
  user-select: none;
}

.day-chip span{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.85);
  font-weight: 700;
  font-size: .95rem;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

/* hover */
.day-chip:hover span{
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.06);
  transform: translateY(-1px);
}

/* checked */
.day-chip input:checked + span{
  background: linear-gradient(135deg, rgba(102,126,234,.35), rgba(240,147,251,.22));
  border-color: rgba(102,126,234,.65);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}

/* focus (keyboard) */
.day-chip input:focus-visible + span{
  outline: none;
  box-shadow: 0 0 0 4px rgba(99,102,241,.22);
}

/* small screens */
@media (max-width: 520px){
  .day-chip span{
    min-width: 70px;
    height: 36px;
    font-size: .9rem;
    padding: 0 12px;
  }
}
