/**
 * Mobile-Specific Enhancements
 * Additional styles to improve mobile user experience
 */

/* ========================================
   MOBILE HEADER GRADIENT
   ======================================== */

@media (max-width: 991.98px) {
    #kt_app_header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
    
    #kt_app_header .page-heading,
    #kt_app_header .fs-7,
    #kt_app_header .fw-semibold {
        color: white !important;
    }
    
    #kt_app_header .btn-icon {
        color: white !important;
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
    }
    
    #kt_app_header .btn-icon:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    #kt_app_header .symbol img {
        border: 2px solid white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
}

/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */

@media (max-width: 767.98px) {
    /* Fixed bottom navigation for quick access */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0 10px;
    }
    
    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: rgba(255, 255, 255, 0.7);
        text-decoration: none;
        font-size: 0.7rem;
        transition: all 0.3s ease;
        padding: 5px;
        flex: 1;
    }
    
    .mobile-bottom-nav a i {
        font-size: 1.5rem;
        margin-bottom: 3px;
    }
    
    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:hover {
        color: white;
        transform: translateY(-3px);
    }
    
    /* Add padding to body to account for bottom nav */
    body {
        padding-bottom: 70px;
    }
}

/* ========================================
   MOBILE FLOATING ACTION BUTTON
   ======================================== */

@media (max-width: 767.98px) {
    .mobile-fab {
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        z-index: 999;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-fab:active {
        transform: scale(0.95);
    }
    
    .mobile-fab i {
        color: white;
        font-size: 1.5rem;
    }
}

/* ========================================
   MOBILE CARD ENHANCEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    .card-header {
        border-radius: 12px 12px 0 0;
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    }
    
    /* Swipe indicator for cards */
    .card-swipeable::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 2px;
    }
}

/* ========================================
   MOBILE TABLE IMPROVEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    /* Card-style table rows on mobile */
    .table-mobile-cards tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 10px;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .table-mobile-cards tbody td {
        display: block;
        text-align: right;
        padding: 8px;
        border: none;
        position: relative;
        padding-left: 50%;
    }
    
    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: 600;
        text-align: left;
    }
    
    .table-mobile-cards thead {
        display: none;
    }
}

/* ========================================
   MOBILE FORM ENHANCEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    /* Better form field styling */
    .form-control,
    .form-select {
        border-radius: 8px;
        padding: 12px 15px;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 2px solid #e5e7eb;
        transition: border-color 0.3s ease;
    }
    
    .form-control:focus,
    .form-select:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    }
    
    /* Form labels */
    .form-label {
        font-weight: 600;
        margin-bottom: 8px;
        color: #374151;
    }
    
    /* Required field indicator */
    .required::after {
        content: ' *';
        color: #ef4444;
    }
}

/* ========================================
   MOBILE BUTTON STYLES
   ======================================== */

@media (max-width: 767.98px) {
    .btn {
        border-radius: 8px;
        padding: 12px 20px;
        font-weight: 600;
        transition: all 0.3s ease;
    }
    
    .btn-primary {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }
    
    .btn-primary:active {
        transform: scale(0.98);
    }
    
    /* Button icons */
    .btn i {
        margin-right: 5px;
    }
}

/* ========================================
   MOBILE MODAL IMPROVEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    .modal {
        padding: 0 !important;
    }
    
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-content {
        border-radius: 0;
        border: none;
        height: 100%;
        overflow-y: auto;
    }
    
    .modal-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        position: sticky;
        top: 0;
        z-index: 1;
    }
    
    .modal-header .btn-close {
        filter: brightness(0) invert(1);
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    }
}

/* ========================================
   MOBILE ALERTS & TOASTS
   ======================================== */

@media (max-width: 767.98px) {
    .alert {
        border-radius: 8px;
        padding: 12px 15px;
        margin-bottom: 10px;
    }
    
    /* Toast notifications */
    .toast {
        max-width: calc(100% - 20px);
        margin: 10px;
    }
}

/* ========================================
   MOBILE BREADCRUMBS
   ======================================== */

