/**
 * Team Portal - Mobile & Touch Optimized Styles
 * 
 * Mobile-first responsive design with:
 * - Touch-friendly UI elements
 * - Swipe gestures support
 * - Optimized for small screens
 * - App-like navigation
 * - Pull-to-refresh
 * - Bottom navigation
 * 
 * @package    Team Portal
 * @subpackage Mobile
 * @version    3.0.0
 */

/*==================================================
  Mobile-First Base Styles
==================================================*/
@media (max-width: 768px) {
    
    /* Improve touch targets */
    button,
    .button,
    a.button,
    input[type="submit"],
    input[type="button"],
    .wp-core-ui .button {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 24px;
        font-size: 16px;
    }
    
    /* Remove hover effects on mobile */
    * {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
    
    /* Improve form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }
    
    /* Better spacing */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
}

/*==================================================
  Bottom Navigation Bar (Mobile)
==================================================*/
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: none;
    z-index: 99999;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }
}

.mobile-bottom-nav-items {
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
}

.mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.3s ease;
    min-width: 60px;
    position: relative;
}

.mobile-bottom-nav-item.active {
    color: #667eea;
}

.mobile-bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0 0 3px 3px;
}

.mobile-bottom-nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.mobile-bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
}

.mobile-bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/*==================================================
  Mobile Header
==================================================*/
.mobile-header {
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 99998;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
}

.mobile-header-left,
.mobile-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.mobile-menu-button,
.mobile-search-button,
.mobile-notifications-button {
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
}

.mobile-menu-button:active,
.mobile-search-button:active,
.mobile-notifications-button:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

/*==================================================
  Mobile Sidebar/Menu
==================================================*/
.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: white;
    z-index: 999999;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-sidebar.active {
    right: 0;
}

.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.mobile-sidebar-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
}

.mobile-sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 40px;
}

.mobile-sidebar-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.mobile-sidebar-user-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.mobile-sidebar-user-info p {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.mobile-sidebar-menu {
    padding: 0;
    margin: 0;
    list-style: none;
}

.mobile-sidebar-menu-item {
    border-bottom: 1px solid #f3f4f6;
}

.mobile-sidebar-menu-item a {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: #374151;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-sidebar-menu-item a:active {
    background: #f9fafb;
}

.mobile-sidebar-menu-item.active a {
    background: #f0f4f8;
    color: #667eea;
    font-weight: 600;
}

.mobile-sidebar-menu-icon {
    font-size: 24px;
    margin-left: 12px;
    width: 40px;
    text-align: center;
}

/*==================================================
  Pull-to-Refresh
==================================================*/
.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.pull-to-refresh.pulling {
    transform: translateY(60px);
}

.pull-to-refresh-icon {
    font-size: 24px;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

/*==================================================
  Swipe Gesture Indicators
==================================================*/
.swipe-indicator {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(102, 126, 234, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 99997;
}

.swipe-indicator.left {
    left: 20px;
}

.swipe-indicator.right {
    right: 20px;
}

.swipe-indicator.active {
    opacity: 1;
    animation: swipePulse 0.6s ease infinite;
}

@keyframes swipePulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.1); }
}

/*==================================================
  Touch-Friendly Tables
==================================================*/
@media (max-width: 768px) {
    .wp-list-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .wp-list-table thead {
        display: none;
    }
    
    .wp-list-table tbody,
    .wp-list-table tr {
        display: block;
    }
    
    .wp-list-table tr {
        margin-bottom: 16px;
        background: white;
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .wp-list-table td {
        display: flex;
        justify-content: space-between;
        padding: 12px 0 !important;
        border: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
    }
    
    .wp-list-table td:last-child {
        border-bottom: none !important;
    }
    
    .wp-list-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        margin-left: 8px;
    }
}

/*==================================================
  Mobile Cards
==================================================*/
.mobile-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
}

