/**
 * PWA Responsive Enhancements
 * Active only in standalone (installed PWA) mode.
 */

@media (display-mode: standalone) {

    /* ── Tighter top navbar ── */
    .navbar {
        min-height: 40px;
    }
    .navbar .navbar-header .navbar-brand {
        padding: 8px 12px;
        height: auto;
    }
    .navbar .navbar-right > li > a {
        padding: 8px 10px;
    }
    .navbar .tabs > li > a {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* ── Sidebar panel ── */
    .side-panel,
    .record .side {
        font-size: 13px;
    }

    /* ── Content area — use space better ── */
    .container.content {
        padding-top: 8px;
    }
    .page-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    .page-header h3,
    .page-header h4 {
        font-size: 1.15rem;
    }

    /* ── List view — denser rows ── */
    .list-container table.table > tbody > tr > td,
    .list-container table.table > thead > tr > th {
        padding: 6px 10px;
        font-size: 13px;
    }
    .list-container table.table {
        margin-bottom: 8px;
    }

    /* ── Record detail — tighter fields ── */
    .record .field {
        margin-bottom: 8px;
    }
    .record .cell {
        padding: 4px 8px;
    }
    .record .panel-heading {
        padding: 8px 14px;
    }
    .record .panel-body {
        padding: 12px 14px;
    }

    /* ── Buttons — slightly smaller ── */
    .record .btn-group .btn,
    .header-buttons .btn {
        padding: 5px 12px;
        font-size: 13px;
    }

    /* ── Modal dialogs ── */
    .modal .modal-body {
        padding: 14px 18px;
    }
    .modal .modal-header {
        padding: 10px 18px;
    }

    /* ── Responsive adjustments for narrower windows ── */
    @media (max-width: 992px) {
        /* Stack side panel below content on smaller screens */
        .record .row .side {
            width: 100%;
            float: none;
        }
        .record .row .middle {
            width: 100%;
            float: none;
        }
    }

    @media (max-width: 768px) {
        .container.content {
            padding-left: 8px;
            padding-right: 8px;
        }
        .page-header h3,
        .page-header h4 {
            font-size: 1rem;
        }
        .record .panel-body {
            padding: 10px;
        }
        .list-container table.table > tbody > tr > td,
        .list-container table.table > thead > tr > th {
            padding: 5px 6px;
            font-size: 12px;
        }
    }

    /* ── Footer — minimal ── */
    footer {
        padding: 4px 0;
    }
    footer .credit {
        font-size: 11px;
    }

    /* ── Smooth transitions ── */
    .navbar, .container.content, .record .panel {
        transition: padding 0.15s ease;
    }
}

/* ── Bottom Navigation Bar ── */

#pwa-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 9999;
    display: none;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    background: #2c3e50;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.25);
    box-sizing: content-box;
}

.pwa-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none !important;
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    position: relative;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    padding: 6px 0 8px;
    gap: 2px;
    min-height: 56px;
    box-sizing: border-box;
}

.pwa-bottom-nav__item:hover,
.pwa-bottom-nav__item:focus {
    text-decoration: none !important;
    color: rgba(255, 255, 255, 0.85);
}

.pwa-bottom-nav__item.active {
    color: #5b9bd5;
}

.pwa-bottom-nav__indicator {
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 3px;
    background: transparent;
    border-radius: 0 0 3px 3px;
    transition: background 0.15s ease;
}

.pwa-bottom-nav__item.active .pwa-bottom-nav__indicator {
    background: #5b9bd5;
}

.pwa-bottom-nav__icon {
    font-size: 20px;
    line-height: 1;
}

.pwa-bottom-nav__label {
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    overflow: visible;
}

/* Show on narrow screens */
@media (max-width: 768px) {
    #pwa-bottom-nav {
        display: flex !important;
    }
    body {
        padding-bottom: 56px !important;
    }
    footer {
        margin-bottom: 56px;
    }
}

/* Always show in installed PWA (standalone) at any width */
@media (display-mode: standalone) {
    #pwa-bottom-nav {
        display: flex !important;
    }
    body {
        padding-bottom: 56px !important;
    }
    footer {
        margin-bottom: 56px;
    }
}
