/*
 * STYLES.CSS - GOV.UK App-Style Dashboard + Chat Interface
 *
 * Mobile-first design with dashboard views, detail cards,
 * and persistent chat — inspired by the official GOV.UK app.
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */

:root {
  /* GOV.UK Colors */
  --govuk-blue: #1d70b8;
  --govuk-dark-blue: #003078;
  --govuk-black: #0b0c0c;
  --govuk-grey-1: #f3f2f1;
  --govuk-grey-2: #b1b4b6;
  --govuk-grey-3: #505a5f;
  --govuk-yellow: #ffdd00;
  --govuk-white: #ffffff;
  --govuk-green: #00703c;
  --govuk-red: #d4351c;
  --govuk-orange: #f47738;
  --govuk-purple: #912b88;

  /* App tokens */
  --app-bg: #f5f5f7;
  --app-chat-bg: #ffffff;
  --app-user-bubble: var(--govuk-blue);
  --app-user-text: #ffffff;
  --app-agent-text: var(--govuk-black);
  --app-input-bg: #f0f0f0;
  --app-input-border: #e0e0e0;
  --app-header-height: 50px;
  --app-info-height: 28px;
  --app-input-bar-height: 56px;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-fab-size: 48px;

  /* Card tokens */
  --card-radius: 12px;
  --card-shadow: none;
  --card-shadow-active: none;

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-govuk: "GDS Transport", arial, sans-serif;

  /* Animation */
  --spring: cubic-bezier(0.25, 0.1, 0.25, 1.4);
  --ease-out: cubic-bezier(0.0, 0.0, 0.2, 1);
}

/* ============================================
   BASE RESET & APP SHELL
   ============================================ */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--app-bg);
  font-family: var(--font-system);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Hide GOV.UK default styles that conflict */
.govuk-skip-link {
  font-family: var(--font-system);
}

/* ============================================
   COMPACT GOV.UK HEADER
   ============================================ */

.app-header {
  flex-shrink: 0;
  background: var(--govuk-blue);
  color: white;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  z-index: 100;
  position: relative;
}

