/*
 * مجلس — phone layout, for the site and every portal.
 *
 * One file, loaded after the theme, holding everything that changes below tablet width.
 * The desktop rules stay untouched; on a phone the aim is: one column, comfortable tap
 * targets (44px), less padding, nothing that overflows sideways, and the things a person
 * needs first within reach of a thumb.
 */

/* ---------- the strip of panel buttons ----------
   On a phone a row of ten wrapped buttons is a cloud nobody can scan. It becomes one
   swipeable rail: every button stays a tap away, in a fixed order, with the current
   screen highlighted. On wider screens it wraps as before. */

@media (max-width: 767.98px) {
  .majlis-strip {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.5rem !important;
    margin-inline: -14px;
    padding: 0.6rem 14px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .majlis-strip::-webkit-scrollbar {
    display: none;
  }

  .majlis-strip > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .majlis-strip .btn {
    border-radius: 999px;
    padding-inline: 0.9rem;
  }
}

/* The screen you are on, on every width. */
.majlis-strip .btn.active,
.majlis-strip .btn.active:hover {
  background-color: var(--majlis-primary);
  border-color: var(--majlis-primary);
  color: #fff;
}

/* ---------- install bar (site and portals) ---------- */

.majlis-install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--majlis-surface-2);
  border-bottom: 1px solid var(--majlis-line);
  color: var(--majlis-text);
  font-weight: 600;
  font-size: 0.92rem;
}

.majlis-install-bar[hidden] {
  display: none;
}

.majlis-install-bar .btn {
  white-space: nowrap;
  border-radius: 999px;
  background-color: var(--majlis-primary);
  border-color: var(--majlis-primary);
  color: #fff;
}

@media (min-width: 992px) {
  .majlis-install-bar:not(.majlis-push-bar) {
    display: none;
  }
}

/* The offer to turn notifications on: same bar, warmer colour, and it is the one bar that
   still belongs inside the installed app. */
.majlis-push-bar {
  background: rgba(var(--majlis-accent-rgb), 0.14);
  border-bottom-color: rgba(var(--majlis-accent-rgb), 0.4);
  color: var(--majlis-text);
}

/* "Later" is a word, not a button: none of the bar's pill styling applies to it. */
.majlis-push-bar .btn-link,
.majlis-push-bar .btn-link:hover {
  min-height: auto;
  padding: 0 0.25rem;
  border: 0;
  border-radius: 0;
  background: none !important;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--majlis-accent-text);
  text-decoration: underline;
  white-space: nowrap;
}

/* ---------- every page on a phone ---------- */

@media (max-width: 767.98px) {
  body > .container {
    padding-inline: 14px;
  }

  .majlis-navbar {
    margin-bottom: 0 !important;
  }

  .majlis-navbar .navbar-toggler {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    border: 1px solid var(--majlis-line);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
  }

  .majlis-navbar .navbar-collapse {
    padding: 0.5rem 0 0.75rem;
  }

  .majlis-navbar .navbar-nav .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.55rem 0.5rem;
  }

  .majlis-navbar .navbar-nav + .navbar-nav {
    border-top: 1px solid var(--majlis-line);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  main[role="main"] {
    padding-top: 1rem;
  }

  /* Cards and heroes: the same shapes, with phone-sized padding. */
  .majlis-card {
    padding: 1.1rem;
    border-radius: 14px;
  }

  .majlis-portal-hero {
    padding: 1.35rem 1.1rem;
    border-radius: 16px;
  }

  .majlis-portal-hero h1 {
    font-size: 1.35rem;
  }

  .majlis-list__item {
    padding: 0.9rem 1rem;
  }

  .majlis-page-head {
    margin-bottom: 1.1rem;
  }

  .majlis-page-head__actions {
    width: 100%;
  }

  .majlis-page-head__actions > *,
  .majlis-page-head__actions form .btn {
    flex: 1 1 0;
    width: 100%;
  }

  .display-6 {
    font-size: 1.6rem;
  }

  .h4, h4 {
    font-size: 1.15rem;
  }

  /* Tables scroll sideways inside their card instead of squeezing every column. */
  .majlis-card > table,
  .majlis-card > .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .table > :not(caption) > * > * {
    padding: 0.6rem 0.5rem;
  }

  /* Forms: 16px inputs so iPhone does not zoom in on focus; controls that are easy to hit. */
  .form-control,
  .form-select {
    font-size: 16px;
    min-height: 44px;
  }

  .form-check-input {
    width: 1.25em;
    height: 1.25em;
  }

  .form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .form-check .form-check-input {
    margin-top: 0;
    flex: none;
  }

  .btn:not(.btn-link),
  .btn-sm:not(.btn-link) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    padding-block: 0.5rem;
  }

  .btn.w-100,
  .d-grid > .btn {
    display: flex;
  }

  form .btn-primary.w-100,
  .majlis-auth-card .btn.w-100 {
    min-height: 48px;
    font-size: 1.05rem;
  }

  .majlis-auth-card {
    margin: 0 auto;
  }

  .alert {
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
  }

  .majlis-footer .container {
    text-align: center;
    font-size: 0.85rem;
  }
}

/* ---------- the public site on phones ---------- */

