/*
 * Bootstrap 5 for the public layouts (main, main_register), loaded by backend\assets\AppAsset after the theme.
 *
 * The theme (Daily Shop, theme/css/style.css) was written for Bootstrap 3. The rules here keep the pages as they
 * looked on Bootstrap 3 where the two differ, except font sizes, which follow Bootstrap 5 (decided 2026-10-30).
 * Plan: doc/upgrade_bootstrap5_public_plan.md.
 */

/* Page width and column gaps as on Bootstrap 3: the theme sets the width of .container (100%, 90%, 1360px)
   and Bootstrap 5 would cap it at 540 to 1320px; columns were 30px apart. */
.container {
    max-width: none;
}

/* From 1200px the theme fixes the width at 1360px, wider than screens of 1200 to 1359px (problem 26):
   use the whole screen there, and 1360px from 1360px up as before. */
@media (min-width: 1200px) {
    .container {
        width: 100%;
        max-width: 1360px;
    }
}

.container,
.row {
    --bs-gutter-x: 30px;
}

/* Page numbers wrap to a second line instead of running past the right edge of a phone screen */
.pagination {
    flex-wrap: wrap;
}

/* ===== Top menu: SmartMenus on a Bootstrap 5 navbar (js/public-menu.js) ===== */

#menu .menu-area .navbar-default {
    padding: 0;
}

/* Bootstrap 3 gave these .nav > li > a, and SmartMenus places a sub menu against its item */
#topmenu li {
    position: relative;
}

#topmenu > li > a,
#topmenu ul a {
    display: block;
    position: relative;
}

/* Sub menus have their own class, not .dropdown-menu: Bootstrap 5 handles arrow keys and Escape in every
   .dropdown-menu (capture listener on document) and throws for a menu it did not open itself.
   SmartMenus shows and places them; absolute on a wide screen, static (opens in place) on a small one,
   which is how SmartMenus tells its two modes apart. */
#topmenu .submenu {
    display: none;
    position: absolute;
    z-index: 1000;
    min-width: 160px;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, .15);
    box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
}

/* as the theme's rule for .dropdown-menu li a */
#menu .menu-area .navbar-default .navbar-nav .submenu li a {
    padding: 8px 15px;
    white-space: normal;
}

/* arrow after an item that has a sub menu: down on the top level, right inside a sub menu */
#topmenu a.has-submenu .sub-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    vertical-align: middle;
    border-top: 4px solid;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

/* The menu bar opens from 1200px (navbar-expand-xl in layouts/_public_header.php, since 2026-11-05; it was 768px):
   below that, phones and tablets get the ☰ button. */
@media (min-width: 1200px) {
    /* the theme makes the list inline-block; Bootstrap 5 lays the items out with flex */
    #menu .menu-area .navbar-default .navbar-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }

    #topmenu ul a.has-submenu {
        padding-right: 30px !important;
    }

    #topmenu ul a.has-submenu .sub-arrow {
        position: absolute;
        top: 50%;
        right: 15px;
        margin-top: -4px;
        border-top: 4px solid transparent;
        border-right: 0;
        border-bottom: 4px solid transparent;
        border-left: 4px solid;
    }

    /* sub menus: rounded boxes with a shadow (no overflow: hidden, which would cut the next level), more room
       around the names */
    #topmenu .submenu {
        border: 0;
        border-radius: var(--gw-radius-md);
        box-shadow: var(--gw-shadow-hover);
    }

    #topmenu .submenu > li:first-child > a {
        border-top-left-radius: var(--gw-radius-md);
        border-top-right-radius: var(--gw-radius-md);
    }

    #topmenu .submenu > li:last-child > a {
        border-bottom-left-radius: var(--gw-radius-md);
        border-bottom-right-radius: var(--gw-radius-md);
    }

    #menu .menu-area .navbar-default .navbar-nav .submenu li a {
        padding: 10px 16px;
    }

    /* SmartMenus gives a sub menu "sm-nowrap" while its names fit in 20em, so it grows to its longest name;
       a wider one loses the class and gets 20em, and only then do the names wrap. The rule needs more weight
       than the white-space: normal above, or every name wraps in a 10em box. */
    #menu .menu-area .navbar-default .navbar-nav ul.sm-nowrap > li > a {
        white-space: nowrap;
    }
}