.app-header__inner {
  display: flex;
  align-items: center;
  height: var(--app-header-height);
  gap: 8px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.app-header__logo {
  font-family: var(--font-govuk);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}

.app-header__title {
  font-family: var(--font-govuk);
  font-size: 16px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Back button (left side of header) */
.app-header__back-btn {
  background: none;
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: -8px;
  transition: background 0.15s;
}

.app-header__back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-header__back-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Persona avatar button (right side of header) */
.app-header__persona-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--govuk-blue);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.app-header__persona-btn:active {
  border-color: rgba(255, 255, 255, 0.6);
}

/* Settings gear (kept as secondary) */
.app-header__config-btn {
  background: none;
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.app-header__config-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-header__config-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Simulation info bar */
.app-header__info {
  height: var(--app-info-height);
  font-size: 12px;
  line-height: var(--app-info-height);
  color: var(--govuk-grey-2);
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ============================================
   PERSONA DROPDOWN
   ============================================ */

.app-header__persona-dropdown {
  position: absolute;
  top: calc(var(--app-header-height) + 4px);
  right: 12px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 8px;
  z-index: 150;
  width: 280px;
  animation: dropdownIn 0.2s var(--ease-out);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.persona-dropdown__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  text-align: left;
  transition: background 0.15s;
  font-family: var(--font-system);
}

.persona-dropdown__item:hover,
.persona-dropdown__item.active {
  background: var(--govuk-grey-1);
}

.persona-dropdown__initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.persona-dropdown__info {
  flex: 1;
  min-width: 0;
}

.persona-dropdown__info strong {
  display: block;
  font-size: 14px;
  color: var(--govuk-black);
  margin-bottom: 1px;
}

.persona-dropdown__info span {
  display: block;
  font-size: 12px;
  color: var(--govuk-grey-3);
}

.persona-dropdown__divider {
  height: 1px;
  background: var(--govuk-grey-1);
  margin: 6px 12px;
}

.persona-dropdown__agent {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  font-family: var(--font-system);
  font-size: 14px;
  color: var(--govuk-grey-3);
  transition: background 0.15s;
}

.persona-dropdown__agent:hover {
  background: var(--govuk-grey-1);
}

.persona-dropdown__agent strong {
  color: var(--govuk-black);
  margin-right: auto;
}

/* ============================================
   MAIN CONTENT & VIEW SYSTEM
   ============================================ */

.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
  min-height: 0;
}

.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.view--chat {
  background: var(--app-chat-bg);
  display: flex;
  flex-direction: column;
}

/* ============================================
   PERSONA PICKER (replaces welcome screen)
   ============================================ */

.persona-picker {
  padding: 24px 16px;
  max-width: 400px;
  margin: 0 auto;
}

.persona-picker__header {
  text-align: center;
  margin-bottom: 28px;
}

.persona-picker__icon {
  margin-bottom: 16px;
}

.persona-picker__heading {
  font-family: var(--font-govuk);
  font-size: 26px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 8px;
}

.persona-picker__subtext {
  font-size: 15px;
  line-height: 1.5;
  color: var(--govuk-grey-3);
  margin: 0;
}

.persona-picker__cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.persona-card {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px;
  background: white;
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  text-align: left;
  gap: 14px;
  transition: box-shadow 0.15s, transform 0.1s;
  font-family: var(--font-system);
}

.persona-card:active {
  transform: scale(0.98);
  box-shadow: var(--card-shadow-active);
}

.persona-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.persona-card__info {
  flex: 1;
  min-width: 0;
}

.persona-card__info strong {
  display: block;
  font-size: 16px;
  color: var(--govuk-black);
  margin-bottom: 3px;
}

.persona-card__info span {
  display: block;
  font-size: 14px;
  color: var(--govuk-grey-3);
  line-height: 1.3;
}

.persona-card__chevron {
  color: var(--govuk-grey-2);
  flex-shrink: 0;
}

.persona-picker__footer {
  font-size: 12px;
  color: var(--govuk-grey-3);
  text-align: center;
  margin-top: 28px;
  line-height: 1.4;
}

/* ============================================
   DASHBOARD
   ============================================ */

.dashboard {
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.dashboard__greeting h2 {
  font-family: var(--font-govuk);
  font-size: 24px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 4px;
}

.dashboard__greeting p {
  font-size: 14px;
  color: var(--govuk-grey-3);
  margin: 0 0 20px;
}

.dashboard__services {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.service-card {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px;
  background: white;
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  text-align: left;
  gap: 14px;
  transition: box-shadow 0.15s, transform 0.1s;
  font-family: var(--font-system);
}

.service-card:active {
  transform: scale(0.98);
  box-shadow: var(--card-shadow-active);
}

.service-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.service-card--driving .service-card__icon {
  background: rgba(29, 112, 184, 0.1);
  color: var(--govuk-blue);
}

.service-card--benefits .service-card__icon {
  background: rgba(0, 112, 60, 0.1);
  color: var(--govuk-green);
}

.service-card--family .service-card__icon {
  background: rgba(145, 43, 136, 0.1);
  color: var(--govuk-purple);
}

.service-card__info {
  flex: 1;
  min-width: 0;
}

.service-card__info strong {
  display: block;
  font-size: 16px;
  color: var(--govuk-black);
  margin-bottom: 2px;
}

.service-card__count {
  font-size: 13px;
  color: var(--govuk-grey-3);
}

.service-card__chevron {
  color: var(--govuk-grey-2);
  flex-shrink: 0;
}

/* Dashboard sections */
.dashboard__section {
  margin-bottom: 24px;
}

.dashboard__section-title {
  font-family: var(--font-govuk);
  font-size: 17px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 12px;
}

.dashboard__empty {
  font-size: 14px;
  color: var(--govuk-grey-3);
  padding: 12px 0;
  margin: 0;
}

/* Coming up items */
.upcoming-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 8px;
  gap: 12px;
}

.upcoming-item__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.upcoming-item__dot--urgent { background: var(--govuk-red); }
.upcoming-item__dot--soon { background: var(--govuk-orange); }
.upcoming-item__dot--ok { background: var(--govuk-green); }

.upcoming-item__text {
  flex: 1;
  font-size: 15px;
  color: var(--govuk-black);
}

.upcoming-item__days {
  font-size: 13px;
  color: var(--govuk-grey-3);
  white-space: nowrap;
}

/* Near you items */
.nearby-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 8px;
  gap: 12px;
}

.nearby-item__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--govuk-grey-1);
  color: var(--govuk-grey-3);
}

.nearby-item__info {
  flex: 1;
  min-width: 0;
}

.nearby-item__info strong {
  display: block;
  font-size: 15px;
  color: var(--govuk-black);
  margin-bottom: 2px;
}

.nearby-item__info span {
  display: block;
  font-size: 13px;
  color: var(--govuk-grey-3);
}

/* ============================================
   DETAIL VIEW
   ============================================ */

.detail-view {
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--govuk-grey-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}

.detail-card {
  background: white;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  margin-bottom: 10px;
}

