*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #6c8cff;
  --accent-glow: rgba(108, 140, 255, 0.25);
  --today-bg: #1c2235;
  --today-border: #6c8cff;
  --time-line: #ff4d6a;
  --header-bg: #141722;
  --hour-height: 80px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.clock-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.clock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.clock-label {
  color: var(--text-muted);
  font-weight: 500;
}

.clock-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

/* Main */
main {
  padding: 1.5rem;
  max-width: 1500px;
  margin: 0 auto;
  overflow-x: auto;
}

/* ===== Timeline Grid ===== */
.schedule-grid {
  display: grid;
  /* dubai-gutter + india-gutter + 7 day columns */
  grid-template-columns: 72px 72px repeat(7, 1fr);
  min-width: 850px;
}

/* Day headers row */
.grid-header-tz {
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-header-tz.dubai {
  color: #8da8ff;
  background: rgba(108, 140, 255, 0.04);
}

.grid-header-tz.india {
  color: #ffb347;
  background: rgba(255, 165, 0, 0.04);
  border-right: 1px solid var(--border);
}

.grid-day-header {
  text-align: center;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.grid-day-header .day-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: block;
}

.grid-day-header .day-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.grid-day-header.today .day-name {
  color: var(--accent);
}

.grid-day-header.today {
  background: rgba(108, 140, 255, 0.06);
}

/* Time body area */
.grid-body {
  display: grid;
  grid-template-columns: 72px 72px repeat(7, 1fr);
  grid-column: 1 / -1;
  position: relative;
}

/* Time gutter columns */
.time-gutter {
  position: relative;
}

.time-gutter.dubai {
  background: rgba(108, 140, 255, 0.02);
}

.time-gutter.india {
  background: rgba(255, 165, 0, 0.02);
  border-right: 1px solid var(--border);
}

.time-label {
  position: absolute;
  left: 0;
  right: 0;
  text-align: right;
  padding-right: 0.5rem;
  font-size: 0.68rem;
  transform: translateY(-50%);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.time-gutter.dubai .time-label {
  color: #8da8ff;
}

.time-gutter.india .time-label {
  color: #ffb347;
}

/* Day lanes */
.day-lane {
  position: relative;
  border-left: 1px solid var(--border);
  min-height: calc(var(--hour-height) * 14); /* 9AM-11PM = 14 hours */
}

.day-lane.today {
  background: rgba(108, 140, 255, 0.03);
}

/* Hour grid lines */
.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  pointer-events: none;
}

.hour-line.half {
  background: rgba(42, 46, 61, 0.4);
}

/* Unavailable block */
.unavailable-block {
  position: absolute;
  left: 0;
  right: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.02) 6px,
    rgba(255, 255, 255, 0.05) 6px,
    rgba(255, 255, 255, 0.05) 12px
  );
  background-color: rgba(255, 77, 106, 0.04);
  border-top: 1px dashed rgba(255, 77, 106, 0.2);
  border-bottom: 1px dashed rgba(255, 77, 106, 0.2);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.unavailable-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 77, 106, 0.35);
}

/* Class card (absolutely positioned) */
.class-card {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  border-left: 3px solid;
  overflow: hidden;
  cursor: default;
  transition: box-shadow 0.15s;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.class-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 6;
}

.class-card.temporary {
  border-left-style: dashed;
}

.temp-badge {
  display: inline-block;
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #cc2233;
  color: #ffd740;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.cancel-badge {
  display: inline-block;
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255, 77, 106, 0.2);
  color: #ff4d6a;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.class-card.cancelled {
  opacity: 0.45;
  border-left-style: dashed;
}

.class-card.cancelled .class-subject {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

.class-card.cancelled .class-time-info {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

.class-subject {
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-time-info {
  font-size: 0.62rem;
  margin-top: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.class-time-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tz-badge {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.05rem 0.2rem;
  border-radius: 2px;
  min-width: 24px;
  text-align: center;
}

.tz-badge.dubai {
  background: rgba(108, 140, 255, 0.15);
  color: #8da8ff;
}

.tz-badge.india {
  background: rgba(255, 165, 0, 0.15);
  color: #ffb347;
}

/* Current time line */
.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--time-line);
  z-index: 20;
  pointer-events: none;
}

.current-time-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--time-line);
}

