/* RideUS Web -- shared components (buttons, cards, inputs, nav, modal, toast) */

/* --- Buttons: fully-rounded "pill" shape, per Theme.Radius.full -- same
   button language as BlaBlaCar reference + the iOS app. --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-sm);
  height: 48px; padding: 0 var(--space-lg);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .12s ease, opacity .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .92; }

.btn-secondary { background: var(--color-secondary); color: #fff; }

.btn-outline { background: transparent; color: var(--color-text-primary); border-color: var(--color-border); }
.btn-outline:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }

.btn-ghost { background: transparent; color: var(--color-primary); height: auto; padding: var(--space-xs) var(--space-sm); }

.btn-block { width: 100%; }
.btn-sm { height: 38px; padding: 0 var(--space-md); font-size: 14px; }
.btn-danger { background: var(--color-danger); color: #fff; }

/* --- Cards / surfaces --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}
.card-raised { background: var(--color-surface-raised); }
.card-flat { box-shadow: none; }
.card-link { display: block; transition: border-color .15s ease, transform .15s ease; }
.card-link:hover { border-color: var(--color-primary); transform: translateY(-2px); }

/* --- Inputs / pill search bar --- */
.field {
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.field label { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }
.input, select.input, textarea.input {
  width: 100%;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  height: 48px; padding: 0 var(--space-md);
  outline: none;
  transition: border-color .12s ease;
}
textarea.input { height: auto; padding: var(--space-md); resize: vertical; min-height: 96px; }
.input:focus { border-color: var(--color-primary); }
.input::placeholder { color: var(--color-text-tertiary); }

.input-error { border-color: var(--color-danger) !important; }
.error-text { color: var(--color-danger); font-size: 13px; margin-top: -4px; }

/* Pill-shaped multi-field search bar, matching the BlaBlaCar homepage search
   bar and Theme.Radius.full pill language used throughout the iOS app. */
.searchbar {
  display: flex; align-items: stretch;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
  padding: 6px;
  gap: 2px;
}
.searchbar-field {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 8px var(--space-md);
  border-radius: var(--radius-full);
  cursor: text;
  position: relative;
}
.searchbar-field:hover { background: var(--color-surface-raised); }
.searchbar-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-tertiary); }
.searchbar-field input, .searchbar-field select {
  border: 0; background: transparent; padding: 0; height: 22px; color: var(--color-text-primary); outline: none; width: 100%;
}
.searchbar-divider { width: 1px; background: var(--color-border); margin: 4px 0; }
.searchbar .btn { align-self: center; margin-left: 4px; }

/* --- City suggest (From/To autocomplete) --- */
/* Popover-under-trigger shape, matching #account-menu in chrome.js:
   absolutely positioned, toggled via `hidden` (never inline `display`, so
   base.css's global [hidden] rule always wins), sitting just under
   whichever input attachCitySuggest() was called on. */
.city-suggest-list {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  max-height: 240px; overflow-y: auto; z-index: 50; padding: 4px;
}
.city-suggest-row {
  padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; color: var(--color-text-primary);
}
.city-suggest-row:hover, .city-suggest-row.is-active { background: var(--color-surface-raised); }
.city-suggest-row strong { color: var(--color-primary); }
@media (max-width: 860px) {
  .searchbar { flex-direction: column; border-radius: var(--radius-lg); }
  .searchbar-divider { display: none; }
  .searchbar .btn { margin: 8px 4px 4px; }
}

/* --- Top navigation --- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: var(--space-lg); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 20px; flex-shrink: 0; }
.brand .brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  /* The mark's own background is near-black, which can blend into the
     site's dark-mode header -- a subtle border keeps it visually defined
     against both dark and light backgrounds. */
  border: 1px solid var(--color-border);
  object-fit: cover; flex-shrink: 0;
}
.nav-links {
  display: flex; align-items: center; gap: var(--space-lg);
  overflow-x: auto; flex-shrink: 1; min-width: 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { font-weight: 600; color: var(--color-text-secondary); font-size: 15px; white-space: nowrap; flex-shrink: 0; }
.nav-links a:hover, .nav-links a.active { color: var(--color-text-primary); }
.nav-right { display: flex; align-items: center; gap: var(--space-sm); flex-shrink: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); background: transparent; cursor: pointer; color: var(--color-text-primary);
  /* Bug fix: <button> keeps the browser's own default padding (Chrome/
     Safari ship ~1px 6px, Firefox similar) unless explicitly zeroed --
     nothing here ever reset it. That ate into this 40px box asymmetrically
     (6px off each side horizontally, 1px vertically), leaving less than
     40x40 of actual centered space -- so a fixed-size child like .avatar's
     32x32 span had no room to stay square and got flex-shrunk to a
     squished ~26x32 oval instead of a circle, and the flag emoji below
     had less centered room than its 40px box suggested, both reading as
     "doesn't fill the circle." */
  padding: 0;
}
.icon-btn:hover { border-color: var(--color-primary); }
/* Sept 2026 audit fix: the flag emoji rendered at the inherited 16px body
   font-size, leaving it small and off-center inside the 40px circle --
   same "doesn't fill its circle" complaint as the avatar photo fix above,
   just from an undersized glyph rather than a sizing bug. */
