/* ===========================================================
   BUS Advisor PWA — App-level styles
   Designed to be linked AFTER colors_and_type.css.
   These styles target the existing PWA template structure
   (#top-bar, #main-content, #bottom-menu) and the per-component
   class names already in your templates.
   =========================================================== */

/* --- Reset / base ------------------------------------------ */
* { box-sizing: border-box; }
html {
  height: 100%;
  background: var(--neutral-5);
}
body {
  margin: 0 auto;
  max-width: 430px;
  min-height: 100dvh;
  font: var(--type-body);
  color: var(--secondary-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
}
a { color: var(--orange-1); text-decoration: none; }
a:active { color: var(--orange-2); }
button { font: inherit; }

#top-bar {
  background: var(--secondary-1);
  color: #fff;
  padding: 0;
  height: var(--title-bar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 var(--neutral-5);
}

#main-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
}

#bottom-menu {
  background: #fff;
  color: var(--secondary-1);
  padding: 0;
  height: var(--menu-bar-h);
  border-top: 1px solid var(--neutral-5);
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ============================================================
   COMPONENT: Title bar (templates/components/titlebar.html)
   ============================================================ */
.titlebar {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 12px;
}
.titlebar-label {
  flex: 1;
  text-align: center;
  font: var(--type-h2);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.titlebar-menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}
.titlebar-menu-btn:active { background: rgba(255, 255, 255, 0.08); }

/* Menu dialog */
#menu-dialog {
  border: none;
  border-radius: 0;
  padding: 0;
  width: min(280px, 85vw);
  box-shadow: var(--shadow-pop);
  color: var(--secondary-1);
}
#menu-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

.menu-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--neutral-5);
  background: var(--secondary-1);
  color: #fff;
}
.menu-dialog-title {
  font: var(--type-h3);
  text-transform: uppercase;
  margin: 0;
  color: #fff;
}
.menu-dialog-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #fff;
  line-height: 1;
  padding: 0;
}
.menu-dialog-body { padding: 8px 0; }

.menu-item {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--secondary-1);
  font: var(--type-body-lg);
  border-bottom: 1px solid var(--neutral-5);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--neutral-6); }

/* ============================================================
   COMPONENT: Footer / bottom menu (footerbar.html)
   ============================================================ */
#bottom-menu a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--secondary-1);
  text-decoration: none;
}
#bottom-menu a:active { background: var(--neutral-6); }
.footerbar-label {
  display: block;
  width: 100%;
  text-align: center;
  font: var(--type-button);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--secondary-1);
}

/* ============================================================
   COMPONENT: Search bar (searchbar.html)
   ============================================================ */
.searchbar {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 100%;
  background: var(--secondary-1);
  border: none;
  border-radius: 0;
}
.searchbar .search-input {
  display: flex;
  align-items: center;
  flex: 1;
  padding: 0 12px;
  background: #fff;
  margin: 6px;
  border: 1px solid var(--neutral-3);
  box-shadow: var(--shadow-input);
}
.search-icon { margin-right: 8px; color: var(--neutral-2); display: flex; }
.search-input input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font: var(--type-body);
  color: var(--secondary-1);
}
.search-input input::placeholder { color: var(--neutral-3); }

.region-select {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #fff;
}
.region-select img {
  width: 24px;
  height: 16px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.dropdown-arrow { color: rgba(255, 255, 255, 0.85); font-size: 12px; }

#region-dialog {
  border: none;
  border-radius: 0;
  padding: 0;
  width: min(360px, 92vw);
  box-shadow: var(--shadow-pop);
}
#region-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.region-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--neutral-5);
  background: var(--secondary-1);
  color: #fff;
}
.region-dialog-title { font: var(--type-h3); text-transform: uppercase; margin: 0; color: #fff; }
.region-dialog-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #fff; }
.region-dialog-body { padding: 12px; max-height: 60vh; overflow-y: auto; }

/* ============================================================
   COMPONENT: Breadcrumbs (breadcrumbs.html)
   Wraps the existing structure. Replace inline <style>.
   ============================================================ */
.breadcrumbs {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--neutral-6);
  border-bottom: 1px solid var(--neutral-5);
  gap: 2px;
  margin: -12px -12px 12px;
}
.breadcrumb-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.breadcrumb-label {
  font: var(--type-eyebrow);
  font-size: 10px;
  line-height: 12px;
  text-transform: uppercase;
  color: var(--neutral-2);
  letter-spacing: 0.04em;
}
.breadcrumb-value {
  font: var(--type-body-sm);
  font-family: var(--font-body-bold);
  color: var(--secondary-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-value.placeholder {
  color: var(--neutral-3);
  font-family: var(--font-body);
}
.breadcrumb-separator {
  color: var(--neutral-3);
  font-size: 16px;
  padding: 0 4px;
  flex-shrink: 0;
  align-self: center;
}

/* ============================================================
   COMPONENT: Sector tiles (home/sectors)  — sector.html
   The original .tile class is used with background-image.
   ============================================================ */
.tile {
  height: 140px;
  border-radius: 0;
  margin-bottom: 10px;
  background-color: var(--neutral-6);
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-card);
}
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(36, 23, 112, 0) 50%, rgba(36, 23, 112, 0.78) 100%);
}
.tile span {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
}
.tile span a {
  display: block;
  color: #fff;
  font: var(--type-h3);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ============================================================
   COMPONENT: Profession tiles (profession_list/tile.html)
   ============================================================ */
.profession-list,
.speciality-list { display: flex; flex-direction: column; gap: 0; }

.profession-tile,
.speciality-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: none;
  border-bottom: 1px solid var(--neutral-5);
  border-radius: 0;
  text-decoration: none;
  color: inherit;
  margin: 0;
}
.profession-tile:active,
.speciality-tile:active { background: var(--neutral-6); }