.detail-card__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--govuk-black);
  padding: 16px 16px 8px;
  margin: 0;
}

.detail-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--govuk-grey-1);
  font-size: 15px;
  gap: 12px;
}

.detail-card__label {
  color: var(--govuk-grey-3);
  flex-shrink: 0;
}

.detail-card__value {
  font-weight: 500;
  color: var(--govuk-black);
  text-align: right;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge--urgent {
  background: rgba(212, 53, 28, 0.1);
  color: var(--govuk-red);
}

.status-badge--warning {
  background: rgba(244, 119, 56, 0.1);
  color: var(--govuk-orange);
}

.status-badge--ok {
  background: rgba(0, 112, 60, 0.1);
  color: var(--govuk-green);
}

.status-badge--info {
  background: rgba(29, 112, 184, 0.1);
  color: var(--govuk-blue);
}

/* ============================================
   HERO CAROUSEL (Detail View — GOV.UK App Style)
   ============================================ */

.hero-carousel {
  margin-bottom: 28px;
}

.hero-carousel__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hero-carousel__track::-webkit-scrollbar {
  display: none;
}

.hero-carousel__card {
  flex: 0 0 calc(100% - 32px);
  min-width: 260px;
  max-width: 340px;
  background: white;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  scroll-snap-align: start;
}

/* When only 1 card, let it fill the width */
.hero-carousel__track:only-child .hero-carousel__card:only-child,
.hero-carousel__card:only-child {
  flex: 1;
  max-width: 100%;
}

.hero-carousel__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 2px;
}

.hero-carousel__subtitle {
  font-size: 14px;
  color: var(--govuk-grey-3);
  margin: 0 0 16px;
}

.hero-carousel__stats {
  display: flex;
  gap: 20px;
}

.hero-carousel__stat {
  flex: 1;
}

.hero-carousel__stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--govuk-black);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}

.hero-carousel__stat-label {
  font-size: 12px;
  color: var(--govuk-grey-3);
  margin-top: 2px;
  line-height: 1.3;
}

/* Urgency dots next to stat numbers */
.hero-carousel__stat-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hero-carousel__stat-dot--ok { background: var(--govuk-green); }
.hero-carousel__stat-dot--warning { background: var(--govuk-orange); }
.hero-carousel__stat-dot--urgent { background: var(--govuk-red); }

/* "Renew" action button inside card */
.hero-carousel__action {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-system);
  color: white;
  background: var(--govuk-blue);
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

/* Pagination row */
.hero-carousel__pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 4px 0;
  font-size: 14px;
  color: var(--govuk-grey-3);
}

.hero-carousel__arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--govuk-grey-2);
  background: white;
  font-size: 18px;
  color: var(--govuk-black);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-family: var(--font-system);
}

.hero-carousel__arrow:active {
  background: var(--govuk-grey-1);
}

/* ============================================
   DETAIL CTA BLOCK
   ============================================ */

.detail-cta {
  background: white;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 28px;
}

.detail-cta__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 12px;
}

.detail-cta__row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-cta__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-system);
  color: var(--govuk-black);
  background: white;
  border: 2px solid var(--govuk-yellow);
  border-radius: 24px;
  cursor: pointer;
}

.detail-cta__desc {
  font-size: 14px;
  color: var(--govuk-grey-3);
  margin: 0;
  line-height: 1.4;
}

/* ============================================
   TOPIC LIST (Chevron Rows)
   ============================================ */

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topic-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: white;
  font-size: 16px;
  color: var(--govuk-black);
  cursor: pointer;
  transition: background 0.1s;
}

.topic-list__item:first-child {
  border-radius: 12px 12px 0 0;
}

.topic-list__item:last-child {
  border-radius: 0 0 12px 12px;
}

.topic-list__item:only-child {
  border-radius: 12px;
}

.topic-list__item:active {
  background: var(--govuk-grey-1);
}

.topic-list__chevron {
  font-size: 20px;
  color: var(--govuk-grey-2);
  flex-shrink: 0;
  font-weight: 300;
}

/* ============================================
   MAP PLACEHOLDER (Detail View — Near You)
   ============================================ */

.detail-map {
  width: 100%;
  height: 180px;
  border-radius: 12px;
  background: var(--govuk-grey-1);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Map pin icon inside placeholder (fallback when no image) */
.detail-map::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='%23b1b4b6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
}

/* Hide fallback pin when iframe is present */
.detail-map:has(.detail-map__iframe)::after {
  display: none;
}

.detail-map__iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  pointer-events: none; /* Prevent scroll hijacking — decorative only */
}

