/* ============================================================
   Desktop / tablet layout layer
   ------------------------------------------------------------
   The app shell was built mobile-first and never constrained: neither
   #page-wrapper nor #main-content had a max-width, so on a desktop monitor
   every page was the phone layout stretched edge to edge, with the mobile
   bottom tab bar still pinned across the bottom.

   This file only ADDS breakpoints. Everything below 768px is deliberately
   untouched, because the mobile UI is already correct.

   LOAD ORDER MATTERS: this must be the last stylesheet in <head>, after
   base.html's own inline <style>, or the rules here lose on document order
   at equal specificity.

   NOTE: edits here are not live until `manage.py collectstatic` is run.
   StaticMediaMiddleware serves /static/ only out of STATIC_ROOT
   (staticfiles/) and never falls back to static/, DEBUG or not.
   ============================================================ */


/* ------------------------------------------------------------
   1. Content column
   Gives the page a real measure instead of letting it span a 27" screen.
   Widths track Bootstrap's container scale so anything inside that already
   uses .container lines up rather than nesting two different rhythms.
   ------------------------------------------------------------ */
@media (min-width: 768px) {
  #main-content {
    width: 100%;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 992px) {
  #main-content { max-width: 940px; }
}

@media (min-width: 1200px) {
  #main-content { max-width: 1140px; }
}

@media (min-width: 1400px) {
  #main-content { max-width: 1296px; }
}

/* Escape hatch for sections that genuinely want to run edge to edge on a
   wide screen - a hero, a full-width slider. Add class="full-bleed" to the
   section and it breaks back out of the column above. */
@media (min-width: 768px) {
  #main-content .full-bleed {
    width: 100vw;
    max-width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
  }
}


/* ------------------------------------------------------------
   2. The bottom tab bar is a phone pattern
   Hidden from 992px up, where the offcanvas sidebar (header hamburger ->
   #sidebarMenu, 22 links) and the header icons already cover navigation, so
   nothing becomes unreachable.

   !important is load-bearing here: bottom_bar.html ships its own <style>
   block inside the BODY, which comes after this file in document order and
   would otherwise win at equal specificity.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  .custom-navbar {
    display: none !important;
  }

  /* base.html reserves 50px under the content for the bar; reclaim it, and
     drop the bar's own pb-5 spacer. */
  #main-content {
    margin-bottom: 24px !important;
  }

  #page-wrapper > .container-fluid.pb-5 {
    padding-bottom: 0 !important;
  }
}


/* ------------------------------------------------------------
   3. Fixed header tracks the same column
   The bar itself stays full width (it is a background), but its contents
   line up with the page instead of being pinned to the screen edges.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  .jh-navbar > .container-fluid {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 1200px) {
  .jh-navbar > .container-fluid { max-width: 1140px; }
}

@media (min-width: 1400px) {
  .jh-navbar > .container-fluid { max-width: 1296px; }
}


/* ------------------------------------------------------------
   4. Pointer-sized affordances
   Phone tap targets are tuned for thumbs; on a mouse the same spacing reads
   as cramped, and hover states are worth having.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  .jh-nav-link { padding: 0 14px; }
  .jh-nav-label { font-size: 10px; }
  .username-txt { font-size: 14px; }
  .userid-txt { font-size: 11px; }

  /* Cards lift slightly under a cursor - a desktop-only cue, so it cannot
     leave a stuck :hover state on a touch device. */
  #main-content .card {
    transition: box-shadow .18s ease, transform .18s ease;
  }
  #main-content .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 23, 42, .10);
  }
}


