/* =========================================================================
   Digital Bus Pass - standalone frontend clone of the eTMS bus pass screen
   Colours and metrics lifted from the decompiled eTMS APK (com.tcs.etms)
   ========================================================================= */

:root {
  --purple:        #492094;   /* toolbar                                   */
  --dark-purple:   #2c125b;   /* drawer header / status bar                */
  --primary:       #482093;   /* buttons, accents (new_primary_color)      */
  --route-a:       #2575fc;   /* route card gradient start                 */
  --route-b:       #6a11cb;   /* route card gradient end                   */
  --seat-bg:       #e2d6f9;
  --label:         #848484;
  --value:         #555555;
  --value-strong:  #262626;
  --page-bg:       #f3f3f6;
  --card-radius:   7px;
  --max-w:         480px;     /* phone column, centred on big screens      */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--page-bg);
  color: var(--value-strong);
  overflow-x: hidden;
}

/* ---- App shell -------------------------------------------------------- */
#app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-w);
  margin: 0 auto;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,.12);
  overflow: hidden;
}
@media (min-width: 481px) {
  body { padding: 0; }
  #app { min-height: 100vh; }
}

/* ---- Toolbar ---------------------------------------------------------- */
.toolbar {
  background: var(--purple);
  color: #fff;
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 20;
}
.toolbar .title {
  font-size: 18px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.icon-btn:active { background: rgba(255,255,255,.18); }
.icon-btn svg { width: 24px; height: 24px; display: block; }

/* ---- Scroll area ------------------------------------------------------ */
.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
.screen[hidden] { display: none; }

/* ---- Route card (gradient) ------------------------------------------- */
.route-card {
  margin: 16px 16px 0;
  background: linear-gradient(90deg, var(--route-a) 0%, var(--route-b) 100%);
  border-radius: var(--card-radius);
  padding: 10px 10px 12px;
  color: #fff;
  text-align: center;
}
.route-card .stop {
  font-size: 16px;
  font-weight: 700;
  padding: 10px 6px;
  word-break: break-word;
}
.route-card .route-arrow {
  display: flex;
  justify-content: center;
  padding-bottom: 8px;
}
.route-card .route-arrow svg { width: 42px; height: 24px; }
.route-times {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 16px;
  font-weight: 700;
  padding-top: 4px;
}

/* ---- White pass card -------------------------------------------------- */
.pass-card {
  margin: 10px 16px 4px;
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
  padding-bottom: 14px;
  overflow: hidden;
}
.pass-card .pass-heading {
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  color: #000;
  padding: 12px 10px 4px;
}
.dotted {
  border: 0;
  border-top: 2px dashed #d8d8d8;
  margin: 8px 8px 0;
}

/* detail grid: two columns, label over value */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  row-gap: 2px;
  padding: 6px 20px 0;
}
.detail-grid .cell { min-width: 0; padding: 10px 0 2px; }
.detail-grid .cell.right { text-align: right; }
.detail-grid .lbl {
  font-size: 15px;
  color: var(--label);
  margin-bottom: 5px;
}
.detail-grid .val {
  font-size: 16px;
  color: var(--value);
  word-break: break-word;
}
.detail-grid .val.bold { font-weight: 700; color: var(--value-strong); }

.route-name {
  text-align: center;
  font-size: 16px;
  color: var(--value);
  padding: 14px 10px 0;
}

/* bus number + seat row */
.bus-seat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px 0;
}
.bus-seat-row .bus-no .lbl { font-size: 15px; color: var(--label); margin-bottom: 4px; }
.bus-seat-row .bus-no .val { font-size: 16px; font-weight: 700; color: var(--value-strong); }
.seat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--seat-bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  border-radius: 5px;
  padding: 8px 18px;
  white-space: nowrap;
}
.seat-badge svg { width: 16px; height: 18px; }

/* QR face of the card */
.qr-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 4px;
  text-align: center;
}
.qr-face canvas, .qr-face img {
  width: 220px;
  height: 220px;
  max-width: 72%;
  image-rendering: pixelated;
}
.qr-face .qr-cap { font-size: 13px; color: var(--label); margin-top: 12px; }
.qr-face .qr-name { font-weight: 700; color: var(--value-strong); margin-top: 10px; font-size: 16px; }

/* toggle button */
.toggle-wrap { padding: 12px 16px 0; }
.toggle-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.toggle-btn:active { opacity: .9; }

/* ---- TCS logo footer -------------------------------------------------- */
.brand-footer {
  margin-top: auto;
  padding: 14px 0 12px;
  display: flex;
  justify-content: center;
}
.brand-footer img { height: 34px; width: auto; }

/* ---- Empty state ------------------------------------------------------ */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 28px;
  color: #666;
  gap: 18px;
}
.empty-state p { margin: 0; font-size: 15px; line-height: 1.5; }

/* ---- My Passes list --------------------------------------------------- */
.list-screen { padding: 14px 16px 20px; }
.list-item {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 5px rgba(0,0,0,.14);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-left: 5px solid transparent;
}
.list-item.active { border-left-color: var(--primary); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-route { font-weight: 700; font-size: 15px; color: var(--value-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 13px; color: var(--label); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px;
  background: var(--seat-bg); color: var(--primary); white-space: nowrap;
}
.li-actions { display: flex; gap: 4px; }
.li-actions .icon-btn svg { width: 20px; height: 20px; }
.li-actions .icon-btn { color: var(--primary); }
.li-actions .icon-btn.danger { color: #ed3d38; }

/* ---- Form screen ------------------------------------------------------ */
.form-screen { padding: 16px 16px 28px; }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--label);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field select {
  width: 100%;
  height: 46px;
  border: 1px solid #d9d9df;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 15px;
  color: var(--value-strong);
  background: #fff;
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(72,32,147,.14);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn {
  flex: 1;
  height: 48px;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #eceaf3; color: var(--primary); }
.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--primary);
  font-weight: 700;
  margin: 4px 0 12px;
}

/* ---- Navigation drawer ------------------------------------------------ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  z-index: 40;
}
.scrim.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 280px;
  max-width: 82%;
  background: #fff;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  background: var(--dark-purple);
  color: #fff;
  padding: 22px 18px 18px;
}
.drawer-header .dh-logo { height: 30px; margin-bottom: 14px; filter: brightness(0) invert(1); }
.drawer-header .dh-name { font-size: 16px; font-weight: 700; }
.drawer-header .dh-sub { font-size: 12.5px; opacity: .8; margin-top: 3px; }
.drawer nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.drawer nav a {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  color: #333;
  text-decoration: none;
  font-size: 15px;
  cursor: pointer;
}
.drawer nav a svg { width: 22px; height: 22px; fill: var(--dark-purple); flex: 0 0 22px; }
.drawer nav a.active { background: #f0ecf8; color: var(--primary); font-weight: 600; }
.drawer nav a.active svg { fill: var(--primary); }
.drawer nav a:active { background: #f0ecf8; }
.drawer-foot { padding: 14px 20px; font-size: 11px; color: #999; border-top: 1px solid #eee; }

/* ---- Toast ------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 11px 20px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
  max-width: 88%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
