/**
 ******************************************************************************
 * @file    mobile.css
 * @author  JanPNP Development Team
 * @brief   Mobile responsive styles for JanPNP web console
 *          Provides responsive layout adaptations for devices with width
 *          ≤ 768px, converting desktop sidebar to bottom navigation bar
 *          and optimizing UI elements for touch interaction.
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2026 JanPNP Development Team. All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */

@media (max-width: 768px) {

    .app {
        height: 100dvh;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(70px + env(safe-area-inset-bottom, 0px));
        flex-direction: row;
        justify-content: space-around;
        border-top: 1px solid var(--border-color);
        border-right: none;
        background: var(--sidebar-bg);
        z-index: 100;
        padding: 0 0 env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
        background-color: var(--sidebar-bg);
        overflow-y: hidden;
        overflow-x: hidden;
    }

    .logo,
    .sidebar-footer {
        display: none;
    }

    .nav-menu {
        display: flex;
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        padding-left: 10px;
        padding-right: 10px;
        padding-top: 0;
        padding-bottom: 0;
        margin: 0;
        height: 70px;
        align-items: center;
        box-sizing: border-box;
        overflow: visible;
    }

    .nav-item {
        flex: 1;
        justify-content: center;
        padding: 8px 4px;
        margin: 4px 6px;
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
        text-align: center;
        border-radius: 12px;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        user-select: none;
        overflow: visible;
    }

    .nav-item.active {
        border-radius: 12px;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
        object-fit: contain;
        flex-shrink: 0;
        display: block;
    }

    .main-content {
        margin-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        padding-bottom: 0;
    }

    .content {
        padding: 16px;
        padding-bottom: 28px;
        -webkit-overflow-scrolling: touch;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-info {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
    }

    .header-info .system-status {
        flex: 0 0 auto;
    }

    .header-info .datetime {
        flex: 1;
        min-width: 0;
        text-align: center;
        white-space: nowrap;
    }

    .header-info .mobile-logout-btn {
        flex: 0 0 auto;
        margin-left: 0;
    }

    .header-title h1 {
        font-size: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .settings-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .setting-control {
        width: 100%;
        text-align: left;
    }

    .order-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .order-table {
        min-width: 0;
    }

    .page-actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .filters {
        flex-direction: column;
        gap: 8px;
    }

    .filter-select,
    .search-input {
        width: 100%;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    select,
    textarea {
        min-height: 42px;
        font-size: 16px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        max-height: calc(100dvh - 32px);
        margin: 0 auto;
        overflow-y: auto;
    }

    .terminal-wrapper {
        height: 400px;
    }

    .commands-grid {
        grid-template-columns: 1fr;
    }

    .command-buttons {
        gap: 8px;
    }

    .quick-cmd {
        padding: 6px 12px;
        font-size: 12px;
    }

    .terminal-content {
        font-size: 11px;
    }

    .terminal-input {
        font-size: 12px;
    }

    .about-info {
        text-align: center;
    }

    .about-actions {
        flex-direction: column;
        gap: 10px;
    }

    .pagination-controls {
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
        justify-content: flex-start;
    }

    .page-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 36px;
        flex-shrink: 0;
    }

    .pagination-controls span {
        flex-shrink: 0;
        padding: 0 2px;
        color: var(--text-secondary);
    }

    .recent-order-card,
    .live-view-card,
    .system-status-card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 14px;
    }

    .recent-order-card h3,
    .live-view-card h3,
    .system-status-card h3 {
        font-size: 17px;
    }

    .status-item {
        gap: 8px;
        min-width: 0;
    }

    .status-label,
    .status-value {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .datetime {
        font-size: 12px;
    }

    .btn,
    .page-btn,
    .tab-btn {
        touch-action: manipulation;
    }

    .confirm-content {
        width: calc(100vw - 32px);
        max-height: calc(100dvh - 32px);
    }

}

@media (max-width: 480px) {
    .nav-item span {
        font-size: 10px;
    }

    .nav-icon {
        width: 18px;
        height: 18px;
    }

    .stat-value {
        font-size: 24px;
    }

    .content {
        padding: 12px;
        padding-bottom: 24px;
    }

    .header {
        padding: 12px;
    }

    .header-title h1 {
        font-size: 19px;
    }

    .header-info {
        gap: 8px;
        font-size: 11px;
    }

    .order-page .order-table th:nth-child(2),
    .order-page .order-table td:nth-child(2),
    .order-page .order-table th:nth-child(3),
    .order-page .order-table td:nth-child(3),
    .recent-order-card .order-table th:nth-child(2),
    .recent-order-card .order-table td:nth-child(2) {
        display: none;
    }

    .order-table th,
    .order-table td {
        padding: 9px 6px;
    }

    .order-table .btn-icon {
        min-height: 32px;
        padding: 5px 7px;
    }

    .terminal-prompt {
        font-size: 12px;
    }

    .terminal-input {
        font-size: 11px;
    }

    .mobile-logout-btn {
        display: block;
        background: transparent;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 6px 12px;
        font-size: 12px;
        color: var(--text-secondary);
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-logout-btn:hover {
        background: var(--danger-color);
        border-color: var(--danger-color);
        color: white;
    }

    .page-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 32px;
    }

    .pagination-controls {
        gap: 4px;
    }
}