.detail-map__label {
  font-size: 14px;
  color: var(--govuk-grey-3);
  margin: 0 0 10px;
}

/* ============================================
   DETAIL EMPTY STATE
   ============================================ */

.detail-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--govuk-grey-3);
  font-size: 15px;
}

.detail-empty__icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============================================
   CHAT MESSAGES AREA
   ============================================ */

.app-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* Agent messages: subtle, left-aligned, no heavy bubble */
.message-agent {
  align-self: flex-start;
  max-width: 92%;
  padding: 4px 2px;
  animation: messageIn 0.3s var(--ease-out) forwards;
}

.message-agent .message-text {
  font-size: 16px;
  line-height: 1.65;
  color: var(--app-agent-text);
}

/* User messages: blue bubble, right-aligned */
.message-user {
  align-self: flex-end;
  max-width: 75%;
  background: var(--app-user-bubble);
  color: var(--app-user-text);
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  animation: messageIn 0.3s var(--ease-out) forwards;
}

.message-user .message-text {
  font-size: 16px;
  line-height: 1.5;
  color: var(--app-user-text);
}

/* System messages */
.message-system {
  align-self: center;
  max-width: 85%;
  padding: 8px 16px;
  background: var(--govuk-grey-1);
  border-radius: 12px;
  text-align: center;
  animation: messageIn 0.3s var(--ease-out) forwards;
}

.message-system .message-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--govuk-grey-3);
}

/* Message text formatting */
.message-text {
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-text strong {
  font-weight: 700;
}

/* Headings inside agent messages (ChatGPT-style spacing) */
.message-text h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin: 24px 0 8px;
  color: var(--govuk-black);
}

.message-text h2:first-child {
  margin-top: 0;
}

.message-text h3 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  margin: 20px 0 6px;
  color: var(--govuk-black);
}

.message-text h3:first-child {
  margin-top: 0;
}

/* Paragraph spacing — generous vertical rhythm */
.message-text p {
  margin: 0 0 14px;
  line-height: inherit;
}

.message-text p:last-child {
  margin-bottom: 0;
}

/* "You likely have:" intro lines followed by lists — tighten gap */
.message-text p + ol,
.message-text p + ul {
  margin-top: -4px;
}

.message-text ul,
.message-text ol {
  margin: 8px 0 14px;
  padding-left: 24px;
  list-style-type: disc;
}

.message-text ol {
  list-style-type: decimal;
}

.message-text li {
  margin: 6px 0;
  padding-left: 2px;
  line-height: 1.5;
}

/* Remove stray <br> tags between list items (from markdown conversion) */
.message-text ul > br,
.message-text ol > br,
.message-text li + br,
.message-text br:has(+ li) {
  display: none;
}

/* Ensure orphaned <li> elements (not wrapped in ul/ol) still display properly */
.message-text > li {
  margin: 6px 0;
  margin-left: 24px;
  line-height: 1.5;
  display: list-item;
  list-style-type: disc;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================
   TYPING INDICATOR (Animated Dots)
   ============================================ */

.app-typing {
  display: flex;
  gap: 5px;
  padding: 8px 16px 16px;
  align-self: flex-start;
}

.app-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--govuk-grey-2);
  animation: typingBounce 1.4s infinite;
}

.app-typing span:nth-child(2) { animation-delay: 0.2s; }
.app-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ============================================
   INPUT BAR (iMessage/ChatGPT Style)
   ============================================ */

.app-input-bar {
  flex-shrink: 0;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--app-chat-bg);
  border-top: 1px solid var(--app-input-border);
}

.app-input-bar__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--app-input-bg);
  border-radius: 24px;
  padding: 6px 6px 6px 16px;
}

.app-input-bar__form textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  font-family: var(--font-system);
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  padding: 6px 0;
  color: var(--govuk-black);
}

.app-input-bar__form textarea::placeholder {
  color: var(--govuk-grey-2);
}

#send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--govuk-blue);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}

#send-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

#send-btn:not(:disabled):active {
  transform: scale(0.9);
}

/* ============================================
   FLOATING ACTION BUTTON (Reasoning)
   ============================================ */

.app-fab {
  position: fixed;
  bottom: calc(var(--app-input-bar-height) + 16px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: var(--app-fab-size);
  height: var(--app-fab-size);
  border-radius: 50%;
  border: none;
  background: var(--govuk-black);
  color: white;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 50;
  display: none !important; /* Hidden for now — capability preserved */
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.app-fab:active {
  transform: scale(0.9);
}

.app-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--govuk-yellow);
  border: 2px solid var(--govuk-black);
}