.mobile-card-action {
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

/*==================================================
  Mobile Forms
==================================================*/
@media (max-width: 768px) {
    .mobile-form-group {
        margin-bottom: 20px;
    }
    
    .mobile-form-label {
        display: block;
        font-size: 14px;
        font-weight: 600;
        color: #374151;
        margin-bottom: 8px;
    }
    
    .mobile-form-input {
        width: 100%;
        min-height: 48px;
        padding: 12px 16px;
        border: 2px solid #e5e7eb;
        border-radius: 12px;
        font-size: 16px;
        transition: all 0.3s ease;
    }
    
    .mobile-form-input:focus {
        outline: none;
        border-color: #667eea;
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    }
}

/*==================================================
  Mobile Modals
==================================================*/
@media (max-width: 768px) {
    .mobile-modal {
        position: fixed;
        bottom: -100%;
        left: 0;
        right: 0;
        background: white;
        border-radius: 24px 24px 0 0;
        z-index: 999999;
        transition: bottom 0.3s ease;
        max-height: 90vh;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .mobile-modal.active {
        bottom: 0;
    }
    
    .mobile-modal-handle {
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 12px auto;
    }
    
    .mobile-modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .mobile-modal-title {
        font-size: 18px;
        font-weight: 700;
        color: #1f2937;
        margin: 0;
    }
    
    .mobile-modal-content {
        padding: 20px;
    }
}

/*==================================================
  Mobile Tabs
==================================================*/
.mobile-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
    gap: 8px;
}

.mobile-tabs::-webkit-scrollbar {
    display: none;
}

.mobile-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.mobile-tab.active {
    color: #667eea;
    font-weight: 700;
}

.mobile-tab.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/*==================================================
  Mobile Search
==================================================*/
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 999999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.mobile-search-overlay.active {
    transform: translateY(0);
}

.mobile-search-header {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-search-back {
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 10px;
    font-size: 24px;
    cursor: pointer;
}

.mobile-search-input {
    flex: 1;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 0 16px;
    font-size: 16px;
}

.mobile-search-results {
    padding: 20px;
}

/*==================================================
  Touch Feedback
==================================================*/
@media (hover: none) {
    button:active,
    .button:active,
    a:active {
        transform: scale(0.97);
        opacity: 0.8;
    }
}

/*==================================================
  Floating Action Button (FAB)
==================================================*/
.mobile-fab {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 99997;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .mobile-fab {
        display: flex;
    }
}

.mobile-fab:active {
    transform: scale(0.9);
}

/*==================================================
  Content Adjustments for Mobile Nav
==================================================*/
@media (max-width: 768px) {
    #wpbody-content {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
    
    .wrap {
        margin: 0;
        padding: 16px;
    }
    
    h1,
    .wp-heading-inline {
        font-size: 24px !important;
    }
    
    h2 {
        font-size: 20px !important;
    }
}

/*==================================================
  Hide Desktop Elements on Mobile
==================================================*/
@media (max-width: 768px) {
    #wpbody-content .page-title-action,
    #wpbody-content .subsubsub,
    .tablenav.top,
    .tablenav.bottom,
    #screen-meta-links,
    #screen-meta {
        display: none !important;
    }
}

/*==================================================
  Landscape Mode Optimizations
==================================================*/
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        padding: 8px 16px;
    }
    
    .mobile-bottom-nav {
        padding: 4px 0;
    }
    
    .mobile-bottom-nav-item {
        padding: 4px 8px;
    }
    
    .mobile-fab {
        bottom: calc(60px + env(safe-area-inset-bottom));
    }
}

/*==================================================
  Accessibility - Larger Touch Targets
==================================================*/
@media (max-width: 768px) {
    a,
    button,
    input,
    select,
    textarea {
        min-height: 44px;
    }
}

/*==================================================
  Prevent Text Selection During Swipe
==================================================*/
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/*==================================================
  Smooth Scrolling
==================================================*/
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/*==================================================
  Dark Mode for Mobile
==================================================*/
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .mobile-header,
    .mobile-bottom-nav,
    .mobile-sidebar,
    .mobile-card,
    .mobile-modal {
        background: #1e293b;
        border-color: #334155;
    }
    
    .mobile-header-title,
    .mobile-card-title,
    .mobile-modal-title {
        color: #f1f5f9;
    }
    
    .mobile-bottom-nav-item,
    .mobile-sidebar-menu-item a {
        color: #cbd5e1;
    }
    
    .mobile-bottom-nav-item.active,
    .mobile-sidebar-menu-item.active a {
        color: #818cf8;
    }
    
    .mobile-menu-button,
    .mobile-search-button,
    .mobile-notifications-button,
    .mobile-card-action {
        background: #334155;
        color: #f1f5f9;
    }
}