/* Flag rendering itself moved to an <img>.flag-icon (see chrome.js's
   localeTriggerIconHtml) -- position:relative + overflow:hidden here is
   what lets that image clip to this circle edge-to-edge, same technique
   as .avatar img below. font-size stays set for the emoji-fallback path
   (a non-Ghana saved locale), which still renders as inline text. */
#locale-trigger { font-size: 26px; position: relative; overflow: hidden; }
.flag-icon {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
/* Sept 2026 audit fix: the hamburger menu button reused .icon-btn as-is,
   which drew a circular border around it like the flag/account buttons --
   requested to be a plain icon with no circle. Only strips the border
   (background was already transparent); .nav-toggle's own display:none /
   display:flex responsive toggle above is untouched. */
.nav-toggle { border: none; }

/* On narrow viewports the full link row doesn't fit next to the flag/
   auth buttons (it would squeeze down to an unreadable sliver), so it's
   swapped for a single hamburger button that opens #mobile-menu instead.
   .nav-toggle's visibility is pure responsive CSS (a media query), never
   tied to the [hidden] attribute, so it can't collide with it. #mobile-menu
   itself intentionally has NO `display` declared anywhere below (including
   inside media queries) -- it relies on the default block display when the
   `hidden` attribute is absent and the browser's built-in
   `[hidden]{display:none}` rule when it's present. That absence is
   deliberate: an earlier version of this menu set `display:flex` on the
   panel unconditionally, which -- because author-origin CSS always beats
   the UA-origin [hidden] rule -- made the menu render open at every
   viewport width regardless of the `hidden` attribute. Do not add a
   `display` value to #mobile-menu; toggle it only via the `hidden`
   property in JS (see chrome.js). */
.nav-toggle { display: none; }
#mobile-menu {
  position: absolute; top: 100%; right: var(--space-lg);
  margin-top: 8px; min-width: 220px; max-width: calc(100vw - 2 * var(--space-lg));
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 8px; z-index: 50;
}
#mobile-menu a { display: block; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 600; color: var(--color-text-secondary); }
#mobile-menu a:hover, #mobile-menu a.active { background: var(--color-surface-raised); color: var(--color-text-primary); }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
}
@media (max-width: 640px) {
  .nav-links { gap: var(--space-md); }
}

.avatar {
  position: relative;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--color-surface-raised); border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; overflow: hidden; color: var(--color-text-primary);
  /* Defensive hardening alongside the .icon-btn padding fix above -- an
     .avatar is always used as a flex child (here inside .icon-btn, also
     in header-avatar-name rows elsewhere), and a flex child shrinks below
     its own width by default whenever its flex parent runs short on
     space. flex-shrink:0 makes that impossible regardless of what any
     future parent does, so this can't quietly turn oval again the way
     the padding bug above just did. */
  flex-shrink: 0;
}
/* Sept 2026 audit fix: was `width:100%; height:100%; object-fit:cover`,
   which sizes the <img> as a flex item of .avatar -- on a tall/portrait
   source photo, some mobile browsers resolve that flex item's width from
   its intrinsic aspect ratio instead of the container's box, leaving a
   narrower oval that doesn't reach the circle's left/right edges. Taking
   the image out of flex flow with absolute positioning against .avatar's
   own box (now `position: relative`) sizes it purely from that box, with
   no flex-item sizing ambiguity possible. */
.avatar img { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; object-fit: cover; }