.profession-image,
.speciality-image {
  width: 56px;
  height: 56px;
  border-radius: 0;
  object-fit: cover;
  background: var(--neutral-6);
  flex-shrink: 0;
}

.profession-title,
.speciality-title {
  flex: 1;
  font: var(--type-h4);
  color: var(--secondary-1);
  font-family: var(--font-display);
  text-transform: none;
}

.profession-arrow,
.speciality-arrow,
.course-arrow {
  font-size: 22px;
  color: var(--neutral-3);
  flex-shrink: 0;
}

/* ============================================================
   COMPONENT: Course list / tile (courses_list / course_tile)
   ============================================================ */
.course-list { display: flex; flex-direction: column; gap: 10px; }

.course-tile {
  display: flex;
  align-items: center;
  padding: 14px 80px 14px 14px;
  position: relative;
  background: #fff;
  border-radius: 0;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  min-height: 70px;
}
.course-tile:active { filter: brightness(0.97); }

.course-name {
  flex: 1;
  font: var(--type-h3);
  color: var(--primary-1);
}

.course-provider-logo {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 70px;
  margin: 0;
  padding: 6px;
  background: var(--neutral-6);
  object-fit: contain;
  flex-shrink: 0;
}

/* ============================================================
   COMPONENT: Course details (course_details.html)
   ============================================================ */
.course-details-header {
  background: var(--primary-1);
  padding: 24px 16px;
  text-align: left;
  margin: -12px -12px 16px;
  color: #fff;
}
.course-details-name {
  font: var(--type-h1);
  color: #fff;
  margin: 0;
}
.course-details-body { padding: 0 4px 20px; }
.course-details-description {
  font: var(--type-body-lg);
  color: var(--secondary-1);
}
.course-details-footer {
  padding: 20px 0;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--neutral-5);
  margin-top: 20px;
}
.course-details-provider-logo {
  max-width: 160px;
  max-height: 80px;
  object-fit: contain;
}

/* ============================================================
   COMPONENT: Search results list (search_results_list.html)
   ============================================================ */
.search-results { display: flex; flex-direction: column; gap: 20px; }
.search-section-heading {
  font: var(--type-eyebrow);
  text-transform: uppercase;
  color: var(--neutral-2);
  letter-spacing: 0.04em;
  margin: 0 0 8px 0;
  padding: 0 4px;
}
.search-empty {
  text-align: center;
  color: var(--neutral-2);
  font: var(--type-body-lg);
  padding: 40px 0;
}

/* ============================================================
   COMPONENT: Region picker (regions.html, region.html)
   ============================================================ */
.region-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 0;
  border-bottom: 1px solid var(--neutral-5);
  background: #fff;
  border-radius: 0;
  text-decoration: none;
  color: var(--secondary-1);
  cursor: pointer;
}
.region-tile:active { background: var(--neutral-6); }
.region-flag {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border: 1px solid var(--neutral-5);
  border-radius: 0;
}
.region-name { font: var(--type-body-lg); color: var(--secondary-1); }

/* ============================================================
   COMPONENT: About page — body
   ============================================================ */
.about-text {
  font: var(--type-body-lg);
  color: var(--secondary-1);
  text-align: center;
  max-width: 360px;
}

/* ============================================================
   Generic primitive: button (use anywhere a CTA is needed)
   ============================================================ */
.bus-btn {
  background: var(--primary-1);
  color: #fff;
  border: none;
  padding: 11px 16px;
  font: var(--type-button);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  outline: none;
  border-radius: 0;
  min-height: 44px;
  min-width: 110px;
}
.bus-btn--secondary { background: var(--secondary-1); }
.bus-btn--transparent {
  background: transparent;
  color: var(--secondary-1);
  border: 1px solid var(--secondary-1);
  box-shadow: none;
}
.bus-btn[disabled] { opacity: 0.6; cursor: default; }
