/* =================================================
   Snowdon Towers 4D/5D Viewer — responsive UI
   Desktop > 1024px | Tablet 768-1024 | Mobile < 768
   ================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1a1d23;
  color: #e8eaed;
  overflow: hidden;
}

.mobile-only { display: none; }

/* ============== TOP BAR ============== */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(180deg, #2a2d35 0%, #20232a 100%);
  border-bottom: 2px solid #00b9f1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#topbar .brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
#topbar .logo { font-size: 28px; color: #00b9f1; }
#topbar .title .t1 { font-size: 16px; font-weight: 600; color: #fff; line-height: 1.1; }
#topbar .title .t2 { font-size: 11px; color: #8a8f99; letter-spacing: 0.5px; }

#topbar .data-date { display: flex; flex-direction: column; gap: 2px; margin-left: auto; flex-shrink: 0; }
#topbar .data-date label { font-size: 10px; color: #8a8f99; text-transform: uppercase; letter-spacing: 1px; }
#topbar .data-date input {
  background: #1a1d23; border: 1px solid #3a3f4a; color: #fff;
  padding: 4px 8px; border-radius: 4px; font-size: 13px;
  min-width: 130px;
}

#topbar .play-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
#topbar .play-controls button {
  background: #2f343d; border: 1px solid #3a3f4a; color: #fff;
  font-size: 14px; width: 38px; height: 38px;
  border-radius: 4px; cursor: pointer; transition: background 0.15s;
  touch-action: manipulation;
}
#topbar .play-controls button:hover { background: #00b9f1; border-color: #00b9f1; }
#topbar .play-controls button:active { transform: scale(0.95); }
#topbar .play-controls button.playing { background: #ff6b35; border-color: #ff6b35; }
#topbar .play-controls button#btn-ghost { width: auto; padding: 0 10px; font-size: 12px; }
#topbar .play-controls button#btn-ghost.active { background: #00b9f1; border-color: #00b9f1; }
#topbar .speed { font-size: 11px; color: #8a8f99; margin-left: 8px; display: flex; align-items: center; gap: 6px; }
#topbar .speed select {
  background: #1a1d23; border: 1px solid #3a3f4a; color: #fff;
  padding: 5px 8px; border-radius: 3px; font-size: 12px;
}

#topbar .credit {
  margin-left: 0; padding-left: 16px;
  border-left: 2px solid #00b9f1;
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; flex-shrink: 0;
  background: linear-gradient(90deg, rgba(0,185,241,0.08) 0%, transparent 100%);
  padding: 4px 12px 4px 16px; border-radius: 0 4px 4px 0;
}
#topbar .credit-line1 { font-size: 12px; color: #c8ccd4; letter-spacing: 0.3px; }
#topbar .credit-line1 b { color: #00b9f1; font-weight: 700; }
#topbar .credit-line2 { font-size: 11px; }
#topbar .credit-line2 a {
  color: #00b9f1; text-decoration: none; transition: color 0.15s; font-weight: 500;
}
#topbar .credit-line2 a:hover { color: #fff; text-decoration: underline; }

#btn-menu {
  background: linear-gradient(135deg, #00b9f1 0%, #0090c4 100%);
  border: 1px solid #00b9f1; color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 0 14px; height: 42px; min-width: 42px;
  border-radius: 6px; cursor: pointer; margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 0 0 0 rgba(0,185,241,0.6);
  animation: menuPulse 2.5s ease-in-out infinite;
}
#btn-menu .menu-icon { font-size: 18px; line-height: 1; }
#btn-menu .menu-label { font-size: 12px; letter-spacing: 0.4px; }
#btn-menu:hover { background: #00b9f1; transform: scale(1.02); }
@keyframes menuPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,185,241,0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(0,185,241,0); }
}
body.drawer-open #btn-menu { animation: none; }
#btn-close-drawer {
  position: absolute; top: 8px; right: 8px;
  background: #2f343d; border: 1px solid #3a3f4a; color: #fff;
  font-size: 18px; width: 36px; height: 36px;
  border-radius: 4px; cursor: pointer; z-index: 5;
}