/* ============================================
   BOTTOM SHEET (iOS-style)
   ============================================ */

.app-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.app-sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.app-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--govuk-white);
  border-radius: 16px 16px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.4s var(--spring);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.app-sheet.open {
  transform: translateY(0);
}

.app-sheet__handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--govuk-grey-2);
  margin: 10px auto 16px;
}

.app-sheet__content {
  padding: 0 20px 8px;
}

.app-sheet__heading {
  font-family: var(--font-govuk);
  font-size: 22px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 20px;
}

.app-sheet__apply {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--govuk-blue);
  color: white;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: transform 0.15s, opacity 0.15s;
}

.app-sheet__apply:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.app-sheet__footer {
  font-size: 12px;
  color: var(--govuk-grey-3);
  text-align: center;
  margin-top: 20px;
  line-height: 1.4;
}

/* ============================================
   SELECTOR CARDS (Bottom Sheet)
   ============================================ */

.app-selector {
  margin-bottom: 20px;
}

.app-selector__label {
  font-size: 15px;
  font-weight: 600;
  color: var(--govuk-black);
  margin: 0 0 10px;
}

.app-selector__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-selector__card {
  cursor: pointer;
  display: block;
}

.app-selector__card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.app-selector__card-inner {
  padding: 12px 16px;
  border: 2px solid var(--app-input-border);
  border-radius: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.app-selector__card input:checked + .app-selector__card-inner {
  border-color: var(--govuk-blue);
  background: rgba(29, 112, 184, 0.06);
}

.app-selector__card-inner strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
  color: var(--govuk-black);
}

.app-selector__card-inner span {
  display: block;
  font-size: 13px;
  color: var(--govuk-grey-3);
  line-height: 1.3;
}

/* ============================================
   REASONING OVERLAY
   ============================================ */

.app-reasoning-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-out);
  padding-top: var(--app-safe-top);
}

.app-reasoning-overlay.open {
  transform: translateY(0);
}

.app-reasoning-overlay__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--app-input-border);
  flex-shrink: 0;
}

.app-reasoning-overlay__header h2 {
  font-family: var(--font-govuk);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--govuk-black);
}

.app-reasoning-overlay__header button {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--govuk-grey-3);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  line-height: 1;
}

.app-reasoning-overlay__header button:hover {
  background: var(--govuk-grey-1);
}

.app-reasoning-overlay__content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--govuk-grey-3);
}

/* ============================================
   DESKTOP ADAPTATION
   ============================================ */

@media (min-width: 768px) {
  .app-body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: -1px 0 0 var(--app-input-border), 1px 0 0 var(--app-input-border);
  }

  .app-sheet {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
  }

  .app-sheet.open {
    transform: translateX(-50%) translateY(0);
  }

  .app-reasoning-overlay {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
  }

  .app-reasoning-overlay.open {
    transform: translateX(-50%) translateY(0);
  }

  .app-fab {
    right: calc(50% - 240px + 16px);
  }
}

/* ============================================
   FOCUS STATES (Accessibility)
   ============================================ */

:focus-visible {
  outline: 3px solid var(--govuk-yellow);
  outline-offset: 2px;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   MCP / LIVE DATA INDICATORS
   ============================================ */

/* "LIVE" badge — appears on enriched dashboard items */
.live-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: var(--govuk-green);
  padding: 1px 5px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  margin-left: 4px;
}

/* "Powered by GOV.UK data" pill on chat messages */
.msg-tools-badge {
  font-size: 11px;
  color: var(--govuk-grey-3);
  padding: 6px 0 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-tools-badge svg {
  width: 14px;
  height: 14px;
  stroke: var(--govuk-blue);
  flex-shrink: 0;
}

.msg-tools-expand {
  font-size: 10px;
  color: var(--govuk-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--font-system);
}

.msg-tools-expand:hover {
  background: var(--govuk-grey-1);
}

/* Flood warning alert style */
.nearby-item--alert .nearby-item__icon {
  color: var(--govuk-red);
}

.nearby-item--alert strong {
  color: var(--govuk-red);
}

/* MCP connection toggle — tappable area around the dot */
.mcp-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.mcp-toggle:active {
  background: rgba(255,255,255,0.15);
}

/* MCP connection status dot — in header next to GOV.UK logo */
.mcp-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--govuk-red);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.mcp-status-dot--connected {
  background: var(--govuk-green);
}

.mcp-status-dot--connecting {
  background: #f4a236;
  animation: mcp-pulse 1s ease-in-out infinite;
}

