/* =====================================================================
   mobile.css  -  loaded AFTER style.css and each page's inline <style>,
   so equal-specificity rules here win. Replaces your existing file.
   ===================================================================== */

/* ---------- Global safety nets (all sizes) ---------- */
html { -webkit-text-size-adjust: 100%; }
img, svg { max-width: 100%; }

/* ---------- Tablet and phone ---------- */
@media (max-width: 720px) {

    body:not(.login-page) { margin: 0; padding: 10px; font-size: 16px; }

    .container,
    .dashboard-container {
        padding: 16px;
        border-radius: 10px;
        max-width: 100%;
        box-sizing: border-box;
    }

    h2 { font-size: 22px; line-height: 1.25; }
    h3 { font-size: 18px; line-height: 1.3; }

    /* Inputs: 16px stops iOS zooming on focus; 44px is a comfortable tap target */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="date"], input[type="number"], input[type="url"],
    select, textarea {
        font-size: 16px;
        min-height: 44px;
        padding: 10px;
    }
    textarea { min-height: 88px; }
    input[type="checkbox"], input[type="radio"] { min-width: 20px; min-height: 20px; }

    .btn, button.btn, a.btn { min-height: 44px; padding: 10px 14px; font-size: 15px; box-sizing: border-box; }
    .btn-approve, .btn-delete, .btn-edit { min-height: 36px; padding: 8px 12px !important; font-size: 14px !important; }

    /* ---------- Dashboard header ---------- */
    .dashboard-welcome { font-size: 18px; flex-wrap: wrap; gap: 8px; }
    .dashboard-welcome button { font-size: 15px; min-height: 44px; padding: 0 4px; }

    .panel-box { padding: 14px; margin-bottom: 16px; border-radius: 10px; }
    .panel-narrow { max-width: 100%; }

    .last-updated { display: block; margin-left: 0; margin-top: 2px; }

    /* ---------- Admin tab bar: two per row ---------- */
    .admin-menu-bar { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; border-bottom-width: 3px; }
    .admin-menu-btn { min-height: 44px; font-size: 13px; padding: 8px 4px; border-bottom: 1px solid #cfd8d2; border-radius: 8px; }

    /* ---------- Generic tables: scroll sideways instead of breaking the page ---------- */
    table:not(.reg-table) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table:not(.reg-table) th,
    table:not(.reg-table) td { white-space: nowrap; padding: 10px 8px; }
    /* Event names and long text may wrap */
    .events-table { table-layout: auto; }
    .events-table td:first-child { white-space: normal; min-width: 150px; }

    /* ---------- Registry table -> stacked cards ---------- */
    .reg-table, .reg-table tbody { display: block; width: 100%; table-layout: auto; }
    .reg-table .reg-head { display: none; }

    .reg-table tr {
        display: block;
        margin-bottom: 14px;
        padding: 12px;
        border: 1px solid #e3e8e4;
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,.06);
    }
    .reg-table tr:hover td { background: transparent; }

    /* Beat the width rules registry.php injects per column */
    .reg-table th, .reg-table td { width: auto !important; }
    .reg-table td {
        display: block;
        border-bottom: none;
        padding: 6px 0;
        word-wrap: break-word;
    }

    /* Cells with a data-label become "Label ..... value" rows */
    .reg-table td[data-label] {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border-top: 1px solid #eef1ee;
        text-align: right;
    }
    .reg-table td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 13px;
        font-weight: 600;
        color: #4a5a52;
        text-align: left;
    }

    /* In edit mode, give the field the full row below its label */
    .reg-table td[data-label] > input,
    .reg-table td[data-label] > select { flex: 1 1 auto; min-width: 0; width: auto; margin-bottom: 0; }

    .reg-table .prio-cell { padding-top: 0; }
    .reg-table .item-cell { font-size: 17px; padding-bottom: 10px; }
    .reg-table .item-cell small { display: block; margin-top: 4px; font-size: 14px; }

    .reg-table .actions { padding-top: 10px; margin-top: 6px; border-top: 1px solid #eef1ee; }
    .reg-table .actions .btn { width: 100%; min-height: 44px; font-size: 15px; }
    .reg-table .actions form { margin-bottom: 8px !important; }
    .reg-table .actions input[type="number"] { width: 64px !important; min-height: 44px; text-align: center; }

    /* Empty-state row */
    .reg-table td[colspan] { display: block; text-align: center; }

    /* Notes button: bigger tap target */
    .reg-table .note-btn { font-size: 22px; padding: 6px 10px; }

    /* Star rating: bigger tap targets */
    .star-rating label { font-size: 32px; padding: 0 2px; }

    /* ---------- Standalone form pages (add item, forgot/reset password) ---------- */
    .checkbox-container { min-height: 44px; }

    /* ---------- Login ---------- */
    .login-split { flex-direction: column; min-height: 100vh; min-height: 100dvh; }
    .login-main { padding: 32px 16px; flex: 1 1 auto; align-items: flex-start; }
    .login-card { max-width: 100%; }
    .login-card h2 { font-size: 30px; }
    .login-sub { margin-bottom: 24px; }
    .login-version { margin-top: 32px; }
}

/* ---------- Small phones ---------- */
@media (max-width: 400px) {
    body:not(.login-page) { padding: 6px; }
    .container, .dashboard-container { padding: 12px; }
    .admin-menu-bar { grid-template-columns: repeat(2, 1fr); }
    .login-card h2 { font-size: 26px; }
}

/* ---------- Keep printing unaffected ---------- */
@media print {
    table:not(.reg-table) { display: table; overflow: visible; }
    table:not(.reg-table) th, table:not(.reg-table) td { white-space: normal; }
}
