/* ========================================
   F&B MASTER - MOBILE STYLES
   Mobile-First UI/UX Optimizations
   ======================================== */

/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(26, 26, 46, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
}

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

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    min-width: 56px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:active {
    transform: scale(0.92);
}

.mobile-nav-item.active {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.15);
}

.mobile-nav-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.mobile-nav-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ========================================
   MOBILE HEADER ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
    .mobile-nav {
        display: block;
    }

    /* FULL SCREEN - No padding waste */
    body {
        overflow-x: hidden;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100vw;
    }

    .page-content {
        padding: 8px !important;
        padding-bottom: 80px !important;
    }

    /* Compact header */
    .main-header {
        height: 50px;
        padding: 0 8px;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .header-left h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }

    .header-date {
        display: none;
    }

    /* Hide desktop elements */
    .header-right .search-box {
        display: none;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .header-right {
        gap: 6px;
    }

    /* Sidebar overlay */
    .sidebar {
        width: 85vw;
        max-width: 300px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 99;
        backdrop-filter: blur(4px);
    }

    .sidebar.active+.sidebar-overlay,
    .sidebar-overlay.active {
        display: block;
    }

    /* ========================================
       FULL-WIDTH TABLES - WOW MOBILE
       ======================================== */
    .menu-management,
    .menu-section,
    .menu-table-container,
    .inventory-table-container,
    .staff-table-container,
    .customers-table-container,
    .orders-table-container {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .data-table {
        width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    .data-table th {
        font-size: 0.7rem;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 10;
    }

    /* Menu Header - Full Width Buttons */
    .menu-header {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .menu-header h3 {
        font-size: 1rem;
        text-align: center;
    }

    .menu-header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        width: 100%;
    }

    .menu-header-actions button {
        width: 100%;
        padding: 10px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Menu Tabs */
    .menu-tabs {
        display: flex;
        gap: 4px;
        padding: 8px;
    }

    .menu-tab {
        flex: 1;
        text-align: center;
        padding: 10px 6px;
        font-size: 0.8rem;
    }
}

/* ========================================
   TOUCH-FRIENDLY COMPONENTS
   ======================================== */
@media (max-width: 768px) {

    /* Larger touch targets */
    .btn-primary,
    .btn-secondary,
    .btn-icon-sm,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    /* Form inputs */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        min-height: 48px;
        font-size: 16px !important;
        /* Prevent zoom on iOS */
        padding: 12px 14px;
    }

    /* Category tabs - horizontal scroll */
    .category-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
        padding: 8px 0;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .category-tab {
        flex-shrink: 0;
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

/* ========================================
   MOBILE POS LAYOUT
   ======================================== */
@media (max-width: 768px) {
    .pos-container {
        flex-direction: column;
        gap: 0;
    }

    .pos-menu {
        width: 100%;
        padding: 12px;
        padding-bottom: 0;
    }

    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .menu-item {
        padding: 12px;
    }

    .menu-item-name {
        font-size: 0.85rem;
    }

    .menu-item-price {
        font-size: 0.9rem;
    }

    /* Floating cart */
    .pos-cart {
        position: fixed;
        bottom: 64px;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 45vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
        transform: translateY(calc(100% - 60px));
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
    }

    .pos-cart.expanded {
        transform: translateY(0);
    }

    .cart-header {
        cursor: pointer;
        padding: 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .cart-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--text-muted);
        border-radius: 2px;
        margin: 0 auto 12px;
    }

    .cart-items {
        max-height: 25vh;
        overflow-y: auto;
    }

    .cart-actions {
        flex-direction: column;
        gap: 8px;
    }

    .cart-actions button {
        width: 100%;
    }
}

/* ========================================
   MOBILE CARDS (Table Alternative)
   ======================================== */
.mobile-card-view {
    display: none;
}

@media (max-width: 768px) {

    .data-table-container,
    .orders-table-container,
    .inventory-table-container,
    .staff-table-container,
    .customers-table-container {
        overflow-x: visible;
    }

    /* Show card view on mobile */
    .mobile-card-view {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mobile-card {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        padding: 16px;
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
    }

    .mobile-card-title {
        font-weight: 600;
        font-size: 1rem;
    }

    .mobile-card-badge {
        padding: 4px 10px;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 500;
    }

    .mobile-card-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .mobile-card-item {
        display: flex;
        flex-direction: column;
    }

    .mobile-card-label {
        font-size: 0.7rem;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 2px;
    }

    .mobile-card-value {
        font-size: 0.9rem;
        font-weight: 500;
    }

    .mobile-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }

    .mobile-card-btn {
        flex: 1;
        padding: 10px;
        border-radius: 10px;
        border: none;
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
    }
}

/* ========================================
   MOBILE KPI CARDS
   ======================================== */
@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kpi-card {
        padding: 16px;
        flex-direction: row;
        align-items: center;
    }

    .kpi-icon {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .kpi-content h3 {
        font-size: 1.3rem;
    }

    .kpi-content p {
        font-size: 0.8rem;
    }

    .kpi-trend {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}

/* ========================================
   MOBILE ORDERS (KANBAN)
   ======================================== */
@media (max-width: 768px) {
    .orders-kanban {
        flex-direction: column;
        gap: 16px;
    }

    .kanban-column {
        width: 100%;
    }

    .kanban-header {
        padding: 12px 16px;
    }

    .kanban-cards {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* ========================================
   MOBILE KITCHEN DISPLAY
   ======================================== */
@media (max-width: 768px) {
    .kitchen-orders-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kitchen-order-card {
        padding: 16px;
    }
}

/* ========================================
   MOBILE TABLES (Floor Plan)
   ======================================== */
@media (max-width: 768px) {
    .tables-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .table-card {
        padding: 16px;
    }

    .table-number {
        font-size: 1.25rem;
    }
}

/* ========================================
   MOBILE MODALS
   ======================================== */
@media (max-width: 768px) {
    .modal {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        margin: 5vh auto;
        border-radius: 20px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 16px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* ========================================
   MOBILE ANALYTICS
   ======================================== */
@media (max-width: 768px) {
    .analytics-header {
        flex-direction: column;
        gap: 12px;
    }

    .analytics-filters {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .quick-filters {
        display: flex;
        overflow-x: auto;
        gap: 8px;
    }

    .quick-filter-btn {
        flex-shrink: 0;
        padding: 8px 16px;
    }

    .date-picker-group {
        display: flex;
        gap: 8px;
    }

    .date-picker-group input {
        flex: 1;
    }

    .analytics-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .analytics-charts {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   MOBILE MENU MANAGEMENT
   ======================================== */
@media (max-width: 768px) {
    .menu-tabs {
        display: flex;
        gap: 8px;
    }

    .menu-tab {
        flex: 1;
        text-align: center;
        padding: 12px;
    }

    .menu-header {
        flex-direction: column;
        gap: 12px;
    }

    .menu-header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .menu-header-actions button {
        flex: 1;
        min-width: calc(50% - 4px);
    }
}

/* ========================================
   SWIPE GESTURES SUPPORT
   ======================================== */
.swipeable {
    touch-action: pan-y;
    user-select: none;
}

.swipe-actions {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    background: var(--danger);
    color: white;
    padding: 0 20px;
    align-items: center;
    justify-content: center;
    border-radius: 0 16px 16px 0;
}

/* ========================================
   PULL TO REFRESH
   ======================================== */
.pull-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border-radius: 0 0 12px 12px;
    font-size: 0.85rem;
    z-index: 1001;
}

.pull-indicator.active {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
    }

    to {
        transform: translateX(-50%) translateY(0);
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
@media (max-width: 768px) {

    /* Optimize scrolling */
    .page-content,
    .cart-items,
    .kanban-cards,
    .modal-body {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Reduce animations on mobile */
    .kpi-card:hover {
        transform: none;
    }

    body::before,
    body::after {
        animation: none;
    }

    /* Optimize backdrop-filter usage */
    .kpi-card {
        backdrop-filter: none;
    }
}

/* ========================================
   SAFE AREA SUPPORT (iPhone X+)
   ======================================== */
@supports (padding: max(0px)) {
    .mobile-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        height: calc(64px + env(safe-area-inset-bottom));
    }

    .page-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-nav {
        height: 56px;
    }

    .mobile-nav-icon {
        font-size: 1.25rem;
    }

    .mobile-nav-label {
        display: none;
    }

    .pos-cart {
        max-height: 60vh;
    }
}

/* ========================================
   LIGHT MODE MOBILE
   ======================================== */
body.light-mode .mobile-nav {
    background: rgba(255, 255, 255, 0.98);
    border-top-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .mobile-nav-item.active {
    background: rgba(99, 102, 241, 0.1);
}

body.light-mode .mobile-card {
    background: rgba(255, 255, 255, 0.95);
}