/* =========================================================================
   mobile.css - app-like experience on phones and tablets.
   Loaded after app.css, so it can refine the desktop rules.
   ========================================================================= */

:root {
    --bottom-nav-height: 60px;
}

/* ---------- Bottom navigation (mobile only) ---------- */
.bottom-nav {
    display: none;
}

.bn-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    border: 2px solid #fff;
    pointer-events: none;
}

@media (max-width: 900px) {
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        /* 5 equal slots keep the WhatsApp button exactly in the middle,
           whatever the labels around it are */
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: center;
        justify-items: center;
        background: #ffffff;
        border-top: 1px solid rgba(148, 163, 184, .35);
        box-shadow: 0 -6px 22px rgba(15, 23, 42, .08);
        z-index: 60;
    }

    .bottom-nav-item {
        width: 100%;
        min-width: 0;
        height: var(--bottom-nav-height);
        border: 0;
        background: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font: inherit;
        color: #6b7280;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav-item .bn-icon { font-size: 19px; line-height: 1; }
    .bottom-nav-item .bn-label {
        font-size: 10.5px;
        letter-spacing: .01em;
        white-space: nowrap;
    }
    .bottom-nav-item.active { color: var(--accent-strong); font-weight: 600; }

    /* Circular WhatsApp button in the middle, raised above the bar */
    .bottom-nav-fab {
        position: relative;   /* anchor for the unread badge */
        width: 58px;
        height: 58px;
        margin-top: -26px;
        border-radius: 50%;
        background: #25d366;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 20px rgba(37, 211, 102, .45);
        border: 4px solid #fff;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: transform .15s ease;
    }
    .bottom-nav-fab:active { transform: scale(.93); }
    .bottom-nav-fab.active { box-shadow: 0 8px 22px rgba(37, 211, 102, .6); }

    /* Room so content is never hidden behind the bar */
    .main {
        padding: 12px 12px calc(var(--bottom-nav-height) + 22px + env(safe-area-inset-bottom, 0px));
    }

    /* ---------- Header / typography ---------- */
    .main-title-block h1 { font-size: 18px; }
    .main-title-block p  { font-size: 11.5px; }

    .main-header {
        margin-bottom: 12px;
        gap: 8px;
    }

    .content-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 13px 13px 12px;
        border-radius: 16px;
        box-shadow: 0 8px 20px rgba(15, 23, 42, .05);
    }

    /* ---------- Touch-friendly controls ---------- */
    button,
    .btn-primary,
    .btn-secondary,
    input[type="submit"],
    input[type="button"] {
        min-height: 42px;
    }

    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="email"],
    select,
    textarea {
        min-height: 42px;
        font-size: 16px; /* stops iOS auto-zoom on focus */
    }

    .users-toolbar {
        gap: 8px;
    }
    .users-toolbar > * {
        flex: 1 1 auto;
        min-width: 0;
    }
    .users-toolbar .users-count {
        flex-basis: 100%;
    }

    /* ---------- Tables become stacked cards ---------- */
    .users-table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
        border-radius: 0;
    }

    table.users-table,
    table[data-search-table] {
        border-collapse: separate;
        border-spacing: 0 8px;
        width: 100%;
    }

    table.users-table thead,
    table[data-search-table] thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    table.users-table tr,
    table[data-search-table] tr {
        display: block;
        background: #fff;
        border: 1px solid rgba(148, 163, 184, .35);
        border-radius: 14px;
        padding: 4px 10px;
        box-shadow: 0 4px 12px rgba(15, 23, 42, .04);
    }

    table.users-table td,
    table[data-search-table] td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        border: 0;
        border-bottom: 1px solid #f1f5f9;
        padding: 7px 0;
        font-size: 13px;
        text-align: right;
        width: auto !important;
    }

    table.users-table tr td:last-child,
    table[data-search-table] tr td:last-child {
        border-bottom: 0;
    }

    /* Label injected by app.js from the matching <th> */
    table.users-table td::before,
    table[data-search-table] td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        text-align: left;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #6b7280;
        font-weight: 600;
        padding-top: 1px;
    }

    /* Cells with no label (action buttons) take the full width */
    table.users-table td[data-label=""],
    table[data-search-table] td[data-label=""] {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    table.users-table td[data-label=""]::before,
    table[data-search-table] td[data-label=""]::before {
        content: none;
    }

    /* Rows the page uses for "empty"/"loading" messages */
    table.users-table td[colspan]::before,
    table[data-search-table] td[colspan]::before {
        content: none;
    }
    table.users-table td[colspan],
    table[data-search-table] td[colspan] {
        justify-content: center;
        text-align: center;
        color: #6b7280;
    }

    /* Tables explicitly marked as wide keep horizontal scrolling instead */
    .table-scroll .users-table-wrap,
    .users-table-wrap.table-scroll {
        overflow-x: auto;
        border: 1px solid rgba(148, 163, 184, .35);
        background: #f9fafb;
        border-radius: 12px;
    }
    .table-scroll table.users-table thead {
        position: static;
        width: auto;
        height: auto;
        clip: auto;
    }
    .table-scroll table.users-table tr {
        display: table-row;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
    .table-scroll table.users-table td {
        display: table-cell;
        text-align: left;
        border-bottom: 1px solid #eef2f7;
    }
    .table-scroll table.users-table td::before { content: none; }

    /* ---------- Modals / drawers full width ---------- */
    .modal,
    .modal-panel,
    .drawer,
    .drawer-panel {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 18px 18px 0 0 !important;
    }

    /* ---------- Misc ---------- */
    .domain-expiry-banner {
        position: static;
        margin: 8px 10px 0;
        left: auto;
        right: auto;
    }

    .table-pagination {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        padding: 6px 0 2px;
    }

    .user-badge { font-size: 11px; padding: 6px 10px; }
}

/* Small phones */
@media (max-width: 380px) {
    .bottom-nav-item .bn-label { font-size: 9.5px; }
    .bottom-nav-fab { width: 54px; height: 54px; margin-top: -22px; }
    .main-title-block h1 { font-size: 17px; }
}

/* Desktop: never show the mobile chrome */
@media (min-width: 901px) {
    .bottom-nav { display: none !important; }
}
