/**
 * Mobile Optimization Overrides
 * Enhanced mobile experience for Senna Launcher
 * 
 * @package SENNA_Launcher
 * @since 4.1.0
 */

/* ===========================================
   MOBILE VIEWPORT OPTIMIZATION (320px - 767px)
   =========================================== */

@media screen and (max-width: 767px) {
  /* ===============================
       CONTAINER & LAYOUT OPTIMIZATION
       =============================== */

  /* Full viewport height utilization */
  .skillfarm-launcher-container,
  .opportunities-launcher-container,
  .opp-launcher-container {
    min-height: 100vh;
    padding: 10px;
  }

  /* Optimize main container for mobile */
  .main-container,
  .opp-main-container {
    width: 100%;
    max-width: 100%;
    padding: 15px 10px;
    border-radius: 15px;
    margin: 5px auto;
    min-height: calc(100vh - 20px);
  }

  /* ===============================
       HEADER OPTIMIZATION
       =============================== */

  /* Compact header for more content space */
  .header-container,
  .opp-header-container {
    padding: 10px;
    gap: 10px;
    margin-bottom: 10px;
  }

  /* Smaller logo section */
  .logo-section,
  .opp-logo-section {
    justify-content: center;
    gap: 5px;
  }

  .leaf-icon,
  .opp-leaf-icon {
    width: 20px;
    height: 20px;
  }

  .logo-text,
  .opp-logo-text {
    font-size: 0.9rem;
  }

  /* Compact journey progress - horizontal scroll or dots */
  .journey-progress,
  .opp-journey-progress {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .journey-progress::-webkit-scrollbar,
  .opp-journey-progress::-webkit-scrollbar {
    display: none;
  }

  /* Smaller journey steps */
  .journey-step,
  .opp-journey-step {
    min-width: auto;
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .stage-indicator,
  .opp-stage-indicator {
    gap: 3px;
  }

  .stage-icon,
  .opp-stage-icon {
    width: 14px;
    height: 14px;
  }

  .stage-text,
  .opp-stage-text {
    display: none; /* Hide text on mobile, show only icons */
  }

  /* Show stage text for active step only */
  .journey-step.active .stage-text,
  .opp-journey-step.active .opp-stage-text {
    display: inline;
  }

  /* Compact user welcome */
  .user-welcome,
  .opp-user-welcome {
    font-size: 0.85rem;
  }

  /* ===============================
       CONTENT AREA OPTIMIZATION
       =============================== */

  /* Optimize content area spacing */
  .content-area,
  .opp-content-area {
    padding: 0;
  }

  /* Reduce padding on steps */
  .onboarding-step,
  .opp-onboarding-step {
    padding: 10px 5px;
  }

  /* Optimize focus content */
  .focus-content,
  .opp-focus-content {
    padding: 10px;
    max-width: 100%;
  }

  /* ===============================
       SENNA AVATAR & MESSAGES
       =============================== */

  /* Smaller avatar for mobile */
  .emma-avatar,
  .opp-emma-avatar {
    width: 45px;
    height: 45px;
    margin-bottom: 10px;
  }

  /* Optimize welcome message */
  .welcome-message,
  .opp-welcome-message {
    font-size: 1.1rem !important;
    margin-bottom: 8px;
    padding: 0;
    line-height: 1.3;
  }

  /* Optimize message content */
  .senna-intro.sfs-message-content,
  .opp-senna-intro.opp-sfs-message-content {
    font-size: 0.9rem !important;
    margin-bottom: 10px;
    min-height: 20px;
    line-height: 1.4;
  }

  .sfs-message-content.main-question,
  .opp-sfs-message-content.opp-main-question {
    font-size: 1rem !important;
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.3;
  }

  /* ===============================
       VISUAL CARDS - 2x2 GRID
       =============================== */

  /* 2x2 grid for better mobile visibility */
  .visual-cards-container,
  .opp-visual-cards-container {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    max-width: 100% !important;
    margin: 0 auto 15px !important;
    padding: 0 !important;
  }

  /* Optimize card size and spacing */
  .visual-card,
  .opp-visual-card {
    padding: 15px 10px !important;
    min-height: 100px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* Smaller icons in cards */
  .visual-card-icon,
  .opp-visual-card-icon {
    width: 30px;
    height: 30px;
    margin-bottom: 8px;
  }

  .visual-card-icon svg,
  .opp-visual-card-icon svg {
    width: 100%;
    height: 100%;
  }

  /* Optimize card text */
  .visual-card-title,
  .opp-visual-card-title {
    font-size: 0.9rem !important;
    font-weight: 600;
    margin-bottom: 3px;
    line-height: 1.2;
  }

  .visual-card-description,
  .opp-visual-card-description {
    font-size: 0.75rem !important;
    line-height: 1.2;
    opacity: 0.8;
  }

  /* ===============================
       QUERY PANEL OPTIMIZATION
       =============================== */

  /* Make query panel more compact */
  .query-panel,
  .opp-query-panel {
    padding: 15px 10px;
    margin-top: 15px;
    border-radius: 10px;
  }

  .query-panel-header,
  .opp-query-panel-header {
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
  }

  .query-label,
  .opp-query-label {
    font-size: 0.9rem;
  }

  .query-badge,
  .opp-query-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  /* Stack input and button vertically */
  .query-input-wrapper,
  .opp-query-input-wrapper {
    flex-direction: column;
    gap: 8px;
  }

  .query-input,
  .opp-query-input {
    width: 100%;
    padding: 10px;
    font-size: 16px; /* Prevents iOS zoom */
    border-radius: 8px;
  }

  .query-submit,
  .opp-query-submit {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  /* Quick questions as horizontal scroll */
  .quick-questions,
  .opp-quick-questions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    scrollbar-width: none;
  }

  .quick-questions::-webkit-scrollbar,
  .opp-quick-questions::-webkit-scrollbar {
    display: none;
  }

  .quick-question,
  .opp-quick-question {
    min-width: max-content;
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 15px;
    white-space: nowrap;
  }

  /* ===============================
       STEP 6 - REPORT OPTIMIZATION
       =============================== */

  /* Compact profile card */
  .profile-card,
  .opp-profile-card {
    padding: 12px;
    margin: 10px 0;
  }

  .profile-card-header,
  .opp-profile-card-header {
    font-size: 0.9rem;
    margin-bottom: 10px;
  }

  /* 2x2 grid for profile items */
  .profile-grid,
  .opp-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .profile-item,
  .opp-profile-item {
    padding: 8px;
    text-align: center;
  }

  .profile-icon,
  .opp-profile-icon {
    width: 14px;
    height: 14px;
    margin-bottom: 3px;
  }

  .profile-label,
  .opp-profile-label {
    font-size: 0.7rem;
  }

  .profile-value,
  .opp-profile-value {
    font-size: 0.85rem;
  }

  /* Optimize report sections */
  .report-section,
  .opp-report-section {
    padding: 12px;
    margin-bottom: 12px;
  }

  .section-title,
  .opp-section-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  /* ===============================
       FORMS & INPUTS
       =============================== */

  /* Optimize form inputs for mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 12px !important;
    border-radius: 8px;
  }

  /* ===============================
       BUTTONS & TOUCH TARGETS
       =============================== */

  /* Ensure minimum touch target size (44x44px) */
  button,
  .action-btn,
  .apply-btn,
  .opp-action-btn,
  .opp-apply-btn {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 0.95rem;
    border-radius: 8px;
  }

  /* ===============================
       VIEWPORT HEIGHT OPTIMIZATION
       =============================== */

  /* Make steps use available viewport height */
  .onboarding-step.active,
  .opp-onboarding-step.active {
    min-height: calc(100vh - 150px); /* Account for header */
    display: flex;
    flex-direction: column;
  }

  /* Push query panel to bottom on mobile */
  #step1 .focus-content,
  #step2 .focus-content,
  #step3 .focus-content,
  #step4 .focus-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: calc(100vh - 180px);
  }

  /* Group top content */
  .mobile-top-content {
    flex-grow: 0;
  }

  /* Push query panel down */
  #step1 .query-panel,
  #step2 .query-panel,
  #step3 .query-panel,
  #step4 .query-panel {
    margin-top: auto;
  }

  /* ===============================
       TYPOGRAPHY OPTIMIZATION
       =============================== */

  h1 {
    font-size: 1.5rem !important;
    line-height: 1.2 !important;
  }

  h2 {
    font-size: 1.25rem !important;
    line-height: 1.2 !important;
  }

  h3 {
    font-size: 1.1rem !important;
    line-height: 1.2 !important;
  }

  p,
  body {
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
  }

  /* ===============================
       PERFORMANCE OPTIMIZATIONS
       =============================== */

  /* Disable animations on mobile for better performance */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* Hide decorative elements on mobile */
  .launcher-overlay::before,
  .opp-launcher-overlay::before,
  .launcher-overlay::after,
  .opp-launcher-overlay::after {
    display: none;
  }
}

/* ===========================================
   SMALL MOBILE OPTIMIZATION (320px - 374px)
   =========================================== */

@media screen and (max-width: 374px) {
  /* Even more compact for very small screens */
  .visual-cards-container,
  .opp-visual-cards-container {
    gap: 8px !important;
  }

  .visual-card,
  .opp-visual-card {
    padding: 12px 8px !important;
    min-height: 90px !important;
  }

  .visual-card-title,
  .opp-visual-card-title {
    font-size: 0.85rem !important;
  }

  .visual-card-description,
  .opp-visual-card-description {
    font-size: 0.7rem !important;
  }
}

/* ===========================================
   LANDSCAPE MOBILE (max-height: 500px)
   =========================================== */

@media screen and (max-height: 500px) and (orientation: landscape) {
  /* Optimize for landscape mobile */
  .header-container,
  .opp-header-container {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    padding: 5px 10px;
  }

  .emma-avatar,
  .opp-emma-avatar {
    width: 35px;
    height: 35px;
  }

  .visual-cards-container,
  .opp-visual-cards-container {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .onboarding-step.active,
  .opp-onboarding-step.active {
    padding-top: 60px; /* Account for sticky header */
  }
}
