/* ========================================
   MOBILE OPTIMIZATIONS - COMPREHENSIVE
   ======================================== */

@media (max-width: 768px) {
    /* ========== MOBILE TAB BAR - ENHANCED ========== */
    .mobile-tab-bar {
        display: block !important;
        padding: 10px 0 max(10px, env(safe-area-inset-bottom));
        box-shadow: 0 -2px 20px rgba(102, 126, 234, 0.25);
    }

    .mobile-tab-container {
        padding: 0 5px;
    }

    .mobile-tab-item {
        padding: 10px 6px;
        min-width: 60px;
    }

    .mobile-tab-icon {
        width: 26px;
        height: 26px;
        stroke-width: 2.5;
    }

    .mobile-tab-label {
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.3px;
    }

    .mobile-tab-item.active {
        transform: translateY(-6px);
    }

    .mobile-tab-item.active::after {
        width: 40px;
        height: 3px;
        top: -3px;
    }

    .mobile-tab-item.active .mobile-tab-icon {
        transform: scale(1.2);
    }

    /* Add padding to body to account for tab bar */
    body {
        padding-top: 60px;
        padding-bottom: 70px;
    }

    /* ========== MOBILE HEADER - PROFESSIONAL REDESIGN ========== */
    .header-nav {
        display: none !important;
    }

    .main-header {
        padding: 0;
        box-shadow: 0 2px 12px rgba(102, 126, 234, 0.15);
    }

    .header-container {
        padding: 12px 15px !important;
        gap: 10px !important;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
    }

    .logo-section {
        min-width: auto !important;
        gap: 8px;
        flex-shrink: 0;
    }

    .logo-icon svg {
        width: 36px !important;
        height: 36px !important;
    }

    .logo-title {
        font-size: 1.1rem !important;
        font-weight: 700;
    }

    .logo-subtitle {
        font-size: 0.65rem !important;
        opacity: 0.9;
    }

    .header-controls {
        display: flex !important;
        gap: 6px !important;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        min-width: auto !important;
        flex-shrink: 1;
    }

    #languageSwitcher {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        border-radius: 10px !important;
        min-width: 50px;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        flex-shrink: 0;
    }

    #userSection {
        display: flex !important;
        gap: 6px !important;
        align-items: center;
        flex-shrink: 1;
        min-width: 0;
    }

    .user-dropdown {
        padding: 6px 8px !important;
        white-space: nowrap !important;
        border-radius: 12px !important;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.25);
        display: flex !important;
        align-items: center;
        gap: 6px;
        min-width: 0;
        max-width: 100%;
        flex-shrink: 1;
    }

    #userAvatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.95rem !important;
        flex-shrink: 0;
        border: 2px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    #userName {
        display: none !important;
    }

    #logoutBtn {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
        border-radius: 10px !important;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        flex-shrink: 0;
        white-space: nowrap;
        min-width: auto;
    }

    #logoutBtn:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.3);
    }

    #authButton {
        padding: 8px 14px !important;
        font-size: 0.75rem !important;
        border-radius: 12px !important;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.95);
        color: #667eea;
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        flex-shrink: 0;
        white-space: nowrap;
    }

    #authButton:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }

    .header-btn {
        display: none !important;
    }

    /* ========== ADMIN SECTION MOBILE ========== */
    .admin-section {
        padding: 20px 15px !important;
        border-radius: 15px;
        margin: 15px;
    }

    .admin-section h2 {
        font-size: 1.4rem !important;
        margin-bottom: 20px;
    }

    .admin-section h3 {
        font-size: 1.1rem !important;
        margin: 20px 0 12px 0;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0;
        margin-bottom: 20px;
    }

    .admin-stat-card {
        padding: 18px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .admin-stat-card h4 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .admin-stat-card .stat-value {
        font-size: 1.8rem;
    }

    /* ========== MOBILE TABLES - PROFESSIONAL DESIGN ========== */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 15px -15px;
        padding: 0 15px;
        scrollbar-width: thin;
        scrollbar-color: #667eea #f0f0f0;
    }

    .table-wrapper::-webkit-scrollbar {
        height: 6px;
    }

    .table-wrapper::-webkit-scrollbar-track {
        background: #f0f0f0;
        border-radius: 3px;
    }

    .table-wrapper::-webkit-scrollbar-thumb {
        background: #667eea;
        border-radius: 3px;
    }

    .table-wrapper::-webkit-scrollbar-thumb:hover {
        background: #5568d3;
    }

    .admin-table {
        min-width: 600px;
        font-size: 0.85rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-radius: 12px;
        overflow: hidden;
    }

    .admin-table th {
        padding: 10px 8px;
        font-size: 0.8rem;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 10;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-right: 1px solid rgba(255, 255, 255, 0.2);
    }

    .admin-table th:last-child {
        border-right: none;
    }

    .admin-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
        border: 1px solid #e8e8e8;
        border-top: none;
        white-space: nowrap;
    }

    .admin-table tr:nth-child(even) {
        background: #f8f9ff;
    }

    .admin-table tr:hover {
        background: #eff1ff;
    }

    .admin-badge {
        padding: 3px 8px;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    /* Chart Container Mobile */
    .chart-container {
        height: 250px;
        padding: 15px;
        margin: 15px 0;
        border-radius: 12px;
    }

    /* Activity Feed Mobile */
    .activity-feed {
        max-height: 400px;
        border-radius: 12px;
        padding: 10px;
    }

    .activity-item {
        padding: 12px;
        font-size: 0.85rem;
        border-radius: 10px;
        margin-bottom: 8px;
    }

    /* WhatsApp Button Mobile - Position Above FAB */
    #whatsappFloatingBtn {
        bottom: 160px;
        right: 20px;
        left: auto;
    }

    .whatsapp-float {
        width: 56px;
        height: 56px;
    }

    .whatsapp-float svg {
        width: 28px;
        height: 28px;
    }

    /* FAB Mobile Responsive */
    .fab-container {
        bottom: 90px;
        right: 20px;
    }

    .fab-main {
        width: 56px;
        height: 56px;
    }

    .fab-icon {
        width: 18px;
        height: 18px;
    }

    .fab-item-button {
        width: 52px;
        height: 52px;
    }

    .fab-item-button svg {
        width: 18px;
        height: 18px;
    }

    .fab-label {
        font-size: 0.8rem;
        padding: 8px 12px;
        bottom: 65px;
        min-width: 120px;
    }

    /* Main Content Mobile */
    .main-content {
        padding: 15px;
        padding-bottom: 100px;
    }

    /* Upload Section Mobile */
    .upload-section {
        padding: 15px;
        margin: 15px;
    }

    .upload-area {
        padding: 30px 20px;
        min-height: 180px;
    }

    .upload-icon {
        font-size: 2.5rem;
        margin-bottom: 15px;
    }

    .upload-text {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .upload-hint {
        font-size: 0.75rem;
    }

    /* Modal Improvements */
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
        border-radius: 16px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }

    .auth-modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
        border-radius: 16px;
        padding: 25px 20px;
    }

    .close-modal {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 50%;
    }

    /* Buttons Mobile Enhancement */
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        border-radius: 12px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:active {
        transform: scale(0.97);
    }

    /* Input Fields Mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 0.95rem;
        border-radius: 10px;
        touch-action: manipulation;
    }

    /* Alert Messages Mobile */
    .alert {
        margin: 15px;
        padding: 12px 15px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    /* Loading Spinner Mobile */
    .loading {
        padding: 30px;
        font-size: 0.9rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }

    /* Smooth Scrolling on Mobile */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* ========== SERVICES SECTION MOBILE FIX ========== */
    .featured-service-section {
        padding: 20px 15px;
        margin: 0;
    }

    .featured-service-card {
        padding: 25px 15px;
        margin: 0;
        border-radius: 15px;
        overflow: hidden;
    }

    .featured-service-content {
        padding: 0;
    }

    .featured-service-content h2 {
        font-size: 1.4rem;
        margin-bottom: 15px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .featured-service-content p,
    .featured-service-content ul {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .featured-service-content ul {
        padding-left: 20px;
        margin: 10px 0;
    }

    .featured-service-content ul li {
        margin-bottom: 8px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .featured-badge {
        font-size: 0.75rem;
        padding: 6px 12px;
        margin-bottom: 15px;
        display: inline-block;
    }

    .service-cards {
        grid-template-columns: 1fr !important;
        gap: 15px;
        padding: 0 15px;
    }

    .service-card {
        padding: 20px 15px;
        margin: 0;
    }

    .service-card h3 {
        font-size: 1.2rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .service-card p {
        font-size: 0.9rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* ========== ADMIN HEATMAP MOBILE FIX ========== */
    #usageHeatmap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 15px -15px;
        padding: 15px;
        scrollbar-width: thin;
        scrollbar-color: #667eea #f0f0f0;
    }

    #usageHeatmap::-webkit-scrollbar {
        height: 6px;
    }

    #usageHeatmap::-webkit-scrollbar-track {
        background: #f0f0f0;
        border-radius: 3px;
    }

    #usageHeatmap::-webkit-scrollbar-thumb {
        background: #667eea;
        border-radius: 3px;
    }

    #usageHeatmap table {
        min-width: 600px;
        font-size: 0.75rem;
        border-collapse: collapse;
    }

    #usageHeatmap th,
    #usageHeatmap td {
        padding: 8px 6px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* ========== PARTNER NOTIFICATIONS MOBILE FIX ========== */
    .partner-notifications-container {
        padding: 0;
        margin: 0;
        overflow: visible;
    }

    .notifications-header {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 15px;
        padding: 0 15px;
    }

    .notifications-header .btn {
        flex: 1;
        min-width: 120px;
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    #partnerNotificationsContainer {
        padding: 0 15px;
        margin-top: 15px;
    }

    .notification-card {
        padding: 15px;
        margin-bottom: 12px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        background: white;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .notification-card h4 {
        font-size: 1rem;
        margin-bottom: 8px;
        word-wrap: break-word;
    }

    .notification-card p {
        font-size: 0.85rem;
        margin-bottom: 8px;
        word-wrap: break-word;
    }

    .notification-card small {
        font-size: 0.75rem;
    }

    .notification-card .btn {
        font-size: 0.8rem;
        padding: 8px 12px;
        margin-top: 8px;
    }

    .notifications-loading,
    .error-message {
        padding: 20px 15px;
        text-align: center;
        font-size: 0.9rem;
    }
}