@media (max-width: 767.98px) {
    .breadcrumb {
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        padding: 8px 12px;
        border-radius: 8px;
        margin-bottom: 10px;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        content: '›';
        font-size: 1.2rem;
    }
}

/* ========================================
   MOBILE DROPDOWN MENUS
   ======================================== */

@media (max-width: 767.98px) {
    .dropdown-menu {
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        border: none;
        margin-top: 10px;
    }
    
    .dropdown-item {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    .dropdown-item:hover {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    }
}

/* ========================================
   MOBILE SEARCH BAR
   ======================================== */

@media (max-width: 767.98px) {
    .search-mobile {
        position: relative;
        margin: 10px 15px;
    }
    
    .search-mobile input {
        width: 100%;
        padding: 12px 40px 12px 15px;
        border-radius: 20px;
        border: 2px solid #e5e7eb;
        font-size: 16px;
    }
    
    .search-mobile i {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
    }
}

/* ========================================
   MOBILE TABS
   ======================================== */

@media (max-width: 767.98px) {
    .nav-tabs {
        border-bottom: 2px solid #e5e7eb;
        margin-bottom: 15px;
    }
    
    .nav-tabs .nav-link {
        border: none;
        border-bottom: 3px solid transparent;
        color: #6b7280;
        font-weight: 600;
        padding: 10px 15px;
    }
    
    .nav-tabs .nav-link.active {
        border-bottom-color: #667eea;
        color: #667eea;
        background: transparent;
    }
}

/* ========================================
   MOBILE BADGES
   ======================================== */

@media (max-width: 767.98px) {
    .badge {
        padding: 5px 10px;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 600;
    }
}

/* ========================================
   MOBILE PROGRESS BARS
   ======================================== */

@media (max-width: 767.98px) {
    .progress {
        height: 8px;
        border-radius: 4px;
        background: #e5e7eb;
    }
    
    .progress-bar {
        background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
        border-radius: 4px;
    }
}

/* ========================================
   MOBILE LOADING STATES
   ======================================== */

@media (max-width: 767.98px) {
    .skeleton-loader {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
        border-radius: 8px;
    }
    
    @keyframes loading {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }
}

/* ========================================
   MOBILE PULL TO REFRESH
   ======================================== */

@media (max-width: 767.98px) {
    .pull-to-refresh {
        position: absolute;
        top: -60px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 40px;
        background: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
    }
    
    .pull-to-refresh.active {
        top: 10px;
    }
}

/* ========================================
   MOBILE EMPTY STATES
   ======================================== */

@media (max-width: 767.98px) {
    .empty-state {
        text-align: center;
        padding: 40px 20px;
    }
    
    .empty-state i {
        font-size: 4rem;
        color: #d1d5db;
        margin-bottom: 15px;
    }
    
    .empty-state h3 {
        font-size: 1.2rem;
        color: #374151;
        margin-bottom: 10px;
    }
    
    .empty-state p {
        color: #6b7280;
        margin-bottom: 20px;
    }
}

/* ========================================
   MOBILE SAFE AREA INSETS (iOS)
   ======================================== */

@media (max-width: 767.98px) {
    @supports (padding: max(0px)) {
        body {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
            padding-bottom: max(70px, env(safe-area-inset-bottom));
        }
        
        #kt_app_header {
            padding-top: max(0px, env(safe-area-inset-top));
        }
        
        .mobile-bottom-nav {
            padding-bottom: max(0px, env(safe-area-inset-bottom));
            height: calc(60px + max(0px, env(safe-area-inset-bottom)));
        }
    }
}

/* ========================================
   MOBILE HAPTIC FEEDBACK SIMULATION
   ======================================== */

@media (max-width: 767.98px) {
    .btn:active,
    .card:active,
    .menu-link:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* ========================================
   MOBILE OVERFLOW SCROLL INDICATORS
   ======================================== */

@media (max-width: 767.98px) {
    .scroll-indicator {
        position: relative;
    }
    
    .scroll-indicator::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(90deg, transparent, white 50%);
        padding: 10px;
        color: #667eea;
        font-weight: bold;
        pointer-events: none;
    }
}
