/**
 * Mobile Responsive Styles - IoT Monitoring CS
 * Bottom Navigation & Responsive Tables
 */

/* ============================================
   DATA LOG CARD MOBILE STYLES
   ============================================ */

.data-log-card-mobile {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.data-log-card-mobile .log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.data-log-card-mobile .log-time {
    font-size: 12px;
    font-weight: 600;
    color: #344767;
}

.data-log-card-mobile .log-data {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.data-log-card-mobile .log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.data-log-card-mobile .log-label {
    font-size: 11px;
    font-weight: 600;
    color: #67748e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bottom-nav {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 1050;
    padding: 4px 0;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav .nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #67748e;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    min-width: 60px;
}

.bottom-nav .nav-item svg {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
    transition: all 0.3s ease;
    color: #67748e;
}

.bottom-nav .nav-item span {
    white-space: nowrap;
    transition: all 0.3s ease;
}

.bottom-nav .nav-item:hover {
    color: #0077b6;
    background: rgba(0, 119, 182, 0.08);
}

.bottom-nav .nav-item:hover svg {
    color: #0077b6;
}

.bottom-nav .nav-item.active {
    color: #0077b6;
}

.bottom-nav .nav-item.active svg {
    color: #0077b6;
    transform: scale(1.1);
}

.bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: linear-gradient(90deg, #0077b6, #00bcd4);
    border-radius: 0 0 4px 4px;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media (max-width: 991.98px) {

    /* Show bottom navigation on mobile/tablet */
    .bottom-nav {
        display: block;
    }

    /* Hide sidebar on mobile */
    .sidenav {
        transform: translateX(-100%);
    }

    .sidenav.show {
        transform: translateX(0);
    }

    /* Adjust main content when sidebar is hidden */
    .main-content {
        margin-left: 0 !important;
    }

    /* Add padding bottom for bottom nav */
    .main-content .container-fluid {
        padding-bottom: 75px !important;
    }

    /* Toggle button for sidebar on mobile */
    .sidenav-toggler {
        display: block !important;
    }

    /* ============================================
       COMPACT NAVBAR FOR MOBILE
       ============================================ */

    /* Make navbar compact */
    .navbar-main {
        padding: 4px 8px !important;
        min-height: auto !important;
    }

    .navbar-main .container-fluid {
        padding: 4px 8px !important;
    }

    /* Hide breadcrumb on mobile */
    .navbar-main .breadcrumb {
        display: none !important;
    }

    /* Reduce page title size */
    .navbar-main h6 {
        font-size: 13px !important;
        margin-bottom: 0 !important;
    }

    /* Compact nav items */
    .navbar-main .navbar-nav {
        gap: 4px;
    }

    .navbar-main .nav-item {
        padding: 0 4px !important;
    }

    .navbar-main .nav-link {
        padding: 4px !important;
        font-size: 12px;
    }

    .navbar-main .nav-link i {
        font-size: 14px;
    }

    /* Hide "Sign Out" text on mobile, show only icon */
    .navbar-main .nav-link span {
        display: none !important;
    }

    /* Hide settings icon on mobile (use bottom nav instead) */
    .navbar-main .fixed-plugin-button-nav {
        display: none !important;
    }

    /* Hide notification dropdown on very small screens */
    .navbar-main #dropdownMenuButton {
        display: none;
    }

    /* Collapse the navbar properly */
    .navbar-main .collapse.navbar-collapse {
        margin-top: 0 !important;
    }
}

@media (max-width: 767.98px) {
    /* ============================================
       MOBILE CARD-BASED TABLE STYLES
       ============================================ */

    /* Hide table headers on mobile */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody {
        display: block;
    }

    .table-mobile-cards tbody tr {
        display: block;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        margin: 12px 16px;
        padding: 16px;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .table-mobile-cards tbody tr:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }

    .table-mobile-cards tbody td {
        display: block;
        text-align: left !important;
        padding: 6px 0;
        border: none;
    }

    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 10px;
        color: #67748e;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: block;
        margin-bottom: 4px;
    }

    /* Patient card header styling */
    .table-mobile-cards .patient-name {
        font-size: 16px;
        font-weight: 700;
        color: #344767;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    /* Mobile action buttons */
    .table-mobile-cards .mobile-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .table-mobile-cards .mobile-actions .btn {
        flex: 1;
        min-width: calc(50% - 4px);
        padding: 10px 12px;
        font-size: 12px;
        font-weight: 600;
    }

    /* ============================================
       MONITOR PAGE MOBILE STYLES
       ============================================ */

    /* Stats cards adjustments */
    .col-xl-3.col-sm-6 {
        margin-bottom: 8px;
    }

    .col-xl-3.col-sm-6 .card-body {
        padding: 10px !important;
    }

    .col-xl-3.col-sm-6 .numbers p {
        font-size: 11px;
    }

    .col-xl-3.col-sm-6 .numbers h5 {
        font-size: 18px;
    }

    /* Chart containers */
    .chart {
        height: 200px !important;
    }

    .chart canvas {
        max-height: 200px !important;
    }

    /* Range slider mobile */
    .range-slider-container {
        padding: 0 8px;
    }

    /* Export dropdown mobile */
    .dropdown-menu {
        width: 100%;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
    }

    /* Data Log table mobile cards */
    .data-log-table thead {
        display: none;
    }

    .data-log-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        margin: 12px 0;
        padding: 16px;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .data-log-table tbody td {
        padding: 4px 0;
        border: none;
        text-align: left !important;
    }

    .data-log-table tbody td:first-child {
        grid-column: 1 / -1;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        padding-bottom: 8px;
        margin-bottom: 4px;
    }

    .data-log-table tbody td:last-child {
        grid-column: 1 / -1;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    /* Header controls mobile */
    .card-header .d-flex.align-items-center.gap-2 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .card-header form.d-flex {
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-header .dropdown {
        width: 100%;
    }

    .card-header .dropdown .btn {
        width: 100%;
    }

    /* Monitor page header mobile */
    .card-body .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* ============================================
       PATIENTS INDEX MOBILE STYLES
       ============================================ */

    /* Tab pills mobile */
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .nav-pills .nav-item {
        flex-shrink: 0;
    }

    .nav-pills .nav-link {
        white-space: nowrap;
        font-size: 12px;
        padding: 8px 16px;
    }

    /* Hide less important columns on mobile */
    .hide-on-mobile {
        display: none !important;
    }

    /* Patient list card view */
    .patient-card-mobile {
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        margin: 8px 10px;
        padding: 12px;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .patient-card-mobile .patient-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .patient-card-mobile .patient-name {
        font-size: 15px;
        font-weight: 700;
        color: #344767;
        margin: 0;
    }

    .patient-card-mobile .patient-id {
        font-size: 11px;
        color: #67748e;
    }

    .patient-card-mobile .patient-info {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin-bottom: 8px;
    }

    .patient-card-mobile .info-item {
        font-size: 12px;
    }

    .patient-card-mobile .info-label {
        font-size: 10px;
        color: #67748e;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: block;
    }

    .patient-card-mobile .patient-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .patient-card-mobile .patient-actions .btn {
        padding: 8px;
        font-size: 11px;
        font-weight: 600;
    }

    .patient-card-mobile .patient-actions .btn-full {
        grid-column: 1 / -1;
    }

    /* ============================================
       GENERAL MOBILE ADJUSTMENTS
       ============================================ */

    /* Page title */
    h5.mb-0,
    h6.mb-0 {
        font-size: 14px;
    }

    /* Cards spacing */
    .card {
        margin-bottom: 8px;
    }

    .card-body {
        padding: 12px;
    }

    .card-header {
        padding: 12px;
    }

    /* Container padding */
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Buttons */
    .btn-sm {
        padding: 6px 12px;
        font-size: 11px;
    }

    /* Navbar top */
    .navbar-main {
        padding: 6px 10px;
    }

    /* Badge sizes */
    .badge-lg {
        font-size: 11px;
        padding: 6px 12px;
    }

    /* Progress bar in cards */
    .progress {
        height: 6px;
    }

    /* Row margins */
    .row {
        margin-left: -4px;
        margin-right: -4px;
    }

    .row>[class*="col-"] {
        padding-left: 4px;
        padding-right: 4px;
    }

    /* Main content top margin */
    .main-content.mt-1 {
        margin-top: 0 !important;
    }

    /* Reduce gaps everywhere */
    .gap-1 {
        gap: 4px !important;
    }

    .gap-2 {
        gap: 6px !important;
    }

    .gap-3 {
        gap: 8px !important;
    }

    .mb-4 {
        margin-bottom: 8px !important;
    }

    .mt-4 {
        margin-top: 8px !important;
    }

    .py-4 {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
}

/* ============================================
   VERY SMALL SCREENS (iPhone SE, etc)
   ============================================ */

@media (max-width: 375px) {
    .bottom-nav .nav-item {
        padding: 4px 8px;
        min-width: 50px;
    }

    .bottom-nav .nav-item i {
        font-size: 18px;
    }

    .bottom-nav .nav-item span {
        font-size: 9px;
    }

    .patient-card-mobile .patient-info {
        grid-template-columns: 1fr;
    }

    .patient-card-mobile .patient-actions {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   DARK MODE SUPPORT (if needed)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .bottom-nav {
        background: rgba(30, 30, 40, 0.95);
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .bottom-nav .nav-item {
        color: #a0aec0;
    }

    .bottom-nav .nav-item:hover,
    .bottom-nav .nav-item.active {
        color: #00bcd4;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION ADJUSTMENTS
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .bottom-nav {
        height: 56px;
        padding: 4px 0;
    }

    .bottom-nav .nav-item i {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .bottom-nav .nav-item span {
        font-size: 9px;
    }

    .main-content .container-fluid {
        padding-bottom: 70px !important;
    }
}