/*
 * Phone / tablet layer for every portal layout. Loaded last (after theme.css).
 * Desktop (>= 992px) is not changed, except the DataTables scroll box which is harmless there.
 * Works with /js/mobile-fit.js (phone menu built from the desktop menu, table scroller).
 */

/* Wide tables scroll inside their own box, not the whole page. */
.vg-dt-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Back-to-top button (jquery.scrollUp, all sizes). Its icon is an Ionicons glyph, and some layouts
   don't load Ionicons, so phones showed an empty box. The arrow is drawn in CSS instead.
   The plugin sets position / z-index / display inline, so those are left alone. */
#scrollUp { width: 44px !important; height: 44px !important; right: 16px !important; bottom: 20px !important;
            border: 0 !important; border-radius: 50% !important; font-size: 0 !important; line-height: 0 !important;
            box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transition: box-shadow .2s, transform .2s; }
#scrollUp > * { display: none !important; }
#scrollUp::before { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px;
                    border-left: 3px solid #1a1a1a; border-top: 3px solid #1a1a1a; border-radius: 1px;
                    transform: translate(-50%, -25%) rotate(45deg); }
#scrollUp:hover, #scrollUp:focus { box-shadow: 0 6px 18px rgba(0, 0, 0, .4); transform: translateY(-2px); }
@media (max-width: 767px) {
    #scrollUp { width: 40px !important; height: 40px !important; right: 12px !important; bottom: 16px !important; }
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 991px) {
    /* The header scrolls away with the page instead of staying fixed: on a phone the fixed
       header (logos + name + menu bar) took 170-260px, a third of the screen, and pages used a
       fixed 128-236px gap that never matched it, so the first lines (e.g. "Registration Form")
       sat under the header. */
    .header-sticky.sticky { position: relative !important; }
    .mt182 { margin-top: 14px !important; padding-top: 0 !important; }

    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .modal-dialog.modal-lg.modal_lg { width: auto; margin: 10px; }

    /* Tablets get the phone header too: the desktop menu does not fit next to the logos below
       992px (it wrapped into 3 rows and ran under the logo). main.js already builds the
       hamburger menu up to 991px; Bootstrap was hiding it on tablets. */
    .header-container .mobile-menu-area.hidden-sm { display: block !important; }
    .mobile-menu, .mean-container .mean-bar { background: #fff; }
    .mean-container a.meanmenu-reveal { color: #000; }
    .mean-container a.meanmenu-reveal span { background: #000104 !important; }
    .mean-container .mean-nav { margin-top: 44px; position: absolute; }

    /* Top strip (mail / phone / theme / login): compact, wraps cleanly, no overflow. */
    .header-top-area .row > [class*="col-"] { float: none; width: 100%; text-align: center; }
    .header-top-menu > ul { margin: 0; padding: 0; }
    .header-top-menu > ul > li { padding-top: 3px; padding-bottom: 3px; padding-right: 10px; margin-right: 8px; line-height: 20px; }
    .header-top-menu > ul > li > span, .header-top-menu > ul > li > a { font-size: 12px; padding: 0; margin-right: 0; }
    .header-top-menu > ul > li .name_text { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

    /* Logo row: V-Guard (+ campaign logo) on the left, Rishta on the right, never overlapping. */
    .header-middel-area .row { display: flex; align-items: center; flex-wrap: nowrap; }
    .header-middel-area .row > [class*="col-"] { float: none; width: auto; flex: 1 1 0; min-width: 0; }
    .header-middel-area .row > .hidden-xs { display: none !important; }
    .header-middel-area .logo { padding: 4px 0; text-align: left; }
    .header-middel-area .row > [class*="col-"]:last-child .logo { text-align: right; }
    /* gap: the rule below removes the inline margins, so V-Guard | Simon would touch the divider */
    .header-middel-area .logo a { display: inline-flex !important; align-items: center; max-width: 100%; gap: 10px; }
    .header-middel-area .logo img { max-height: 48px; width: auto !important; max-width: 100%; margin: 0 !important; min-width: 0; flex: 0 1 auto; }
    .header-middel-area .logo a img + img { max-height: 38px; max-width: 48%; }
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
    html, body { max-width: 100%; }
    body { -webkit-text-size-adjust: 100%; }

    /* Page titles and cards */
    .heading-banner-title h4 { font-size: 17px; line-height: 1.3; word-break: break-word; }
    .card-title { font-size: 15px; }
    .card-title .pull-right { float: none !important; display: inline-block; margin-left: 8px; }
    .container { padding-left: 12px; padding-right: 12px; }

    /* Forms: full-width fields, 16px text so iPhones don't zoom in on focus. */
    input.form-control, select.form-control, select.form-control2, textarea.form-control,
    .form-control, .form-control2 { font-size: 16px; max-width: 100%; }
    .form-group label { white-space: normal; }
    label.invisible { display: none; }
    .callwell .form-group > .btn, .callwell .form-group > input[type="button"], .callwell .form-group > input[type="submit"] { width: 100%; }

    /* DataTables: controls stack and centre under the table. */
    .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate {
        float: none; text-align: center; width: 100%;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button { padding: 4px 9px; min-width: 32px; }
    table.dataTable th, table.dataTable td { white-space: nowrap; }

    /* table.vg-cards: one card per row; js/mobile-fit.js puts each column title in data-label. */
    table.vg-cards, table.vg-cards > tbody, table.vg-cards > tbody > tr, table.vg-cards > tbody > tr > td { display: block; width: 100% !important; }
    table.vg-cards > thead { display: none; }
    table.vg-cards > tbody > tr { margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--vg-border, #e3e3e3); border-radius: 8px; background: var(--vg-surface, #fff); box-shadow: 0 1px 3px var(--vg-shadow, rgba(0,0,0,.08)); }
    table.vg-cards > tbody > tr > td { border: 0 !important; padding: 3px 0 !important; white-space: normal !important; text-align: left !important; background: transparent !important; }
    table.vg-cards > tbody > tr > td[data-label]:before { content: attr(data-label); display: inline-block; min-width: 92px; margin-right: 8px; font-size: 12px; color: var(--vg-text-muted, #777); }
    table.vg-cards > tbody > tr > td:last-child[data-label]:before { display: none; }
    table.vg-cards > tbody > tr > td:last-child { padding-top: 8px !important; }
    table.vg-cards > tbody > tr > td:last-child .btn { margin: 0 6px 0 0; }
    table.vg-cards > tbody > tr > td.dataTables_empty:before { display: none; }
    table.vg-cards > tbody > tr > td.dataTables_empty { text-align: center !important; }

    /* Pop-ups use the whole screen width. */
    .modal-dialog { width: auto; margin: 8px; }
    .modal-body { padding: 12px; }

    /* Images and charts never wider than the screen. */
    img { max-width: 100%; height: auto; }
    .amcharts-main-div, [id^="chartdiv"] { max-width: 100%; }

    /* Report progress pop-up fits a phone. */
    #report-progress-box { min-width: 0 !important; width: calc(100% - 32px); padding: 18px; }

    /* Long hamburger menus scroll inside themselves. */
    .mean-container .mean-nav { max-height: 70vh; overflow-y: auto; }
}