/* ------------------------------------------------------------
   5. Wide-screen guards
   Two things that look fine on a phone and wrong on a monitor: media that
   scales past its natural size, and tables that force the page to scroll
   sideways.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content img,
  #main-content video {
    max-width: 100%;
    height: auto;
  }

  #main-content .table-responsive {
    overflow-x: auto;
  }
}


/* ============================================================
   PAGE LAYERS
   ------------------------------------------------------------
   Sections 1-5 only give the shell a measure. That alone leaves the inner
   pages as a phone layout in a narrower box: the grids are pinned to a fixed
   mobile column count, and the vertical rhythm is tuned for a 390px screen,
   both inside <style> blocks the templates ship themselves.

   Every selector here is prefixed with #main-content on purpose. Those
   template <style> blocks live in the BODY (includes/pay_bill_category.html,
   includes/recharge-app.html and ecommerce/products/products_home.html each
   carry a nested <head>, which the parser hoists into the body), so they come
   AFTER this file in document order and would win any tie at equal
   specificity. The id prefix decides it on specificity instead.

   Where a rule fights a Bootstrap spacing utility (.py-4, .mb-4) it needs
   !important, because those utilities carry !important themselves. Those are
   the only !important declarations below, and each is marked.

   Still min-width only: below 768px nothing here applies.
   ============================================================ */


/* ------------------------------------------------------------
   6. Pay Bills / Home - the top band
   Shared by includes/pay_bill_category.html and includes/recharge-app.html,
   which have the same body structure:

     .container.mb-1.mt-4
       > .row.g-3        - four quick-action tiles
       > .wallets        - two balance cards
       > .premium-divider

   Stacked, that is right on a phone and wrong on a monitor: four tiles
   shrink to a thin strip while the two wallets become 630px slabs carrying
   three words each. On desktop the band becomes two columns instead - the
   tiles as a 2x2 block on the left, the wallets stacked down the right - so
   both halves carry their weight and the row has no dead middle.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content .container.mb-1.mt-4 {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
    column-gap: 26px;
    align-items: stretch;
    /* Zeroed so the band's outer edges line up with the services panel
       below it: .row keeps its -12px gutter margin and the columns their
       +12px padding, which cancel out only if the container adds none. */
    padding-left: 0;
    padding-right: 0;
  }

  #main-content .container.mb-1.mt-4 > .row {
    grid-column: 1;
    grid-row: 1;
  }

  /* 4 tiles across a half-width column would be a strip; 2x2 fills it. */
  #main-content .container.mb-1.mt-4 > .row > [class*="col-"] {
    width: 50%;
  }

  #main-content .container.mb-1.mt-4 > .wallets {
    grid-column: 2;
    grid-row: 1;
    flex-direction: column;
    gap: 16px;
    margin: 0;
  }

  /* Stretch the two cards to exactly match the height of the 2x2 block
     beside them, whatever that turns out to be. */
  #main-content .container.mb-1.mt-4 > .wallets > a {
    display: flex;
    flex: 1;
  }

  #main-content .container.mb-1.mt-4 > .premium-divider {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 26px 0 6px;
  }

  #main-content .action-card {
    min-height: 88px;
    padding: 14px 16px;
    gap: 14px;
  }

  #main-content .action-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
  }
}


/* ------------------------------------------------------------
   7. Pay Bills / Home - wallet cards
   On a phone these stack label / amount / full-width button. In a ~570px
   column that shape leaves a hole in the middle, so the text goes left and
   the action anchors right, on one line.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content .wallet {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 20px;
    padding: 20px 24px;
    border-radius: 20px;
  }

  #main-content .wallet-title {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 2px;
    font-size: 13px;
    letter-spacing: .2px;
  }

  #main-content .wallet-amount {
    grid-column: 1;
    grid-row: 2;
    margin-bottom: 0;
  }

  #main-content .wallet .main-amount {
    font-size: 1.7rem;
    margin: 2px 0 0;
  }

  /* Button spans both text rows, so it centres against the block instead of
     stretching to the full card width. */
  #main-content .wallet .add-money-btn {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: auto;
    padding: 11px 22px;
    white-space: nowrap;
    transition: transform .18s ease, filter .18s ease;
  }

  #main-content .wallet .add-money-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
  }

  /* On the amber card the button was #fcd9a3 on a #e09a2c gradient - two
     close values, so the control barely read as a control. Lifting it to
     near-white puts real contrast behind the label. */
  #main-content .wallet.service .add-money-btn {
    background: #fffaf0;
    color: #7a4e12;
    box-shadow: 0 2px 10px rgba(120, 74, 16, .18);
  }
}


