/* ==========================================================================
   AjonTec — frontend fixes
   --------------------------------------------------------------------------
   Loaded after style.css, meanmenu.css and ats-enhance.css, so it wins on
   equal specificity. Two problems are fixed here.

   1. MOBILE MENU OPENED DOWNWARD
      The theme already has a proper right-hand drawer (.sidebar-area), and
      the hamburger (#openButton) slides it in correctly. MeanMenu is injected
      into .mobile-menu INSIDE that drawer -- and MeanMenu hides its own list
      and adds a SECOND hamburger to reveal it.

      So the real behaviour was: tap hamburger -> drawer slides in from the
      right, but appears almost empty -> tap a second hamburger inside ->
      the links slide DOWN from the top of the drawer. That downward slide is
      what looked like "the menu opens from the top".

      Fix: drop MeanMenu's redundant reveal button and keep the first-level
      list permanently visible inside the drawer. Sub-menus keep their
      expand/collapse, which is still useful.

   2. DARK MODE LEFT WHITE PATCHES
      Dark mode is driven by [data-theme=dark_mode] on <html>, which only
      re-points CSS variables. ats-enhance.css sets `background:#fff !important`
      on seven blocks, so in dark mode those stayed bright white against a dark
      page. Those seven are re-pointed at variables below.

   Nothing here changes layout geometry outside the mobile drawer.
   ========================================================================== */


/* ==========================================================================
   1. MOBILE MENU — inside the drawer, no second hamburger
   ========================================================================== */

@media (max-width: 991px) {

    /* MeanMenu's own reveal button is redundant: the drawer has #openButton
       to open it and #closeButton to close it. A second hamburger inside an
       already-open panel just reads as broken. */
    .sidebar-area .mean-container a.meanmenu-reveal {
        display: none !important;
    }

    /* MeanMenu calls .hide() on the list, which writes inline display:none.
       Only !important can beat an inline style. Scoped to the first level so
       nested sub-menus still open and close on tap. */
    .sidebar-area .mean-container .mean-nav > ul {
        display: block !important;
    }

    /* The bar is a wrapper here, not a visible toolbar. */
    .sidebar-area .mean-container .mean-bar {
        background: transparent !important;
        padding: 0 !important;
        min-height: 0 !important;
        float: none !important;
        z-index: auto !important;
    }

    .sidebar-area .mean-container .mean-nav {
        float: none !important;
        width: 100% !important;
        margin: 0 !important;
        background: transparent !important;
    }

    /* Readable list inside a dark drawer. */
    .sidebar-area .mean-container .mean-nav ul li {
        float: none !important;
        width: 100% !important;
        border-top: 1px solid rgba(255, 255, 255, .10);
    }

    .sidebar-area .mean-container .mean-nav ul li a {
        display: block;
        width: 100% !important;
        padding: 13px 4px !important;
        color: #fff !important;
        font-size: 15px;
        font-weight: 500;
        border-top: 0 !important;
        text-transform: none;
    }

    .sidebar-area .mean-container .mean-nav ul li a:hover,
    .sidebar-area .mean-container .mean-nav ul li a:focus-visible {
        color: var(--primary-color, #1e3a8a) !important;
    }

    /* Sub-menu items, one step in so the hierarchy is visible. */
    .sidebar-area .mean-container .mean-nav ul li li a {
        padding-left: 20px !important;
        font-size: 14px;
        opacity: .85;
    }

    /* The +/- control for sub-menus. */
    .sidebar-area .mean-container .mean-nav ul li a.mean-expand {
        width: 42px !important;
        height: 44px !important;
        padding: 0 !important;
        line-height: 44px !important;
        text-align: center;
        border: 0 !important;
        background: rgba(255, 255, 255, .06) !important;
        border-radius: 6px;
        top: 0;
    }

    .sidebar-area .mean-container .mean-nav ul li a.mean-expand:hover {
        background: rgba(255, 255, 255, .14) !important;
    }

    /* The drawer scrolls on short screens instead of clipping the last links. */
    .sidebar-area {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 40px;
    }

    /* Tapping the dimmed backdrop should feel like it will close the drawer.
       (#closeButton still does the actual closing.) */
    .sidebar-area .sidebar__overlay {
        cursor: pointer;
    }

    /* Keep the close button clear of the menu. */
    .sidebar-area button#closeButton {
        z-index: 5;
    }
}


/* ==========================================================================
   2. DARK MODE — remove the white patches
   ========================================================================== */

[data-theme=dark_mode] {
    /* Surfaces used by the overrides below. Kept close to the theme's own
       --main-bg / --sub-bg so panels sit on the page rather than float. */
    --ajt-surface:      #1c1a33;
    --ajt-surface-soft: #16142c;
    --ajt-line:         rgba(255, 255, 255, .10);
    --ajt-text:         rgba(255, 255, 255, .88);
    --ajt-text-dim:     rgba(255, 255, 255, .62);
}

