/* =====================================================================
 * mobile-overrides.css
 * Late-loading sheet that targets phones and small tablets.
 * Strategy: tame the desktop-first theme without rewriting it.
 *
 * Loaded AFTER MainTheme.css from _Layout.cshtml so its rules win the
 * cascade where they need to. Everything is wrapped in
 * `@media (max-width: 1070px)` to match the existing theme breakpoint;
 * desktop view is unchanged.
 * ===================================================================== */

@media (max-width: 1070px) {

    /* ----- 1. iOS Safari auto-zoom on focused inputs -----------------
       Anything under 16px makes iOS Safari zoom in on focus and never
       zoom back out. Force inputs/selects/textareas to >=16px.            */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px !important;
        line-height: 1.4;
        padding: 10px 12px;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ----- 2. Tap targets ---------------------------------------------
       Apple HIG and Material both want >=44px for interactive elements. */
    button,
    .btn,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        padding: 12px 18px;
        font-size: 15px;
    }

    /* ----- 3. Body padding under fixed navbar -------------------------
       navbar-fixed-top floats — without padding-top content sits under it. */
    body {
        padding-top: 64px;
    }
    .body-content,
    .body-content-dlcl {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* ----- 4. Tables: card-style on mobile ----------------------------
       Generic responsive table — each <tr> becomes a stacked card,
       <td> gets its column header from data-label. Razor only needs to
       add data-label="X" to each <td>. Tables without data-label still
       render but without per-row labels — fall back to native horizontal
       scroll so nothing breaks visually.                                  */
    table.table,
    .body-content table,
    .body-content-dlcl table {
        display: block;
        width: 100%;
        border: 0;
        overflow: visible;
    }
    table.table thead,
    .body-content table thead,
    .body-content-dlcl table thead {
        /* hide column headers — labels show up per-cell via data-label */
        display: none;
    }
    table.table tbody,
    .body-content table tbody,
    .body-content-dlcl table tbody {
        display: block;
    }
    table.table tr,
    .body-content table tr,
    .body-content-dlcl table tr {
        display: block;
        background: #fff;
        border: 1px solid #e4e7ec;
        border-radius: 8px;
        margin: 0 0 12px 0;
        padding: 12px 14px;
        box-shadow: 0 1px 2px rgba(16,24,40,0.04);
    }
    table.table td,
    .body-content table td,
    .body-content-dlcl table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        padding: 6px 0;
        border: 0;
        border-bottom: 1px solid #f2f4f7;
        word-break: break-word;
        text-align: right;
        font-size: 14px;
    }
    table.table td:last-child,
    .body-content table td:last-child,
    .body-content-dlcl table td:last-child {
        border-bottom: 0;
        padding-top: 10px;
    }
    table.table td[data-label]::before,
    .body-content table td[data-label]::before,
    .body-content-dlcl table td[data-label]::before {
        content: attr(data-label);
        color: #667085;
        font-weight: 500;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        margin-right: 12px;
        text-align: left;
        flex-shrink: 0;
    }
    /* Action cells (buttons / links) take the whole row width */
    table.table td.actions-cell,
    table.table td:last-child:not([data-label]),
    .body-content table td:last-child:not([data-label]),
    .body-content-dlcl table td:last-child:not([data-label]) {
        display: block;
        text-align: left;
        padding-top: 12px;
    }

    /* ----- 5. Forms ---------------------------------------------------
       Stack labels above inputs instead of inline, so labels don't
       collide with controls on narrow widths.                            */
    form label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
    }
    .form-group { margin-bottom: 14px; }
    .form-control { font-size: 16px; }   /* same anti-zoom rule */

    /* ----- 6. Tone down dense desktop typography ----------------------*/
    h1 { font-size: 26px; }
    h2 { font-size: 22px; line-height: 1.3; }
    h3 { font-size: 18px; }

    /* ----- 7. Disable hover effects on touch --------------------------
       Desktop hover-driven menus cause sticky highlight on mobile.       */
    a:hover,
    .nav > li > a:hover {
        background: transparent;
    }

    /* ----- 8. Footer compact -----------------------------------------*/
    .container.footer,
    .footer {
        font-size: 11px;
        color: #98a2b3;
        text-align: center;
        padding: 16px 8px 24px;
    }

    /* ----- 9. Modal / dialog full-width ------------------------------*/
    .ui-dialog,
    .modal-dialog {
        width: 92vw !important;
        max-width: 92vw !important;
        margin: 12px auto !important;
    }

    /* ----- 10. Long URLs / monospace content don't blow layout -------*/
    code, pre {
        word-break: break-word;
        white-space: pre-wrap;
        font-size: 12px;
    }

    /* ----- 11. Main blue menu bar (.menu-dldl) ------------------------
       The teal/blue strip with Operations / Contact / About uses
       desktop-style absolute-positioned icons + custom .operations-dlcl,
       .contact-dlcl, .abount-dlcl classes from MainTheme.css. Those
       collide on narrow widths (icons stacked on top of empty pills).
       Reset to plain stacked white links — high specificity + !important
       beats the theme.                                                    */
    .menu-dldl {
        padding: 0 !important;
        background: #0081a6;
    }
    .menu-dldl .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    .menu-dldl .navbar-collapse,
    .menu-dldl .menu-bar-dlcl {
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
    }
    .menu-dldl ul.nav {
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        display: block !important;
        float: none !important;
    }
    .menu-dldl ul.nav > li {
        display: block !important;
        float: none !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: 0 !important;
        position: static !important;
        height: auto !important;
        min-height: 0 !important;
    }
    .menu-dldl ul.nav > li > a {
        display: block !important;
        width: 100% !important;
        padding: 14px 18px !important;
        color: #fff !important;
        background: transparent !important;
        background-image: none !important;
        border: 0 !important;
        border-bottom: 1px solid rgba(255,255,255,0.15) !important;
        border-radius: 0 !important;
        text-align: left !important;
        text-indent: 0 !important;
        line-height: 1.3 !important;
        height: auto !important;
        min-height: 44px !important;
        position: static !important;
        font-size: 16px !important;
    }
    .menu-dldl ul.nav > li > a.active {
        background: rgba(255,255,255,0.12) !important;
    }
    /* kill icon pseudo-elements injected by .operations-dlcl etc. */
    .menu-dldl ul.nav > li > a::before,
    .menu-dldl ul.nav > li > a::after,
    .menu-dldl ul.nav > li::before,
    .menu-dldl ul.nav > li::after {
        display: none !important;
        content: none !important;
    }
}

/* ----- Touch devices (any width): disable :hover backgrounds ----------
   Phones expose :hover when you tap, then it sticks. Detect tap-only
   devices and neutralise it everywhere. ------------------------------- */
@media (hover: none) {
    *:hover { transition: none !important; }
    .nav > li > a:hover,
    a:hover { background-color: transparent; }
}