/* ============== MAIN LAYOUT ============== */
#main {
  position: absolute;
  top: 56px; left: 0; right: 0;
  bottom: 180px;
  display: flex;
}

#viewer-wrapper { flex: 1; position: relative; background: #f4f5f7; }
#preview { position: absolute; inset: 0; }

#floating-date {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.75); color: #fff;
  padding: 6px 14px; border-radius: 4px;
  font-weight: 600; font-size: 14px;
  pointer-events: none; z-index: 10;
  border-left: 3px solid #00b9f1;
}

/* ============== SIDEBAR ============== */
#sidebar {
  width: 280px; background: #20232a;
  border-left: 1px solid #2a2d35;
  overflow-y: auto; padding: 12px;
  transition: transform 0.25s ease;
}
#drawer-backdrop {
  display: none;
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 99;
}
body.drawer-open #drawer-backdrop { display: block; }
#sidebar .card {
  background: #2a2d35; border-radius: 6px;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid #3a3f4a;
}
#sidebar .card h3 {
  margin: 0 0 10px 0; font-size: 12px;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: #8a8f99;
  border-bottom: 1px solid #3a3f4a; padding-bottom: 6px;
}

#sidebar .legend, #sidebar .count-row { list-style: none; margin: 0; padding: 0; }
#sidebar .legend li, #sidebar .count-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; font-size: 13px;
}
#sidebar .count-row b {
  margin-left: auto;
  background: #1a1d23; padding: 1px 8px;
  border-radius: 10px; font-size: 12px;
  min-width: 28px; text-align: center;
}

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.s-completed-ontime { background: #70AD47; }
.s-completed-late   { background: #ED7D31; }
.s-inprogress       { background: #FFC000; }
.s-delayed          { background: #C00000; }
.s-future           { background: #5a5f6a; }

#sidebar .kpi {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; font-size: 13px;
  border-bottom: 1px dashed #3a3f4a;
}
#sidebar .kpi:last-child { border-bottom: none; }
#sidebar .kpi span { color: #8a8f99; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
#sidebar .kpi b { color: #fff; font-size: 13px; }

#active-list { font-size: 12px; line-height: 1.5; }
.active-item {
  background: #1a1d23; border-left: 3px solid #00b9f1;
  padding: 6px 8px; margin-bottom: 6px; border-radius: 3px;
}
.active-item .aid { font-weight: 600; color: #fff; }
.active-item .meta { color: #8a8f99; font-size: 11px; margin-top: 2px; }

.credit-card .cc-name { font-size: 13px; color: #fff; font-weight: 600; margin-bottom: 8px; }
.credit-card .cc-links { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.credit-card .cc-links a {
  color: #00b9f1; text-decoration: none; padding: 6px 8px;
  background: #1a1d23; border-radius: 4px; transition: background 0.15s;
}
.credit-card .cc-links a:hover { background: #00b9f1; color: #fff; }

/* ============== BOTTOM BAR ============== */
#bottombar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 180px; background: #20232a;
  border-top: 1px solid #2a2d35;
  padding: 10px 16px; overflow: hidden;
}

#scrubber-row { position: relative; height: 30px; margin-bottom: 8px; }
#scrubber {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 6px; background: #3a3f4a;
  border-radius: 3px; outline: none;
}
#scrubber::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #00b9f1;
  cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0,185,241,0.6);
}
#scrubber::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #00b9f1; cursor: pointer; border: 2px solid #fff;
}
#scrubber-ticks {
  position: absolute; top: 18px; left: 0; right: 0;
  display: flex; justify-content: space-between;
  font-size: 10px; color: #8a8f99; padding: 0 4px;
  pointer-events: none;
}

#activity-strip {
  position: relative; height: 130px;
  overflow-x: auto; overflow-y: auto;
  background: #1a1d23; border-radius: 4px; padding: 4px;
  -webkit-overflow-scrolling: touch;
}
.act-bar {
  position: absolute; height: 16px;
  border-radius: 2px; font-size: 9px;
  color: #fff; padding: 1px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; border: 1px solid rgba(255,255,255,0.15);
  line-height: 14px;
}
.act-bar:hover { z-index: 5; border-color: #fff; }
.act-bar.s-completed-ontime { background: #70AD47; }
.act-bar.s-completed-late   { background: #ED7D31; }
.act-bar.s-inprogress       { background: #FFC000; color: #000; }
.act-bar.s-delayed          { background: #C00000; }
.act-bar.s-future           { background: #4a4f5a; }

.data-date-line {
  position: absolute; top: 0; bottom: 0;
  width: 2px; background: #00b9f1;
  z-index: 4; pointer-events: none;
  box-shadow: 0 0 4px #00b9f1;
}

/* ============================================
   TABLET (768-1024px)
   ============================================ */
@media (max-width: 1024px) {
  #topbar { gap: 10px; padding: 0 10px; }
  #topbar .title .t2 { font-size: 10px; }
  #topbar .credit-line2 { font-size: 10px; }
  #topbar .credit-line1 { font-size: 11px; }
  #topbar .data-date label { display: none; }
  #topbar .data-date input { min-width: 110px; }
  #topbar .speed { display: none; }
  #topbar .play-controls button { width: 34px; height: 34px; font-size: 13px; }
  #sidebar { width: 230px; }
  #main { bottom: 160px; }
  #bottombar { height: 160px; }
}

/* ============================================
   MOBILE (< 768px)  — drawer pattern
   ============================================ */
@media (max-width: 768px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  #topbar {
    height: auto; min-height: 56px;
    flex-wrap: wrap; padding: 8px 12px; gap: 8px;
  }
  #topbar .brand { flex: 0 0 auto; }
  #topbar .title .t1 { font-size: 14px; }
  #topbar .title .t2 { display: block; font-size: 10px; letter-spacing: 0.3px; color: #8a8f99; }
  #topbar .credit {
    flex-basis: 100%;
    order: 2;
    text-align: center;
    padding: 4px 8px;
    background: linear-gradient(90deg, transparent 0%, rgba(0,185,241,0.10) 50%, transparent 100%);
    border-left: none;
    border-top: 1px solid rgba(0,185,241,0.3);
    border-bottom: 1px solid rgba(0,185,241,0.3);
    border-radius: 0;
  }
  #topbar .credit-line1 { font-size: 12px; }
  #topbar .credit-line2 { font-size: 11px; }
  #topbar .data-date {
    flex-basis: 100%; flex-direction: row; align-items: center;
    margin-left: 0; gap: 6px; order: 4;
  }
  #topbar .data-date label { display: inline; font-size: 10px; }
  #topbar .data-date input { flex: 1; min-width: 0; }
  #topbar .play-controls {
    flex-basis: 100%; justify-content: center;
    flex-wrap: wrap; order: 5;
  }
  #btn-menu { order: 3; }
}

/* ============================================
   MOBILE drawer + sizing (continued from 768px block)
   ============================================ */
@media (max-width: 768px) {
  #topbar .play-controls button { width: 42px; height: 42px; font-size: 15px; }
  #topbar .play-controls button#btn-ghost { width: auto; padding: 0 12px; }

  #main {
    top: 150px; bottom: 160px;
    flex-direction: column;
  }

  /* Sidebar = right-side drawer */
  #sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    z-index: 200;
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    padding-top: 50px;
  }
  body.drawer-open #sidebar { transform: translateX(0); }

  #floating-date { font-size: 11px; padding: 4px 10px; }
  #bottombar { height: 140px; padding: 8px 10px; }
  #activity-strip { height: 95px; }
}

/* very narrow phones */
@media (max-width: 480px) {
  #topbar .title .t1 { font-size: 13px; }
  #topbar .title .t2 { font-size: 9px; }
  #topbar .logo { font-size: 24px; }
  #topbar .play-controls button { width: 38px; height: 38px; }
  #btn-menu { padding: 0 10px; }
  #btn-menu .menu-label { font-size: 11px; }
  #main { top: 160px; bottom: 130px; }
  #bottombar { height: 130px; }
  #activity-strip { height: 80px; }
  .act-bar { font-size: 8px; height: 14px; line-height: 12px; }
}