/* The seven blocks ats-enhance.css pins to #fff. */
[data-theme=dark_mode] .pricing__item,
[data-theme=dark_mode] .about__right-item,
[data-theme=dark_mode] .process__item,
[data-theme=dark_mode] .testimonial__item,
[data-theme=dark_mode] .talk-us__item {
    background: var(--ajt-surface) !important;
    border-color: var(--ajt-line) !important;
    color: var(--ajt-text) !important;
}

[data-theme=dark_mode] .about-area {
    background: var(--ajt-surface-soft) !important;
}

[data-theme=dark_mode] .pricing-area {
    background: var(--ajt-surface-soft) !important;
}

[data-theme=dark_mode] .footer-title {
    color: var(--ajt-text) !important;
}

/* Text inside those panels, which inherited a dark ink colour from :root. */
[data-theme=dark_mode] .pricing__item h2,
[data-theme=dark_mode] .pricing__item h3,
[data-theme=dark_mode] .pricing__item h4,
[data-theme=dark_mode] .pricing__item li,
[data-theme=dark_mode] .about__right-item h3,
[data-theme=dark_mode] .about__right-item h4,
[data-theme=dark_mode] .process__item h3,
[data-theme=dark_mode] .process__item h4,
[data-theme=dark_mode] .testimonial__item h4,
[data-theme=dark_mode] .talk-us__item h4 {
    color: var(--ajt-text) !important;
}

[data-theme=dark_mode] .pricing__item p,
[data-theme=dark_mode] .about__right-item p,
[data-theme=dark_mode] .process__item p,
[data-theme=dark_mode] .testimonial__item p,
[data-theme=dark_mode] .talk-us__item p {
    color: var(--ajt-text-dim) !important;
}

/* Form controls: the browser default is a white field with dark text, which
   is jarring beside dark panels and looks like an unstyled element. */
[data-theme=dark_mode] input[type=text],
[data-theme=dark_mode] input[type=email],
[data-theme=dark_mode] input[type=tel],
[data-theme=dark_mode] input[type=number],
[data-theme=dark_mode] input[type=password],
[data-theme=dark_mode] input[type=search],
[data-theme=dark_mode] textarea,
[data-theme=dark_mode] select {
    background-color: var(--ajt-surface) !important;
    border-color: var(--ajt-line) !important;
    color: var(--ajt-text) !important;
}

[data-theme=dark_mode] input::placeholder,
[data-theme=dark_mode] textarea::placeholder {
    color: rgba(255, 255, 255, .42) !important;
}

/* .light-area is the theme's opt-out: blocks that should stay light even in
   dark mode. Its inputs must stay light too, or they invert twice. */
[data-theme=dark_mode] .light-area input,
[data-theme=dark_mode] .light-area textarea,
[data-theme=dark_mode] .light-area select {
    background-color: #fff !important;
    border-color: #e3e8f0 !important;
    color: #101117 !important;
}

/* Tables read as a bright slab in dark mode otherwise. */
[data-theme=dark_mode] table:not(.light-area table) {
    color: var(--ajt-text);
}

[data-theme=dark_mode] .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: var(--ajt-text) !important;
    border-color: var(--ajt-line) !important;
}

/* Cards and modals from Bootstrap, which default to white. */
[data-theme=dark_mode] .card:not(.light-area .card),
[data-theme=dark_mode] .modal-content:not(.light-area .modal-content) {
    background-color: var(--ajt-surface) !important;
    border-color: var(--ajt-line) !important;
    color: var(--ajt-text) !important;
}

/* Horizontal rules and borders that were tuned for a light page. */
[data-theme=dark_mode] hr {
    border-color: var(--ajt-line) !important;
    opacity: 1;
}

/* Selection highlight, so selected text stays readable. */
[data-theme=dark_mode] ::selection {
    background: rgba(120, 150, 255, .32);
    color: #fff;
}


/* ==========================================================================
   3. USER PANEL MOBILE MENU — slide in from the left, not down from the top
   --------------------------------------------------------------------------
   The user panel is a different layout from the public site. Its menu is a
   Bootstrap collapse:

       <button data-bs-toggle="collapse" data-bs-target="#navbar-menu">
       <div class="collapse navbar-collapse" id="navbar-menu">

   Bootstrap collapse animates HEIGHT, so it always expands downward and pushes
   the page content down. That is the "menu opens from the top" behaviour.

   Converted here into a left drawer. Bootstrap still toggles the .show class,
   so no JavaScript changes are needed -- only what .show looks like.
   ========================================================================== */

