/**
 * Mobile Visual Cards Full Width Fix
 * Makes visual cards fill the screen width on mobile for app-like experience
 * 
 * @package SENNA_Launcher
 * @since 4.6.0
 */

/* ===========================================
   CRITICAL VIEWPORT FIX - Prevent Horizontal Scroll
   =========================================== */

/* Global viewport lock - prevent ANY horizontal scroll */
html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

/* ===========================================
   MOBILE ONLY - Visual Cards Full Width
   =========================================== */

@media screen and (max-width: 767px) {
    
    /* ===============================
       CONTAINER FULL WIDTH
       =============================== */
    
    /* Main launcher container - proper mobile viewport */
    .skillfarm-launcher-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        position: relative !important;
    }
    
    /* Main container - full width with minimal padding */
    .skillfarm-launcher-container .main-container {
        border-radius: 0 !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Content area - no side padding */
    .skillfarm-launcher-container .content-area {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Focus content - keep text padding but allow cards to go full width */
    .skillfarm-launcher-container .focus-content {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* ===============================
       VISUAL CARDS FULL WIDTH
       =============================== */
    
    /* Visual cards container - full width without causing scroll */
    .skillfarm-launcher-container .visual-cards-container {
        width: calc(100% + 32px) !important;
        max-width: none !important;
        margin-left: -16px !important;
        margin-right: -16px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        box-sizing: border-box !important;
        
        /* 2x2 grid for better touch targets */
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        margin-top: 24px !important;
        margin-bottom: 24px !important;
    }
    
    /* Visual cards - optimized for mobile touch */
    .skillfarm-launcher-container .visual-card {
        min-height: 120px !important;
        padding: 20px 16px !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        transition: all 0.2s ease !important;
        -webkit-tap-highlight-color: transparent !important;
        background: white !important;
        border: 1px solid rgba(27, 67, 50, 0.1) !important;
    }
    
    /* Active state for touch feedback */
    .skillfarm-launcher-container .visual-card:active {
        transform: scale(0.98) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Card icon */
    .skillfarm-launcher-container .visual-card-icon {
        width: 36px !important;
        height: 36px !important;
        margin-bottom: 12px !important;
    }
    
    /* Card title */
    .skillfarm-launcher-container .visual-card-title {
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;
        margin-bottom: 6px !important;
        color: #1B4332 !important;
    }
    
    /* Card description */
    .skillfarm-launcher-container .visual-card-description {
        font-size: 0.8rem !important;
        line-height: 1.4 !important;
        opacity: 0.75 !important;
        color: #374151 !important;
    }
    
    /* ===============================
       QUERY PANEL FULL WIDTH
       =============================== */
    
    /* Query panel - full width without horizontal scroll */
    .skillfarm-launcher-container .query-panel {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 16px !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
    }
    
    /* Query input - proper mobile size */
    .skillfarm-launcher-container .query-input {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 14px 16px !important;
        border-radius: 12px !important;
    }
    
    /* Query submit button - full width on mobile */
    .skillfarm-launcher-container .query-submit {
        width: 100% !important;
        padding: 14px !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
        margin-top: 12px !important;
    }
    
    /* ===============================
       SENNA MESSAGES PADDING
       =============================== */
    
    /* Keep messages properly padded */
    .skillfarm-launcher-container .senna-intro,
    .skillfarm-launcher-container .welcome-message,
    .skillfarm-launcher-container .message-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* SENNA avatar stays centered */
    .skillfarm-launcher-container .senna-avatar {
        margin: 0 auto 16px !important;
        display: block !important;
    }
}

/* ===========================================
   SMALL MOBILE (max-width: 374px)
   =========================================== */

@media screen and (max-width: 374px) {
    
    /* Even tighter padding for small screens */
    .skillfarm-launcher-container .visual-cards-container {
        padding: 0 8px !important;
        gap: 10px !important;
    }
    
    .skillfarm-launcher-container .visual-card {
        min-height: 110px !important;
        padding: 16px 12px !important;
    }
    
    .skillfarm-launcher-container .visual-card-icon {
        width: 32px !important;
        height: 32px !important;
    }
    
    .skillfarm-launcher-container .visual-card-title {
        font-size: 0.9rem !important;
    }
    
    .skillfarm-launcher-container .visual-card-description {
        font-size: 0.75rem !important;
    }
}

/* ===========================================
   SMOOTH APP-LIKE SCROLLING & VIEWPORT LOCK
   =========================================== */

@media screen and (max-width: 767px) {
    
    /* Prevent ANY element from causing horizontal scroll */
    * {
        max-width: 100% !important;
    }
    
    /* Lock viewport completely */
    html {
        overflow-x: hidden !important;
        width: 100% !important;
    }
    
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
    }
    
    /* Smooth scrolling for the entire container */
    .skillfarm-launcher-container {
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Ensure all containers respect viewport */
    .skillfarm-launcher-container > *,
    .skillfarm-launcher-container .main-container > *,
    .skillfarm-launcher-container .content-area > * {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Remove any transform animations on scroll for performance */
    .skillfarm-launcher-container * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* ===========================================
   LANDSCAPE MOBILE ADJUSTMENTS
   =========================================== */

@media screen and (max-height: 500px) and (orientation: landscape) {
    
    /* 4 columns in landscape for better use of space */
    .skillfarm-launcher-container .visual-cards-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin-top: 16px !important;
        margin-bottom: 16px !important;
    }
    
    .skillfarm-launcher-container .visual-card {
        min-height: 100px !important;
        padding: 14px 12px !important;
    }
    
    .skillfarm-launcher-container .visual-card-icon {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 8px !important;
    }
}