* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  direction: rtl;
  background: #f0f4f8;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #1565c0;
  color: white;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.school-logo {
  height: 40px;
  width: auto;
  border-radius: 6px;
  flex-shrink: 0;
}

.insta-link {
  flex-shrink: 0;
  color: white;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.insta-link:hover { opacity: 1; }

.insta-icon {
  height: 32px;
  width: 32px;
  display: block;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}

.day-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.day-tab {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 28px;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.day-tab:hover { background: rgba(255,255,255,0.35); }
.day-tab.active { background: white; color: #1565c0; }

.date-display {
  font-size: 0.85rem;
  text-align: center;
  margin-top: 6px;
  opacity: 0.85;
}

/* ── View tabs ── */
.view-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid #e0e0e0;
}

.view-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.view-tab.active {
  color: #1565c0;
  border-bottom-color: #1565c0;
}

/* ── Filter bar ── */
.filter-bar {
  background: white;
  padding: 10px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.filter-bar select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #1565c0;
  border-radius: 8px;
  font-size: 1rem;
  color: #1a1a2e;
  background: white;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231565c0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  cursor: pointer;
}

/* ── Main content ── */
main {
  padding: 12px;
  max-width: 700px;
  margin: 0 auto;
}

/* ── Class remark banner ── */
.class-remark {
  background: #7B1FA2;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  direction: rtl;
}

/* ── Lesson cards ── */
.lesson-card {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.lesson-header {
  background: #1565c0;
  color: white;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lesson-num {
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 2px 10px;
}

.lesson-time {
  font-size: 0.85rem;
  opacity: 0.9;
  direction: ltr;
}

.lesson-body {
  padding: 8px 14px;
}

/* By-class view: each row = one group */
.group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.group-row:last-child { border-bottom: none; }

.subject-tag {
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.teacher-name {
  color: #555;
  font-size: 0.85rem;
}

/* By-teacher view: each row = one class entry */
.class-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.class-row:last-child { border-bottom: none; }

.class-badge {
  background: #1565c0;
  color: white;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
}

.class-subject {
  color: #333;
  font-size: 0.85rem;
}

/* ── States ── */
.state-msg {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.state-msg .icon { font-size: 3rem; margin-bottom: 12px; }
.state-msg p { font-size: 1rem; }

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Download bar ── */
.download-bar {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  justify-content: center;
}

.dl-btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.dl-xlsx { background: #e8f5e9; color: #2e7d32; border: 1.5px solid #2e7d32; }
.dl-pdf  { background: #fce4ec; color: #c62828; border: 1.5px solid #c62828; }

/* ── Newspaper ticker bar ── */
.newspaper-bar {
  background: #1b5e20;
  color: white;
  height: 36px;
  display: flex;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.newspaper-label {
  padding: 0 10px;
  font-size: 1rem;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.3);
}

/* ── Ticker bar ── */
.ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1565c0;
  color: white;
  height: 36px;
  display: flex;
  align-items: center;
  z-index: 200;
  overflow: hidden;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.25);
}

.ticker-label {
  padding: 0 10px;
  font-size: 1rem;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.3);
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
}

#ticker-text, #newspaper-text {
  position: absolute;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  top: 50%;
  transform: translateY(-50%);
  left: 100%;
}

/* push footer above ticker */
.app-version { margin-bottom: 36px; }

/* ── Version footer ── */
.app-version {
  text-align: center;
  padding: 16px;
  font-size: 0.72rem;
  color: #bbb;
}

/* ── Grid view ── */
main.grid-mode {
  max-width: none;
  padding: 8px 0;
}

.grid-section {
  margin-bottom: 20px;
}

.grid-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  background: #1565c0;
  text-align: center;
  padding: 7px 12px;
  letter-spacing: 0.5px;
}

.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sched-grid {
  border-collapse: collapse;
  min-width: max-content;
  width: 100%;
  font-size: 0.72rem;
  direction: rtl;
}

.sched-grid thead th {
  background: #1e88e5;
  color: white;
  padding: 5px 6px;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid #1565c0;
}

.sched-grid thead .g-remark-hdr {
  background: #7B1FA2;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  padding: 3px 4px;
  border: 1px solid #6a1b9a;
  white-space: normal;
  line-height: 1.2;
}

.sched-grid thead .g-remark-empty {
  background: #1e88e5;
  border-color: #1565c0;
}

.g-time-hdr {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #0d47a1 !important;
  min-width: 62px;
}

.g-time {
  background: #e8eaf6;
  text-align: center;
  padding: 4px 6px;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid #c5cae9;
  position: sticky;
  right: 0;
  z-index: 1;
}

.g-num {
  font-weight: 700;
  color: #1565c0;
  font-size: 0.75rem;
}

.g-hrs {
  color: #555;
  font-size: 0.65rem;
  direction: ltr;
}

.g-cell {
  border: 1px solid #e0e0e0;
  padding: 3px 4px;
  vertical-align: top;
  min-width: 72px;
  max-width: 100px;
  background: white;
}

.g-cell.g-empty {
  background: #fafafa;
}

.sched-grid tbody tr:nth-child(even) .g-cell {
  background: #f3f6ff;
}
.sched-grid tbody tr:nth-child(even) .g-empty {
  background: #f5f5f5;
}

.g-group {
  padding: 2px 0;
  border-bottom: 1px dashed #e0e0e0;
}
.g-group:last-child { border-bottom: none; }

.g-subj {
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.3;
}

.g-tchr {
  color: #777;
  font-size: 0.65rem;
  line-height: 1.2;
}

/* ── Responsive ── */
@media (min-width: 500px) {
  .lesson-body { padding: 10px 18px; }
  .group-row, .class-row { padding: 8px 0; }
}