/* ------------------------------------------------------------
   8. Pay Bills / Home - section header
   The header sits in its own .container.py-4 above the services panel, and
   between that padding, .top-nav's own margin and .mb-4 there was roughly
   110px of air holding a single line of text. Tighten it and let the title
   carry the hierarchy instead.

   !important: .py-4 / .mb-4 are Bootstrap utilities and ship !important.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content .container.py-4:not(.bg-white) {
    padding-top: 1.25rem !important;
    padding-bottom: 0 !important;
  }

  #main-content .top-nav {
    align-items: center;
    margin-bottom: 14px !important;
  }

  #main-content .nav-title {
    font-size: 22px;
    letter-spacing: -.2px;
  }

  #main-content .brand-logo {
    height: 58px;
  }
}


/* ------------------------------------------------------------
   9. Pay Bills / Home - the services grid
   This is the whole point of the page, so it gets the most room.

   The templates pin .qs-grid to repeat(4, 1fr) at every width: on a monitor
   that is four 46px icons adrift in four ~300px columns. Track the measure
   instead, and give each service a real tile with an edge and a hover state
   so the grid reads as a set of targets rather than scattered dots.
   ------------------------------------------------------------ */
@media (min-width: 768px) {
  /* Column counts are chosen to divide the actual service counts evenly -
     12 visible tiles and 24 under "More" - so no row is left ragged:
     4 across gives 3 and 6 rows, 6 across gives 2 and 4. */
  #main-content .qs-grid,
  #main-content .qs-grid-extra {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  /* Tiles. The label is a bare text node next to .quick-icon, so the tile is
     .qs-item itself - centred, fixed height so one- and two-line labels line
     up across the row. */
  #main-content .qs-item {
    min-height: 122px;
    justify-content: center;
    gap: 10px;
    padding: 16px 8px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: #f7f9fc;
    font-size: 12px;
    line-height: 1.35;
    color: #1f2937;
    transition: transform .2s ease, box-shadow .2s ease,
                background .2s ease, border-color .2s ease;
  }

  /* Hover, not :active - .qs-item covers both the linked services and the
     unlinked "More" toggle, so this must not depend on the anchor. */
  #main-content .qs-item:hover {
    transform: translateY(-3px);
    background: #fff;
    border-color: #e3e8f2;
    box-shadow: 0 10px 24px rgba(22, 35, 92, .10);
  }

  #main-content .quick-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 22px;
  }

  /* The template animates .quick-icon on :active for touch; on a pointer the
     whole tile already moves, so keep the icon still. */
  #main-content .qs-item:active .quick-icon {
    transform: none;
  }

  /* The panel holding the grid. Padding is a Bootstrap .py-4 utility. */
  #main-content .container.py-4.rounded-4 {
    padding-top: 26px !important;
    padding-bottom: 30px !important;
    border: 1px solid #eef1f6;
    box-shadow: 0 6px 24px rgba(15, 23, 42, .05);
  }

  /* The dashed rule the expanded grid draws above itself. */
  #main-content .qs-grid-extra.show {
    margin-top: 20px;
    padding-top: 20px;
  }
}

@media (min-width: 992px) {
  #main-content .qs-grid,
  #main-content .qs-grid-extra {
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
  }
}


/* ------------------------------------------------------------
   10. Shopping / Business - wallet summary cards
   ecommerce/products/products_home.html gives .fund-card a 160px min-height
   and a 32px figure, tuned for a ~170px-wide phone card. At half of a wide
   row the same card reads as an oversized slab, so flatten it.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content .fund-card {
    min-height: 132px;
    padding: 22px 26px;
  }

  #main-content .fund-val {
    font-size: 26px;
  }

  #main-content .fund-grid {
    gap: 20px;
  }
}


/* ------------------------------------------------------------
   11. Cashback wallet has no action
   The Add Money button was removed from that card - cashback is earned, not
   topped up - so the right-hand column now carries a caption instead. It has
   to sit where the button did or the card looks unfinished.
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  #main-content .wallet .wallet-note {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    max-width: 150px;
    text-align: right;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.35;
    color: rgba(255, 255, 255, .72);
  }
}