@media (max-width: 991.98px) {
  .majlis-topbar .navbar-collapse {
    padding: 0.75rem 0 0.5rem;
  }

  .majlis-topbar .navbar-nav .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid var(--majlis-line);
  }

  .majlis-topbar__actions {
    padding-top: 0.75rem;
  }

  .majlis-topbar__actions > .btn:not(.btn-icon),
  .majlis-topbar__actions > form {
    flex: 1 1 100%;
  }

  .majlis-topbar__actions form .btn {
    width: 100%;
  }
}

@media (max-width: 767.98px) {
  .majlis-topbar .container {
    padding-inline: 14px;
  }

  .majlis-hero {
    padding: 2rem 0 2.5rem;
  }

  .majlis-hero__title {
    font-size: 1.85rem;
  }

  .majlis-hero__lead {
    font-size: 1rem;
    line-height: 1.85;
    margin-bottom: 1.25rem;
  }

  .majlis-hero__actions > * {
    flex: 1 1 100%;
  }

  .majlis-hero__actions .btn,
  .majlis-hero__actions form .btn {
    width: 100%;
    min-height: 50px;
  }

  .majlis-hero__join {
    margin-top: 1.25rem;
    padding: 0.85rem;
  }

  .majlis-section {
    padding: 2.5rem 0;
  }

  .majlis-section__head {
    margin-bottom: 1.5rem;
  }

  .majlis-section__title {
    font-size: 1.45rem;
  }

  .majlis-section__lead {
    font-size: 0.95rem;
  }

  .majlis-feature {
    padding: 1.15rem;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.9rem;
  }

  .majlis-feature__icon {
    grid-row: span 2;
    margin-bottom: 0;
  }

  .majlis-plan {
    padding: 1.6rem 1.15rem 1.25rem;
  }

  .majlis-plan__period {
    min-height: 0;
  }

  .majlis-segment {
    max-width: 100%;
  }

  .majlis-segment a {
    padding-inline: 0.85rem;
    min-height: 44px;
  }

  .majlis-pay__head {
    padding: 1.2rem 1rem;
  }

  .majlis-pay__head h1 {
    font-size: 1.2rem;
  }

  .majlis-pay__body {
    padding: 1.1rem 1rem;
  }

  .majlis-price__amount {
    font-size: 1.35rem;
  }

  .majlis-code__value {
    font-size: 1.7rem;
    letter-spacing: 0.1em;
  }

  .majlis-steps-inline li {
    font-size: 0.95rem;
  }

  .majlis-site-footer {
    padding-top: 2.25rem;
    margin-top: 2rem;
  }
}

/* ---------- the phone's tab bar ----------
   Screens and "more", fixed to the bottom where a thumb rests, with a badge on the bell.
   Rendered on every page for whoever is signed in; on wider screens it does not exist. */

.majlis-tabbar {
  display: none;
}

@media (max-width: 767.98px) {
  /* The bar is fixed over the page, so the page ends above it - including the footer, which
     on the public pages comes after <main> and used to sit under the bar. */
  body.has-tabbar {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }

  body.has-tabbar .majlis-site-footer {
    margin-bottom: 0;
  }

  /* The tab bar and its "more" sheet carry every link the strip has, so the strip steps aside. */
  body.has-tabbar .majlis-strip {
    display: none !important;
  }

  .majlis-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 1030;
    background: var(--majlis-surface);
    border-top: 1px solid var(--majlis-line);
    padding: 0.3rem 0 calc(0.3rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(31, 18, 53, 0.08);
  }

  .majlis-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 52px;
    padding: 0.2rem 0;
    border: 0;
    background: none;
    color: var(--majlis-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
  }

  .majlis-tab__icon {
    position: relative;
    font-size: 1.3rem;
    line-height: 1;
  }

  .majlis-tab.active {
    color: var(--majlis-primary-text);
  }

  .majlis-tab.active .majlis-tab__icon {
    transform: translateY(-2px);
  }

  .majlis-tab__badge {
    position: absolute;
    top: -0.45rem;
    inset-inline-end: -0.8rem;
    min-width: 1.15rem;
    padding: 0.08rem 0.3rem;
    border-radius: 999px;
    background: #DC2626;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
  }

  .majlis-more {
    border-radius: 18px 18px 0 0;
  }

  .majlis-more .list-group-item {
    font-weight: 700;
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0.8rem 0.5rem;
  }

  .majlis-more .list-group-item.active {
    background: var(--majlis-primary);
    border-color: var(--majlis-primary);
  }
}

/* ---------- when running as the installed app ---------- */

@media (display-mode: standalone) {
  /* No browser chrome to fall back on: the header is the app bar, so it stays put. */
  .majlis-topbar,
  .majlis-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
  }

  .majlis-install-bar:not(.majlis-push-bar) {
    display: none !important;
  }
}

@media (max-width: 767.98px) {
  .btn-icon,
  .majlis-topbar .btn-icon {
    width: 44px;
    height: 44px;
  }
}

/* The plan comparison keeps its columns and scrolls sideways inside its own box. */
@media (max-width: 575.98px) {
  .majlis-compare .table {
    min-width: 30rem;
    font-size: 0.9rem;
  }

  .majlis-compare th,
  .majlis-compare td {
    padding: 0.65rem 0.6rem;
  }

  .majlis-compare tbody th {
    position: sticky;
    inset-inline-start: 0;
    background: var(--majlis-surface);
    z-index: 1;
  }

  .majlis-footer .container {
    justify-content: center !important;
  }
}