/* small screens: the menu opens under the menu button, sub menus open in place with a +/- button */
@media (max-width: 1199.98px) {
    #topmenu .submenu {
        position: static;
        border: 0;
        box-shadow: none;
    }

    #topmenu a.has-submenu {
        padding-right: 60px !important;
    }

    #topmenu a.has-submenu .sub-arrow {
        position: absolute;
        top: 50%;
        right: 15px;
        width: 32px;
        height: 26px;
        margin: -13px 0 0 0;
        line-height: 24px;
        text-align: center;
        border: 1px solid;
    }

    #topmenu a.has-submenu .sub-arrow::before {
        content: '+';
        font-family: monospace;
        font-weight: bold;
    }

    #topmenu .open > a.has-submenu .sub-arrow::before {
        content: '-';
    }

    /* a thin line between the items of the folded menu, in the menu's text colour */
    #topmenu > li {
        border-bottom: 1px solid rgba(127, 127, 127, .25);
        border-bottom-color: color-mix(in srgb, var(--gw-menu-text) 22%, transparent);
    }

    #topmenu > li:last-child {
        border-bottom: 0;
    }

    /* the sub menus open in place, so each level starts a step further right to read apart from its parent */
    #menu .menu-area .navbar-default .navbar-nav .submenu .submenu li a {
        padding-left: 30px;
    }

    #menu .menu-area .navbar-default .navbar-nav .submenu .submenu .submenu li a {
        padding-left: 45px;
    }

    #menu .menu-area .navbar-default .navbar-nav .submenu .submenu .submenu .submenu li a {
        padding-left: 60px;
    }
}

/* pictures: img-responsive of Bootstrap 3 was also display:block */
img.img-fluid {
    display: block;
}

/* news slide on the home page (site/index): round dots as on Bootstrap 3 instead of bars */
.carousel-indicators {
    align-items: center;
}

.carousel-indicators [data-bs-target] {
    width: 10px;
    height: 10px;
    margin: 1px;
    border: 1px solid #fff;
    border-radius: 10px;
    background-color: transparent;
    opacity: 1;
}

.carousel-indicators .active {
    width: 12px;
    height: 12px;
    margin: 0;
    background-color: #fff;
}

/* menu button on small screens: white lines on the menu colour */
#menu .navbar-toggler {
    margin: 8px 0;
    border-color: rgba(255, 255, 255, .5);
}

/* ===== Sidebar (layouts/_public_sidebar.php): the meeting box and the boxes of Manage Home Right as cards =====
   --side-accent and --side-accent-text are the title colours of Manage Banner, set on .side-cards. */
.side-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* room above the footer when the sidebar is taller than the content (a margin: below 992px the column's
       padding is set with !important) */
    margin-bottom: 28px;
}

/* the shared values of css/public-ui.css, as the news cards */
.side-card {
    overflow: hidden;
    border-radius: var(--gw-radius);
    background: #fff;
    box-shadow: var(--gw-shadow);
}

