/* ============================================
   AIledger — Shared Mobile / PWA Styles
   Linked from all pages for Android web app
   ============================================ */

/* ---- Bottom Tab Bar (PWA Android pattern) ---- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 900;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.bottom-nav-items {
    display: flex;
    align-items: stretch;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 6px;
    text-decoration: none;
    color: #6b7280;
    font-size: 0.65rem;
    font-weight: 500;
    gap: 3px;
    min-height: 56px;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.bottom-nav-item.active {
    color: #667eea;
}

.bottom-nav-item:active {
    background: #f3f4f6;
}

/* Add padding to body so content isn't hidden behind bottom nav */
@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Safe area for iOS notch / Android gesture bar */
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ---- Touch target minimum size ---- */
@media (max-width: 768px) {
    button, .btn, a.btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
    }

    /* Compact inline buttons that must stay small */
    .btn-xs, button.btn-xs {
        min-height: 32px;
    }
}

/* ---- Full-screen modals on mobile ---- */
@media (max-width: 480px) {
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }
}

/* ---- Table → Card view on mobile ---- */
@media (max-width: 600px) {
    .table-cards thead {
        display: none;
    }

    .table-cards tbody tr {
        display: block;
        background: #fff;
        border-radius: 10px;
        margin-bottom: 10px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
        padding: 12px;
    }

    .table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 4px 0;
        border: none !important;
        font-size: 0.875rem;
    }

    .table-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.75rem;
        min-width: 90px;
        flex-shrink: 0;
    }

    .table-cards td:empty {
        display: none;
    }
}

/* ---- Responsive form inputs ---- */
@media (max-width: 768px) {
    .filter-group input[type="search"],
    .filter-group input[type="text"],
    .filter-group select {
        min-width: 0 !important;
        width: 100% !important;
    }

    .form-group {
        min-width: 0 !important;
        width: 100% !important;
    }
}

/* ---- Stats / summary cards wrap ---- */
@media (max-width: 600px) {
    .stats-bar,
    .summary-cards,
    .stat-item {
        flex-wrap: wrap;
    }

    .stat-item {
        min-width: calc(50% - 0.5rem);
    }
}

/* ---- Page header stack ---- */
@media (max-width: 600px) {
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .page-header .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-header .header-actions .btn {
        flex: 1;
        text-align: center;
        min-width: 120px;
    }
}

/* ---- Tabs wrapping ---- */
@media (max-width: 600px) {
    .tabs {
        flex-wrap: wrap !important;
    }

    .tab {
        flex: 1;
        min-width: calc(50% - 4px);
        text-align: center;
    }
}