/* --- Badges / pills / status chips --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
  background: var(--color-surface-raised); color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.badge-primary { background: rgba(var(--color-primary-rgb), .14); color: var(--color-primary); border-color: transparent; }
.badge-secondary { background: rgba(var(--color-secondary-rgb), .14); color: var(--color-secondary); border-color: transparent; }
.badge-success { background: rgba(26,127,55,.14); color: var(--color-success); border-color: transparent; }
.badge-warning { background: rgba(184,134,11,.14); color: var(--color-warning); border-color: transparent; }
.badge-danger { background: rgba(192,57,43,.14); color: var(--color-danger); border-color: transparent; }

.dot-unread {
  width: 9px; height: 9px; border-radius: var(--radius-full);
  background: var(--color-secondary); display: inline-block;
}

/* --- Modal (used for the country/language picker, auth prompts, etc.) --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh var(--space-md); z-index: 100; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-xl); width: 100%; max-width: 760px;
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
}
.modal-close {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-primary); color: var(--color-primary);
  background: transparent; cursor: pointer; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.modal-sm { max-width: 440px; }

/* --- Toast --- */
#toast-root { position: fixed; bottom: var(--space-lg); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--color-surface-raised); border: 1px solid var(--color-border);
  color: var(--color-text-primary); padding: 12px 20px; border-radius: var(--radius-full);
  box-shadow: var(--shadow-card); font-size: 14px; font-weight: 600;
  animation: toast-in .18s ease;
}
.toast-error { border-color: var(--color-danger); color: var(--color-danger); }
.toast-success { border-color: var(--color-success); color: var(--color-success); }
@keyframes toast-in { from { opacity:0; transform: translateY(8px);} to { opacity:1; transform:none; } }

/* --- Feature tiles ("How are you travelling today?") --- */
.travel-tile {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-lg);
}
.travel-tile-icon {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: rgba(var(--color-primary-rgb), .14); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0;
}
.travel-tile-arrow {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* --- Empty / loading states --- */
.empty-state { text-align: center; padding: var(--space-xxl) var(--space-lg); color: var(--color-text-secondary); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--color-border); border-top-color: var(--color-primary);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-raised) 25%, var(--color-border) 37%, var(--color-surface-raised) 63%);
  background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: var(--radius-md);
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--color-border); padding: var(--space-xxl) 0 var(--space-lg); margin-top: var(--space-xxl); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--space-xl); }
.footer-grid h4 { color: var(--color-text-secondary); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.footer-grid a { display: block; color: var(--color-text-secondary); padding: 4px 0; font-size: 14px; }
.footer-grid a:hover { color: var(--color-text-primary); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid var(--color-border); flex-wrap: wrap; gap: var(--space-sm); }

/* Plain (non-circular) social icons -- lives at the bottom of the "Find out
   more" column in the home page's routes-section (see index.html), not in
   the footer. Deliberately no border/background/border-radius: earlier this
   reused .icon-btn as-is, which drew a circular pill around each glyph;
   here it's just the bare icon so it reads as part of the link column
   rather than a separate button row. */
.social-links { display: flex; gap: 16px; margin-top: var(--space-sm); }
.social-links .icon-btn {
  width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  color: var(--color-text-secondary);
}
.social-links .icon-btn:hover { color: var(--color-text-primary); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* --- Tabs (used on account page) --- */
/* Sept 2026 audit fix: min-width: 0 alongside overflow-x: auto -- without
   it, a .tabbar nested in a flex/grid ancestor can still be sized to its
   un-wrapped .tab buttons' full min-content width (see the matching
   .account-grid fix in pages.css) instead of the space actually available,
   which is what overflow-x: auto needs in order to have anything to scroll
   within. */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-lg); overflow-x: auto; min-width: 0; }
.tab {
  padding: var(--space-sm) var(--space-md); font-weight: 700; color: var(--color-text-secondary);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-left:0;border-right:0;border-top:0;
}
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* --- Country/language picker grid --- */
.locale-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 60vh; overflow-y: auto; margin-top: var(--space-lg); }
.locale-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: 10px 12px; border-radius: var(--radius-md); cursor: pointer; border: 1px solid transparent;
}
.locale-row:hover { background: var(--color-surface-raised); }
.locale-row.is-active { border-color: var(--color-primary); background: rgba(var(--color-primary-rgb), .1); }
.locale-row .flag { font-size: 22px; margin-right: 6px; }
.locale-row .name { font-weight: 700; font-size: 14px; }
.locale-row .lang { color: var(--color-text-secondary); font-size: 13px; }
@media (max-width: 600px) { .locale-grid { grid-template-columns: 1fr; } }