/* Time line in the gutter */
.gutter-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--time-line);
  z-index: 20;
  pointer-events: none;
}

.gutter-time-label {
  position: absolute;
  right: 0.3rem;
  transform: translateY(-100%);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--time-line);
  white-space: nowrap;
  z-index: 21;
  pointer-events: none;
}

/* No classes */
.no-classes {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
  white-space: nowrap;
}

/* Time tooltip */
.time-tooltip {
  position: absolute;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tt-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.tt-tz {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  min-width: 28px;
  text-align: center;
}

.tt-tz.dubai {
  background: rgba(108, 140, 255, 0.15);
  color: #8da8ff;
}

.tt-tz.india {
  background: rgba(255, 165, 0, 0.15);
  color: #ffb347;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

footer strong {
  color: var(--text);
  font-weight: 500;
}

/* ===== Mobile day nav (hidden on desktop) ===== */
.mobile-day-nav {
  display: none;
}

.mobile-schedule {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .schedule-grid {
    min-width: 750px;
  }

  :root {
    --hour-height: 65px;
  }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 1.15rem;
  }

  main {
    padding: 1rem;
  }

  .schedule-grid {
    min-width: 650px;
    grid-template-columns: 58px 58px repeat(7, 1fr);
  }

  .grid-body {
    grid-template-columns: 58px 58px repeat(7, 1fr);
  }

  :root {
    --hour-height: 60px;
  }

  .time-label {
    font-size: 0.6rem;
  }
}

/* ===== Mobile portrait: single-day view ===== */
@media (max-width: 600px) {
  /* Hide desktop grid, show mobile view */
  .schedule-container {
    display: none !important;
  }

  .mobile-day-nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 99;
    scrollbar-width: none;
  }

  .mobile-day-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-day-nav .day-tab {
    flex: 0 0 auto;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
  }

  .mobile-day-nav .day-tab .tab-date {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-muted);
    opacity: 0.7;
  }

  .mobile-day-nav .day-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  .mobile-day-nav .day-tab.today-tab {
    color: var(--accent);
  }

  .mobile-day-nav .day-tab.today-tab .tab-date {
    color: var(--accent);
  }

  .mobile-schedule {
    display: block;
    padding: 0;
  }

  /* Mobile single-day timeline */
  .mobile-timeline {
    display: grid;
    grid-template-columns: 56px 56px 1fr;
    position: relative;
  }

  .mobile-timeline .time-gutter {
    position: relative;
  }

  .mobile-timeline .time-gutter.dubai {
    background: rgba(108, 140, 255, 0.02);
  }

  .mobile-timeline .time-gutter.india {
    background: rgba(255, 165, 0, 0.02);
    border-right: 1px solid var(--border);
  }

  .mobile-timeline .time-label {
    font-size: 0.6rem;
    padding-right: 0.35rem;
  }

  .mobile-timeline .day-lane {
    border-left: none;
  }

  .mobile-timeline .class-card {
    left: 4px;
    right: 4px;
    padding: 0.4rem 0.5rem;
  }

  .mobile-timeline .class-subject {
    font-size: 0.82rem;
  }

  .mobile-timeline .class-time-info {
    font-size: 0.66rem;
  }

  .mobile-timeline .unavailable-label {
    font-size: 0.6rem;
  }

  /* Header adjustments */
  header {
    padding: 0.75rem 1rem;
    position: relative;
    top: auto;
  }

  header h1 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .clock-bar {
    gap: 0.4rem;
  }

  .clock {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    gap: 0.3rem;
  }

  .clock-label {
    font-size: 0.6rem;
  }

  main {
    padding: 0;
    overflow-x: hidden;
  }

  footer {
    font-size: 0.7rem;
    padding: 0.75rem;
  }

  :root {
    --hour-height: 65px;
  }
}