@keyframes mcp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* MCP popover */
.mcp-popover {
  display: none;
  position: absolute;
  top: 52px;
  left: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15), 0 1px 4px rgba(0,0,0,0.1);
  padding: 16px;
  width: 220px;
  z-index: 1000;
  animation: mcp-popover-in 0.15s ease-out;
}

.mcp-popover--open {
  display: block;
}

@keyframes mcp-popover-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mcp-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 44px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: -1px -1px 2px rgba(0,0,0,0.06);
}

.mcp-popover__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mcp-popover__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--govuk-red);
  flex-shrink: 0;
}

.mcp-popover__dot--connected {
  background: var(--govuk-green);
}

.mcp-popover__dot--connecting {
  background: #f4a236;
  animation: mcp-pulse 1s ease-in-out infinite;
}

.mcp-popover__label {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

.mcp-popover__desc {
  font-size: 12px;
  color: #666;
  margin: 0 0 12px;
  line-height: 1.4;
}

.mcp-popover__btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mcp-popover__btn--connect {
  background: var(--govuk-blue);
  color: #fff;
}

.mcp-popover__btn--connect:active {
  background: #164e8a;
}

.mcp-popover__btn--disconnect {
  background: #f3f3f3;
  color: #555;
}

.mcp-popover__btn--disconnect:active {
  background: #e5e5e5;
}

/* ============================================
   CONVERSATION LIST (in detail views)
   ============================================ */

.conversation-item {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.conversation-item__title {
  display: block;
  font-size: 16px;
  color: var(--govuk-black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item__meta {
  display: block;
  font-size: 13px;
  color: var(--govuk-grey-3);
  margin-top: 2px;
}

.conversation-list__item {
  position: relative;
  overflow: hidden;
}

.conversation-delete-btn {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--govuk-red);
  color: white;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transform: translateX(80px);
  transition: transform 0.2s ease;
}

.conversation-list__item.swiped .conversation-delete-btn {
  display: block !important;
  transform: translateX(0);
}

.conversation-list__item.swiped .conversation-item,
.conversation-list__item.swiped .topic-list__chevron {
  transform: translateX(-80px);
  transition: transform 0.2s ease;
}

/* ============================================
   COPY BUTTON (on agent messages)
   ============================================ */

.message-agent {
  position: relative;
}

.message-copy-btn {
  position: absolute;
  top: -6px;
  right: -12px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--govuk-grey-1);
  color: var(--govuk-grey-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.message-agent:hover .message-copy-btn {
  opacity: 1;
}

/* Always visible on touch devices */
@media (hover: none) {
  .message-copy-btn {
    opacity: 0.5;
  }
}

.message-copy-btn:active {
  background: var(--govuk-grey-2);
}

.message-copy-btn--copied {
  color: var(--govuk-green);
  opacity: 1 !important;
}

/* ============================================
   SHARE BUTTON (on conversation list items)
   ============================================ */

.conversation-share-btn {
  background: none;
  border: none;
  color: var(--govuk-blue);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.conversation-share-btn:active {
  opacity: 1;
}

/* Share bar inside loaded conversations */
.chat-share-bar {
  display: flex;
  justify-content: center;
  padding: 4px 0 12px;
}

.chat-share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--govuk-blue);
  color: var(--govuk-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-share-btn:active {
  background: var(--govuk-blue);
  color: #fff;
}

.chat-share-btn svg {
  flex-shrink: 0;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.toast-notification {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0b0c0c;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   FILING PROMPT (for general conversations)
   ============================================ */

.filing-prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.filing-prompt-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.filing-prompt {
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 500px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.filing-prompt-overlay.open .filing-prompt {
  transform: translateY(0);
}

.filing-prompt__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--govuk-black);
  margin: 0 0 4px 0;
}

.filing-prompt__subtitle {
  font-size: 14px;
  color: var(--govuk-grey-3);
  margin: 0 0 16px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filing-prompt__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filing-prompt__btn {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--govuk-grey-2);
  border-radius: 12px;
  background: white;
  font-size: 16px;
  color: var(--govuk-black);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.filing-prompt__btn:active {
  background: var(--govuk-grey-1);
}

.filing-prompt__btn--secondary {
  border: none;
  background: none;
  color: var(--govuk-grey-3);
  text-align: center;
  padding: 12px 16px;
}

/* =========================================
   TASK CARDS (in-chat, after agent messages)
   ========================================= */

.task-card {
  margin: 8px 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(29, 112, 184, 0.3);
  transition: opacity 0.3s, max-height 0.3s;
}
.task-card--user { border-color: rgba(0, 112, 60, 0.3); }
.task-card--accepted { opacity: 0.7; }

.task-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.task-card__badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.task-card__badge--agent { background: #e8f0fe; color: #1d70b8; }
.task-card__badge--user  { background: #e6f4ea; color: #00703c; }

.task-card__due {
  font-size: 10px;
  font-weight: 600;
  color: #f47738;
  background: #fef3e8;
  padding: 2px 8px;
  border-radius: 10px;
}

.task-card__description {
  font-size: 14px;
  font-weight: 600;
  color: #0b0c0c;
  margin-bottom: 4px;
  line-height: 1.3;
}

.task-card__detail {
  font-size: 12px;
  color: #505a5f;
  line-height: 1.4;
  margin-bottom: 10px;
}

.task-card__actions {
  display: flex;
  gap: 8px;
}

.task-card__btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.task-card__btn--accept {
  background: #1d70b8;
  color: #fff;
}
.task-card--user .task-card__btn--accept {
  background: #00703c;
}
.task-card__btn--accept:active { opacity: 0.8; }
.task-card__btn--dismiss {
  background: #f3f2f1;
  color: #505a5f;
}
.task-card__btn--dismiss:active { background: #e0dedd; }

.task-card__accepted {
  font-size: 13px;
  font-weight: 600;
  color: #00703c;
}

/* =========================================
   DASHBOARD TASK SUMMARY
   ========================================= */

.dashboard-task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.dashboard-task-item:active { background: #f3f2f1; }

.dashboard-task-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.dashboard-task-item__dot--agent { background: #1d70b8; }
.dashboard-task-item__dot--user  { background: #00703c; }

.dashboard-task-item__content {
  flex: 1;
  min-width: 0;
}

.dashboard-task-item__title {
  font-size: 14px;
  font-weight: 600;
  color: #0b0c0c;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-task-item__meta {
  font-size: 11px;
  color: #6f7781;
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.dashboard-task-item__chevron {
  color: #b1b4b6;
  font-size: 18px;
  flex-shrink: 0;
  align-self: center;
}

.dashboard__see-all {
  display: block;
  width: 100%;
  text-align: center;
  padding: 10px;
  border: none;
  background: none;
  color: #1d70b8;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Service card task badge */
.service-card__tasks-badge {
  font-size: 11px;
  font-weight: 600;
  color: #1d70b8;
  background: #e8f0fe;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 2px;
  display: inline-block;
}

/* =========================================
   TASK DETAIL BOTTOM SHEET
   ========================================= */

.task-detail__type-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.task-detail__status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.task-detail__status-badge--suggested { background: #fef3e8; color: #f47738; }
.task-detail__status-badge--accepted  { background: #e8f0fe; color: #1d70b8; }
.task-detail__status-badge--completed { background: #e6f4ea; color: #00703c; }
.task-detail__status-badge--dismissed { background: #f3f2f1; color: #505a5f; }

.task-detail__title {
  font-size: 20px;
  font-weight: 700;
  color: #0b0c0c;
  margin-bottom: 8px;
  line-height: 1.3;
}

.task-detail__detail {
  font-size: 15px;
  color: #505a5f;
  line-height: 1.5;
  margin-bottom: 12px;
}

.task-detail__due {
  font-size: 14px;
  font-weight: 600;
  color: #f47738;
  margin-bottom: 12px;
}

.task-detail__meta {
  font-size: 12px;
  color: #6f7781;
  margin-bottom: 20px;
}

.task-detail__actions {
  display: flex;
  gap: 10px;
}

.task-detail__btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.task-detail__btn--primary {
  background: #1d70b8;
  color: #fff;
}
.task-detail__btn--primary:active { opacity: 0.8; }
.task-detail__btn--secondary {
  background: #f3f2f1;
  color: #505a5f;
}
.task-detail__btn--secondary:active { background: #e0dedd; }
.task-detail__btn--danger {
  background: #f3f2f1;
  color: #d4351c;
}
.task-detail__btn--danger:active { background: #e0dedd; }

/* =========================================
   FULL TASKS VIEW
   ========================================= */

.tasks-view {
  padding: 16px;
}

.tasks-view__filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  margin-bottom: 8px;
}

.tasks-filter-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid #b1b4b6;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #505a5f;
  cursor: pointer;
  transition: all 0.15s;
}
.tasks-filter-pill--active {
  background: #1d70b8;
  color: #fff;
  border-color: #1d70b8;
}

.tasks-view__group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6f7781;
  margin: 16px 0 8px;
}

.tasks-view__empty {
  text-align: center;
  padding: 40px 20px;
  color: #6f7781;
  font-size: 14px;
  line-height: 1.5;
}

/* Tasks in detail views — grouped container (matches topic-list style) */
.detail-tasks-section { margin-top: 24px; margin-bottom: 24px; }
.detail-tasks-section .dashboard-task-item { margin-bottom: 6px; }

.detail-tasks-section .timeline-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-tasks-section .timeline-group .timeline-item {
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
  padding: 16px;
}

.detail-tasks-section .timeline-group .timeline-item:first-child {
  border-radius: 12px 12px 0 0;
}

.detail-tasks-section .timeline-group .timeline-item:last-child {
  border-radius: 0 0 12px 12px;
}

.detail-tasks-section .timeline-group .timeline-item:only-child {
  border-radius: 12px;
}

/* =========================================
   UNIFIED TIMELINE ITEMS
   ========================================= */

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.timeline-item:active { background: #f3f2f1; }

.timeline-item__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

/* Urgency-based dots (for upcoming/reminder items) */
.timeline-item__dot--urgent { background: var(--govuk-red); }
.timeline-item__dot--soon { background: var(--govuk-orange); }
.timeline-item__dot--ok { background: var(--govuk-green); }

/* Type-based dots (for tasks) */
.timeline-item__dot--agent { background: #1d70b8; }
.timeline-item__dot--user  { background: #00703c; }

.timeline-item__content {
  flex: 1;
  min-width: 0;
}

.timeline-item__title {
  font-size: 15px;
  font-weight: 600;
  color: #0b0c0c;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-item__meta {
  font-size: 11px;
  color: #6f7781;
  margin-top: 2px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.timeline-item__due {
  font-size: 13px;
  color: #6f7781;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}

.timeline-item__chevron {
  color: #b1b4b6;
  font-size: 18px;
  flex-shrink: 0;
  align-self: center;
}

/* =========================================
   ENHANCED TASK DETAIL — Data sections
   ========================================= */

.task-detail__plan-section {
  margin-bottom: 16px;
}

.task-detail__plan-text {
  font-size: 14px;
  color: #0b0c0c;
  line-height: 1.5;
  padding: 10px 12px;
  background: #f0f4f8;
  border-radius: 8px;
  margin-top: 6px;
}

.task-detail__data-section {
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f8f8;
  border-radius: 10px;
}

.task-detail__data-section--needed {
  background: #fef3e8;
}

.task-detail__data-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6f7781;
  margin-bottom: 8px;
}

.task-detail__data-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
}

.task-detail__data-item:last-child {
  border-bottom: none;
}

.task-detail__data-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.task-detail__data-icon--available {
  background: #e6f4ea;
  color: #00703c;
}

.task-detail__data-icon--needed {
  background: #fef3e8;
  color: #f47738;
}

.task-detail__data-label {
  font-weight: 600;
  color: #0b0c0c;
  white-space: nowrap;
}

.task-detail__data-value {
  color: #505a5f;
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

/* Calendar button */
.task-detail__calendar-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #1d70b8;
  border-radius: 10px;
  background: #fff;
  color: #1d70b8;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-bottom: 16px;
  transition: background 0.15s;
}

.task-detail__calendar-btn:active {
  background: #e8f0fe;
}

/* Agent task control buttons */
.task-detail__btn--pause {
  flex: 0.6;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: #fef3e8;
  color: #f47738;
}
.task-detail__btn--pause:active { background: #fde8d0; }

.task-detail__btn--stop {
  flex: 0.6;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: #fce4e4;
  color: #d4351c;
}
.task-detail__btn--stop:active { background: #f8d0d0; }

/* Reminder badge (for upcoming items in task detail sheet) */
.task-card__badge--reminder {
  background: #f3f2f1;
  color: #505a5f;
}

/* ========================================
   TOPIC SUB-QUESTIONS SHEET
   ======================================== */
.topic-sheet__questions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.topic-sheet__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--govuk-grey-1, #f3f2f1);
  border: none;
  font-size: 15px;
  line-height: 1.4;
  color: var(--govuk-black, #0b0c0c);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  gap: 12px;
  font-family: inherit;
}

.topic-sheet__question:first-child {
  border-radius: 12px 12px 0 0;
}

.topic-sheet__question:last-child {
  border-radius: 0 0 12px 12px;
}

.topic-sheet__question:only-child {
  border-radius: 12px;
}

.topic-sheet__question:active {
  background: var(--govuk-grey-2, #b1b4b6);
}

.topic-sheet__question span:first-child {
  flex: 1;
}