@media (max-width: 991.98px) {

    /* .collapse sets display:none, which would stop the drawer animating at
       all. It is forced visible and moved off-screen instead, so the slide is
       a transform rather than a height change. */
    aside.navbar #navbar-menu.collapse,
    aside.navbar #navbar-menu.collapsing,
    aside.navbar #navbar-menu {
        display: block !important;
        position: fixed !important;
        top: 0;
        left: 0;
        width: min(284px, 84vw);
        height: 100vh !important;      /* beats the inline height Bootstrap writes */
        max-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform .28s ease;
        z-index: 1045;
        background: #16181d;           /* matches the panel's dark sidebar */
        padding: 68px 0 28px;          /* clears the toggler at the top */
        box-shadow: 6px 0 26px rgba(0, 0, 0, .34);
        visibility: hidden;
    }

    aside.navbar #navbar-menu.show,
    aside.navbar #navbar-menu.collapsing {
        transform: translateX(0);
        visibility: visible;
    }

    /* The toggler has to stay above the drawer, otherwise the drawer covers
       the only control that closes it. */
    aside.navbar .navbar-toggler {
        position: relative;
        z-index: 1046;
    }

    /* Dim the page behind the drawer. Progressive enhancement: browsers
       without :has() simply get no backdrop, and the drawer still works. */
    aside.navbar:has(#navbar-menu.show)::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 1044;
        pointer-events: none;
    }

    /* Full-width tap targets down the drawer. */
    aside.navbar #navbar-menu .navbar-nav {
        flex-direction: column;
        width: 100%;
        padding: 0 10px;
    }

    aside.navbar #navbar-menu .navbar-nav .nav-item {
        width: 100%;
    }

    aside.navbar #navbar-menu .navbar-nav .nav-link {
        padding: 12px 14px;
        border-radius: 8px;
        font-size: 15px;
    }

    aside.navbar #navbar-menu .navbar-nav .nav-link:hover {
        background: rgba(255, 255, 255, .07);
    }

    /* Dropdowns inside the drawer should stack, not float over it. */
    aside.navbar #navbar-menu .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        transform: none !important;
        border: 0;
        background: rgba(255, 255, 255, .05);
        margin: 2px 0 6px;
        padding-left: 10px;
    }

    /* Stop the page scrolling sideways while the drawer is off-screen. */
    body {
        overflow-x: hidden;
    }
}


/* ==========================================================================
   6. USER PANEL HEADER ON MOBILE — wallet visible, PIN moved to the menu
   --------------------------------------------------------------------------
   _wallet_card.blade.php carries its own rule:
       @media (max-width: 767.98px) { .ajt-wallet-card { display: none; } }
   An earlier attempt here set order and width but never touched `display`, so
   the card stayed hidden and the change appeared to do nothing. `display` is
   what has to be overridden.

   The PIN chip is handled in Blade instead: the header copy hides below 992px
   and a second copy renders inside the account dropdown, which is where people
   look for it on a phone.
   ========================================================================== */

@media (max-width: 767.98px) {

    /* Bring the wallet back, full width, first in the row. */
    .page-wrapper > header.navbar .ajt-wallet-card {
        display: inline-flex !important;
        order: -1;
        width: 100%;
        justify-content: flex-start;
        gap: .6rem;
    }

    .page-wrapper > header.navbar .ajt-wallet-meta {
        flex: 1 1 auto;
    }

    .page-wrapper > header.navbar .ajt-wallet-value {
        font-size: 1.02rem;
        font-weight: 700;
    }

    /* The "+ Add" button is worth keeping on mobile — topping up is the most
       common reason to look at the wallet. */
    .page-wrapper > header.navbar .ajt-wallet-add {
        display: inline-block !important;
        margin-left: auto;
    }

    .page-wrapper > header.navbar .d-flex.w-100 {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .page-wrapper > header.navbar .d-flex.align-items-center.gap-2 {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px !important;
    }

    .page-wrapper > header.navbar select.form-select {
        max-width: 128px;
        font-size: 13px;
    }

    .page-wrapper > header.navbar {
        padding-top: 8px;
        padding-bottom: 8px;
    }
}


/* ==========================================================================
   7. ACCOUNT DROPDOWN — keep it on screen
   --------------------------------------------------------------------------
   The menu is anchored to an item at the far right of the header, so at some
   widths it rendered partly past the edge of the viewport and the last item
   was awkward to reach.
   ========================================================================== */

.navbar .dropdown-menu-end {
    right: 0;
    left: auto;
    max-width: calc(100vw - 24px);
}

@media (max-width: 575.98px) {
    .navbar .dropdown-menu-end {
        position: fixed !important;
        right: 12px !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        min-width: 232px;
    }
}

/* The PIN row inside the dropdown should read as part of the menu. */
.dropdown-menu .ajt-pin--menu .ajt-pin-label,
.dropdown-menu .ajt-pin--menu .ajt-pin-value {
    color: inherit;
}