/* up to two lines; the line height leaves room for the marks above and below Lao letters */
.side-card-title {
    padding: 9px 14px;
    background: var(--side-accent, #2663c5);
    color: var(--side-accent-text, #fff);
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

.side-card-title span {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.side-card-media {
    display: block;
    overflow: hidden;
}

.side-card-media img {
    width: 100%;
    height: auto;
    transition: transform .35s ease;
}

a.side-card-media:not(.no-link):hover img {
    transform: scale(1.04);
}

a.side-card-media.no-link {
    cursor: default;
}

/* meeting list */
.side-events {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.side-events li + li {
    border-top: 1px solid #eef1f5;
}

.side-events a {
    display: flex;
    gap: 10px;
    padding: 11px 16px;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    text-decoration: none;
    transition: background-color .2s;
}

.side-events a:hover {
    background-color: #f3f6fb;
    color: var(--side-accent, #2663c5);
}

.side-events a > .fa {
    margin-top: 4px;
    color: var(--side-accent, #2663c5);
}

.side-events small {
    display: block;
    color: #6b7280;
    font-size: 12.5px;
}

/* "all meetings": a small outlined button (.gw-btn-outline, css/public-ui.css) under the list */
.side-card-more {
    padding: 10px 14px 14px;
    border-top: 1px solid #eef1f5;
    text-align: center;
}

/* under the content (below 992px): some room at the screen edges, and two cards side by side from 576px */
@media (max-width: 991.98px) {
    .margdiv.side-col {
        padding: 0 10px !important;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .side-cards {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

/* ===== Home page (site/index.php): the items of the Manage Home groups as cards =====
   --home-accent is the title colour of Manage Banner, set on .home-group. */
.home-group #css_title {
    border-radius: 10px;
}

.home-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-bottom: 3px solid transparent;
    /* the shared values of css/public-ui.css, set by layouts/_public_header.php */
    border-radius: var(--gw-radius);
    background: #fff;
    box-shadow: var(--gw-shadow);
    color: #333;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

a.home-card:hover,
a.home-card:focus-visible {
    border-bottom-color: var(--home-accent, #2663c5);
    box-shadow: var(--gw-shadow-hover);
    color: #333;
    transform: translateY(-4px);
}

/* the theme takes the outline off a:focus; keyboard users still need to see where they are */
a.home-card:focus-visible {
    outline: 3px solid var(--home-accent, #2663c5);
    outline-offset: 2px;
}

/* the picture is shown whole (logos, scanned documents and photos alike) inside a 4:3 frame. min-height and
   overflow keep a tall picture from stretching the frame: without them aspect-ratio lets the content grow it */
.home-card-img {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    min-height: 0;
    overflow: hidden;
    padding: 12px;
    background: #f3f5f9;
}

.home-card-img img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* the line height leaves room for the marks above and below Lao letters */
.home-card-name {
    flex: 1;
    padding: 10px 12px 12px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.6;
    text-align: center;
}

a.home-card:hover .home-card-name,
a.home-card:focus-visible .home-card-name {
    color: var(--home-accent, #2663c5);
}

/* the arrow after the name of a link that leaves the site */
.home-card-ext {
    margin-left: 4px;
    font-size: .75em;
    opacity: .55;
}

/* phones: two cards side by side */
@media (max-width: 575.98px) {
    .home-card-img {
        padding: 8px;
    }

    .home-card-name {
        padding: 8px;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-card {
        transition: none;
    }

    a.home-card:hover,
    a.home-card:focus-visible {
        transform: none;
    }
}

/* ===== Install bar of the app (PWA): phones and tablets only, at the bottom of the screen =====
   layouts/_public_header.php writes it hidden (d-none), js/public-pwa.js shows it. The colours come from Manage
   Banner: the button takes Backgound Menu (--pwa-accent) and the colour of the menu text (--pwa-accent-text).
   Under Bootstrap's modals and SweetAlert, so the iPhone how-to opens above it. */
.pwa-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 12px;
    /* the bar of the iPhones without a home button */
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom)) 12px;
    background: #fff;
    color: #212529;
    box-shadow: 0 -2px 12px rgba(16, 24, 40, .18);
}

.pwa-banner-icon {
    flex: 0 0 44px;
    border-radius: 10px;
}

/* the line height leaves room for the marks above and below Lao letters */
.pwa-banner-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.5;
}

.pwa-banner-text strong,
.pwa-banner-text span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-banner-text span {
    font-size: 13px;
    color: #6c757d;
}

.pwa-banner-install {
    flex: 0 0 auto;
    padding: 8px 14px;
    border: 0;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.5;
    white-space: nowrap;
    background: var(--pwa-accent, #2663c5);
    color: var(--pwa-accent-text, #fff);
}

.pwa-banner-close {
    flex: 0 0 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #6c757d;
}

/* while the bar shows, the end of the page and the "scroll to top" button stay above it */
body.pwa-banner-open {
    padding-bottom: 72px;
}

body.pwa-banner-open .scrollToTop {
    bottom: 84px;
}
