/* Mobile & Tablet Responsive Stylesheet for NOTAM Tracker */

/* Tablet & below: disable sticky table header overlap and enable smooth scrolling */
@media (max-width: 991.98px) {
    .notam-sticky-top {
        position: static;
    }

    .notam-table thead th {
        position: static;
        box-shadow: none;
    }

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

    .desktop-sort-tip {
        display: none;
    }
}

/* Cell phone screens (< 768px767.98): card-based layout, touch-friendly controls, zero horizontal overflow */
@media (max-width: 767.98px) {

    html,
    body {
        overflow-x: hidden;
    }

    .container-fluid {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }

    /* Top Navbar */
    .navbar {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 0.75rem !important;
    }

    .navbar .container-fluid {
        gap: 0.5rem;
    }

    .navbar-brand {
        font-size: 1.05rem;
        white-space: normal;
        line-height: 1.25;
        margin-right: 0;
    }

    .navbar .d-flex {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    /* Cards & Headers */
    .card-header h5 {
        font-size: 1rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .sync-status-badge {
        white-space: normal;
        text-align: left;
        line-height: 1.3;
    }

    #notamArchiveCard .card-header>.d-flex:last-child {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    #notamLangToggle {
        width: 100%;
        display: flex;
    }

    #notamLangToggle .btn {
        flex: 1 1 0;
        padding: 0.4rem 0.25rem;
        font-size: 0.8rem;
    }

    #notamCountBadge {
        align-self: flex-start;
    }

    /* Prevent iOS Safari zoom on input focus and improve tap targets */
    .form-control,
    .form-select {
        font-size: 16px;
    }

    .form-check {
        padding-top: 0.15rem;
        padding-bottom: 0.15rem;
    }

    .form-check-input {
        width: 1.15em;
        height: 1.15em;
    }

    #notamFilterForm .btn,
    #addTrackerForm .btn[type="submit"] {
        min-height: 40px;
    }

    /* Pagination Bar */
    .notam-pagination-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .notam-pagination-bar>.d-flex {
        width: 100%;
        justify-content: space-between;
    }

    .notam-pagination-bar .btn-group {
        flex: 1 1 auto;
    }

    .notam-pagination-bar .btn-group .btn {
        flex: 1 1 0;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .notam-per-page-select {
        font-size: 0.875rem;
    }

    /* Transform 8- and 9-column tables into stacked mobile cards */
    .notam-table-wrap,
    .tracker-table-wrap {
        overflow-x: visible;
    }

    .notam-table,
    .notam-table tbody,
    .tracker-table,
    .tracker-table tbody {
        display: block;
        width: 100%;
    }

    /* Keep sortable column headers as a horizontal touch-scrollable pill strip */
    .notam-table thead,
    .tracker-table thead {
        display: block;
        width: 100%;
        margin-bottom: 0.6rem;
    }

    .notam-table thead tr,
    .tracker-table thead tr {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.4rem;
        padding: 0.25rem 0.05rem 0.45rem;
    }

    .notam-table thead th,
    .tracker-table thead th {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
        width: auto !important;
        white-space: nowrap;
        padding: 0.32rem 0.65rem;
        font-size: 0.78rem;
        border: 1px solid #ced4da !important;
        border-radius: 999px;
        background-color: #f8f9fa;
    }

    .notam-table thead th.mobile-hide-th,
    .tracker-table thead th.mobile-hide-th {
        display: none !important;
    }

    /* Individual record card */
    .notam-table tbody tr,
    .tracker-table tbody tr {
        display: block;
        width: 100%;
        margin-bottom: 0.75rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        overflow: hidden;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .notam-table tbody tr.table-danger {
        border-color: #f1aeb5;
        background-color: #fff5f5;
    }

    .tracker-table tbody tr.table-warning {
        border-color: #ffe69c;
        background-color: #fffdf0;
    }

    .tracker-table tbody tr.table-secondary {
        border-color: #ced4da;
        background-color: #f4f5f7;
    }

    /* Key-value rows inside each card */
    .notam-table tbody td,
    .tracker-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100% !important;
        padding: 0.45rem 0.75rem;
        border: 0 !important;
        border-bottom: 1px solid #eef0f2 !important;
        text-align: right !important;
        white-space: normal !important;
        background-color: transparent !important;
        font-size: 0.875rem;
    }

    .notam-table tbody td:last-child,
    .tracker-table tbody td:last-child {
        border-bottom: 0 !important;
    }

    .notam-table tbody td::before,
    .tracker-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.78rem;
        color: #6c757d;
        text-align: left;
        flex-shrink: 0;
        padding-top: 0.1rem;
    }

    /* Full-width NOTAM text block at bottom of card */
    .notam-table tbody td.notam-text-col,
    .tracker-table tbody td.notam-text-col {
        display: block;
        min-width: 0 !important;
        text-align: left !important;
        padding-top: 0.5rem;
        padding-bottom: 0.65rem;
    }

    .notam-table tbody td.notam-text-col::before,
    .tracker-table tbody td.notam-text-col::before {
        display: block;
        margin-bottom: 0.35rem;
    }

    .raw-notam,
    .tracker-notam {
        font-size: 0.78rem;
        line-height: 1.4;
        padding: 0.5rem;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Touch-friendly tracker action buttons */
    .tracker-table tbody td.tracker-actions-cell {
        align-items: center;
        flex-wrap: wrap;
    }

    .tracker-table tbody td.tracker-actions-cell .tracker-actions-wrap {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    .tracker-table tbody td.tracker-actions-cell .btn {
        min-height: 34px;
        padding: 0.25rem 0.65rem;
    }

    /* Empty-state rows span cleanly without a field label */
    .notam-table tbody td[colspan],
    .tracker-table tbody td[colspan] {
        display: block;
        text-align: center !important;
        border-bottom: 0 !important;
    }

    .notam-table tbody td[colspan]::before,
    .tracker-table tbody td[colspan]::before {
        display: none;
    }

    /* Modals & popups */
    .modal-dialog {
        margin: 0.5rem;
    }

    .date-warning-dialog {
        max-width: calc(100vw - 1.5rem);
    }

    .login-wall-container {
        max-width: 100%;
    }
}