/**
 * Mobile Responsive Styles for Audiobook Studio
 * Comprehensive mobile optimization with breakpoints and touch-friendly design
 */

/* ==================== MOBILE BREAKPOINTS ==================== */
/* Mobile First Approach */
/* xs: 0-479px (small phones) */
/* sm: 480-767px (large phones) */
/* md: 768-1023px (tablets) */
/* lg: 1024-1199px (small desktops) */
/* xl: 1200px+ (large desktops) */

/* ==================== MOBILE HEADER IMPROVEMENTS ==================== */

/* EXACT SHOP PAGE COPY - Apply to ALL mobile pages */
@media screen and (max-width: 768px) {
  
  /* Copy shop page header exactly */
  .coharmonify-header {
    background-color: #1e293b !important;
    padding: 10px 20px !important;
    color: white !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
  }
  
  .coharmonify-header .header-inner {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin: 0 auto !important;
  }
  
  .coharmonify-header .site-logo {
    font-size: 18px !important;
    font-weight: bold !important;
    color: #ffffff !important;
    text-decoration: none !important;
  }
  
  .coharmonify-header .main-nav {
    flex: 1 !important;
    display: flex !important;
    justify-content: flex-end !important;
  }
  
  .coharmonify-header .nav-tabs {
    list-style: none !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  
  .coharmonify-header .nav-tabs li {
    display: inline-block !important;
  }
  
  .coharmonify-header .nav-tabs li a {
    color: white !important;
    text-decoration: none !important;
    font-size: 14px !important;
  }
  
  body {
    padding-top: 60px !important;
  }
  
  /* Extra compact for pages with many nav items (6+ items) */
  .coharmonify-header .nav-tabs li:nth-child(4) ~ li a {
    font-size: 10px !important;
    padding: 3px 4px !important;
  }
  
  /* Ultra compact for really long nav lists */
  .coharmonify-header .nav-tabs li:nth-child(5) ~ li a {
    font-size: 9px !important;
    padding: 2px 3px !important;
  }
}

/* Shop page layout applied above - no additional overrides needed */

@media screen and (max-width: 480px) {
  
  /* Maintain shop page layout on small screens */
  .coharmonify-header {
    padding: 8px 15px !important;
  }
  
  .coharmonify-header .nav-tabs {
    gap: 10px !important; /* Slightly smaller gap */
  }
  
  .coharmonify-header .nav-tabs li a {
    font-size: 12px !important;
    padding: 5px 7px !important;
  }
  
  .coharmonify-header .site-logo {
    font-size: 16px !important;
  }
  
  /* Hide mobile nav toggle button - keep nav visible */
  #mobile-nav-toggle {
    display: none !important;
  }
  
  body {
    padding-top: 65px !important;
  }
}

/* Extra small screens */
@media screen and (max-width: 380px) {
  
  .coharmonify-header {
    padding: 6px 8px !important;
  }
  
  .header-inner {
    gap: 8px !important;
  }
  
  .site-logo {
    font-size: 14px !important;
  }
  
  .nav-tabs {
    gap: 4px !important;
  }
  
  .nav-tabs li a {
    font-size: 10px !important;
    padding: 5px 6px !important;
    min-width: 40px !important;
  }
  
  body {
    padding-top: 80px !important;
  }
}

/* ==================== BASE MOBILE STYLES ==================== */
@media screen and (max-width: 767px) {
  
  /* ========== LAYOUT FUNDAMENTALS ========== */
  .creator-dashboard-layout {
    display: block !important;
    min-height: 100vh;
    padding: 0 !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    padding: 15px !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  /* ========== SIDEBAR MOBILE TRANSFORMATION ========== */
  .creator-sidebar {
    position: fixed !important;
    left: -280px !important; /* Hidden by default */
    top: 0 !important;
    height: 100vh !important;
    width: 280px !important;
    z-index: 9999 !important;
    transition: left 0.3s ease-in-out !important;
    background: white !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
  }
  
  .creator-sidebar.mobile-open {
    left: 0 !important;
  }
  
  /* Mobile Overlay */
  .mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
  }
  
  .mobile-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
  
  /* ========== HAMBURGER MENU BUTTON ========== */
  .mobile-hamburger {
    display: block !important;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
  }
  
  .mobile-hamburger:hover {
    background: #4338ca;
    transform: scale(1.05);
  }
  
  .mobile-hamburger.menu-open {
    background: #dc2626;
  }
  
  /* ========== STUDIO HEADER MOBILE ========== */
  .audiobook-studio h1 {
    font-size: 1.8rem !important;
    margin-left: 65px !important; /* Space for hamburger */
  }
  
  .audiobook-studio p {
    font-size: 1rem !important;
    margin-left: 65px !important;
  }
  
  /* ========== TAB NAVIGATION MOBILE ========== */
  .studio-tabs-container {
    margin-bottom: 20px !important;
  }
  
  /* Desktop tabs - hide on mobile */
  .studio-tabs-desktop {
    display: none !important;
  }
  
  /* Mobile tab selector */
  .studio-tabs-mobile {
    display: block !important;
    margin-bottom: 20px;
  }
  
  .mobile-tab-selector {
    width: 100%;
    padding: 15px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
    padding-right: 50px;
  }
  
  /* ========== FORM FIELDS MOBILE ========== */
  
  /* Grid layouts - stack on mobile */
  div[style*="display: grid"] {
    display: block !important;
  }
  
  /* Form groups - full width with spacing */
  .form-group {
    margin-bottom: 20px !important;
    width: 100% !important;
  }
  
  /* Input fields - touch friendly */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    width: 100% !important;
    padding: 15px 12px !important; /* Increased for touch */
    font-size: 16px !important; /* Prevents zoom on iOS */
    border-radius: 8px !important;
    border: 2px solid #e2e8f0 !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    min-height: 50px !important; /* Touch target minimum */
  }
  
  /* Focus states for better UX */
  input:focus,
  select:focus,
  textarea:focus {
    border-color: #4f46e5 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
  }
  
  /* Labels - better spacing */
  label {
    margin-bottom: 8px !important;
    font-weight: 600 !important;
    font-size: 16px !important;
  }
  
  /* ========== BUTTON OPTIMIZATIONS ========== */
  
  /* Primary buttons - full width on mobile */
  button,
  .btn,
  input[type="submit"] {
    min-height: 50px !important; /* Touch friendly */
    padding: 15px 20px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
    box-sizing: border-box !important;
  }
  
  /* Full width buttons for important actions */
  .mobile-full-width,
  #create-new-book-btn,
  #save-chapter-structure,
  #next-to-structure-btn,
  #save-chapter-content,
  #editor-generate-audio-btn {
    width: 100% !important;
    margin-bottom: 15px !important;
  }
  
  /* Button groups - stack vertically */
  .button-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
  }
  
  /* Secondary buttons */
  .btn-secondary {
    background: #f8fafc !important;
    color: #64748b !important;
    border: 2px solid #e2e8f0 !important;
  }
  
  /* ========== CONTENT SECTIONS ========== */
  
  /* Section spacing */
  .book-management-section,
  .book-metadata-section,
  .voice-settings-section,
  .chapter-structure-section {
    margin-bottom: 25px !important;
    padding: 20px 15px !important;
    border-radius: 12px !important;
  }
  
  /* Section headers */
  h3 {
    font-size: 1.25rem !important;
    margin-bottom: 15px !important;
  }
  
  /* ========== CHAPTER MANAGEMENT ========== */
  
  /* Chapter list */
  #chapter-list,
  #chapter-sortable-list {
    padding: 0 !important;
  }
  
  /* Chapter items */
  .chapter-item {
    margin-bottom: 15px !important;
    padding: 15px !important;
    border-radius: 8px !important;
    background: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
  }
  
  /* Chapter buttons */
  .chapter-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-top: 15px !important;
  }
  
  .chapter-actions button {
    width: 100% !important;
  }
  
  /* ========== EDITOR OPTIMIZATIONS ========== */
  
  /* Quill editor */
  .ql-container {
    font-size: 16px !important;
    line-height: 1.6 !important;
  }
  
  .ql-editor {
    padding: 20px !important;
    min-height: 300px !important;
  }
  
  /* Editor toolbar */
  .ql-toolbar {
    border-radius: 8px 8px 0 0 !important;
    padding: 10px !important;
  }
  
  /* ========== AUDIO CONTROLS ========== */
  
  /* Audio players */
  audio {
    width: 100% !important;
    height: 60px !important;
    margin: 15px 0 !important;
  }
  
  /* Audio generation status */
  .audio-status {
    padding: 15px !important;
    border-radius: 8px !important;
    margin: 15px 0 !important;
    font-size: 16px !important;
  }
  
  /* ========== UTILITY CLASSES ========== */
  
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-visible {
    display: block !important;
  }
  
  .mobile-text-center {
    text-align: center !important;
  }
  
  .mobile-margin-bottom {
    margin-bottom: 20px !important;
  }
  
  /* ========== LOADING STATES ========== */
  
  .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #4f46e5;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  /* ========== ERROR STATES ========== */
  
  .error-message {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    border: 1px solid #fecaca !important;
    margin: 15px 0 !important;
    font-size: 16px !important;
  }
  
  .success-message {
    background: #f0fdf4 !important;
    color: #166534 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    border: 1px solid #bbf7d0 !important;
    margin: 15px 0 !important;
    font-size: 16px !important;
  }
}

/* ==================== TABLET STYLES ==================== */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  
  .main-content {
    margin-left: 0 !important;
    padding: 25px !important;
  }
  
  .creator-sidebar {
    position: fixed !important;
    left: -280px !important;
    transition: left 0.3s ease-in-out !important;
  }
  
  .creator-sidebar.tablet-open {
    left: 0 !important;
  }
  
  .mobile-hamburger {
    display: block !important;
  }
  
  /* Tablet-specific optimizations */
  .studio-tabs-desktop {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  .studio-tab {
    font-size: 14px !important;
    padding: 10px 15px !important;
  }
  
  /* Form fields - 2 columns on tablet */
  .tablet-two-column {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
  }
}

/* ==================== DESKTOP STYLES ==================== */
@media screen and (min-width: 1024px) {
  
  .mobile-hamburger {
    display: none !important;
  }
  
  .studio-tabs-mobile {
    display: none !important;
  }
  
  .studio-tabs-desktop {
    display: flex !important;
  }
  
  .creator-sidebar {
    position: fixed !important;
    left: 0 !important;
  }
  
  .main-content {
    margin-left: 280px !important;
  }
}

/* ==================== LARGE DESKTOP OPTIMIZATIONS ==================== */
@media screen and (min-width: 1200px) {
  
  .main-content {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 300px !important;
  }
  
  .creator-sidebar {
    width: 300px !important;
  }
}

/* ==================== REMOVE INSTALL APP PROMPTS ==================== */

/* Hide PWA install prompts and floating install buttons */
#pwa-install-prompt,
.pwa-install-banner,
.install-app-banner,
.install-app-floating,
.install-app-button,
.add-to-homescreen,
.add-to-homescreen-banner,
.install-prompt,
.app-install-banner,
.pwa-banner,
.install-floating-button,
.floating-install-btn,
.install-app-fab,
.add-app-banner,
.web-app-install,
.mobile-app-install,
.install-app-popup,
.app-install-popup,
.pwa-install-popup,
.a2hs-banner,
.a2hs-prompt,
.beforeinstallprompt,
.install-app-notification,
.app-install-notification {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  z-index: -1 !important;
  pointer-events: none !important;
}

/* Hide common BuddyBoss/WordPress install prompts */
.bb-install-app,
.bb-pwa-banner,
.bb-add-to-homescreen,
.wp-pwa-install,
.wp-app-install,
.buddyboss-install-app,
.buddyboss-pwa-banner {
  display: none !important;
  visibility: hidden !important;
}

/* Hide floating action buttons that might be install prompts */
.fab,
.floating-action-button,
.fixed-bottom-right,
.fixed-bottom-left,
.floating-btn {
  display: none !important;
}

/* Specifically target install-related floating buttons */
[class*="install"],
[class*="pwa"],
[class*="a2hs"],
[id*="install"],
[id*="pwa"],
[id*="app-banner"] {
  display: none !important;
}

/* Hide any element with install-related text content */
*[title*="install" i],
*[title*="add to home" i],
*[aria-label*="install" i],
*[aria-label*="add to home" i] {
  display: none !important;
}

/* Target specific positioning that install buttons commonly use */
div[style*="position: fixed"][style*="bottom"],
div[style*="position: fixed"][style*="right"],
div[style*="position: absolute"][style*="bottom"],
button[style*="position: fixed"],
.fixed-bottom,
.position-fixed {
  /* Only hide if it contains install-related content */
}

div[style*="position: fixed"]:has([class*="install"]),
div[style*="position: fixed"]:has([id*="install"]),
div[style*="position: fixed"]:has(button[title*="install" i]) {
  display: none !important;
}

/* Remove any install prompts from iOS Safari */
.ios-install-prompt,
.safari-install-banner,
.ios-add-to-homescreen {
  display: none !important;
}

/* Remove Android Chrome install prompts */
.chrome-install-banner,
.android-install-prompt,
.chrome-pwa-banner {
  display: none !important;
}

/* Generic catch-all for floating install elements */
*[style*="position: fixed"][style*="z-index"]:not(.creator-sidebar):not(.mobile-hamburger):not(.mobile-sidebar-overlay) {
  /* Check if it's an install button by content */
}

/* Hide elements with install-related data attributes */
[data-install],
[data-pwa],
[data-a2hs],
[data-add-to-homescreen] {
  display: none !important;
}

/* BuddyBoss specific install elements */
#buddypress .install-app,
.bp-install-app,
.bb-mobile-app-banner {
  display: none !important;
}

/* WordPress PWA plugin elements */
.wp-pwa-install-button,
.wp-pwa-banner,
.super-progressive-web-apps {
  display: none !important;
}

/* ==================== HIDE WISHLIST FROM NAVIGATION ==================== */

/* Remove wishlist links from header navigation */
.wishlist-nav-link,
.nav-tabs .wishlist-nav-link,
a[href*="wishlist"],
a[href*="/my-wishlist"],
.nav-tabs a[href*="wishlist"],
.nav-tabs li:has(a[href*="wishlist"]) {
  display: none !important;
  visibility: hidden !important;
}

/* Hide wishlist badges and counters */
#wishlist-count-badge,
.wishlist-badge,
.wishlist-counter,
.wishlist-count {
  display: none !important;
}

/* Hide any wishlist menu items */
*[title*="wishlist" i],
*[aria-label*="wishlist" i],
li:has(*[title*="wishlist" i]),
li:has(*[aria-label*="wishlist" i]) {
  display: none !important;
}

/* Remove wishlist from mobile navigation */
@media screen and (max-width: 768px) {
  .wishlist-nav-link,
  .nav-tabs .wishlist-nav-link {
    display: none !important;
  }
}

/* ==================== COMMUNITY FORUM MOBILE FIXES ==================== */

/* Fix community forum tab switching on mobile */
@media screen and (max-width: 768px) {
  
  /* Ensure both chat and forum content containers exist and work properly */
  .chat-content,
  .forum-content {
    display: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    box-sizing: border-box !important;
  }
  
  /* Show active content */
  .chat-content.active,
  .forum-content.active {
    display: block !important;
  }
  
  /* Force visibility of active chat content on mobile */
  .chat-content.active {
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
  }
  
  /* Forum/Community page layout fixes */
  .layout.forum-layout {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .layout.forum-layout .left-sidebar {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    margin-bottom: 20px !important;
    padding: 15px !important;
  }
  
  .layout.forum-layout .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 15px !important;
  }
  
  /* Community tab navigation mobile fixes */
  #main-studio-tabs {
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 10px 15px !important;
    overflow-x: auto !important;
  }
  
  .studio-tab {
    padding: 12px 20px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
    min-width: 100px !important;
    text-align: center !important;
  }
  
  .studio-tab.active {
    background-color: #4f46e5 !important;
    color: white !important;
  }
  
  /* Hide sidebar categories on mobile to save space */
  .left-sidebar .sidebar-section {
    display: none !important;
  }
  
  /* Mobile newsfeed improvements */
  .newsfeed-container {
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .post-creation-box {
    margin-bottom: 20px !important;
    padding: 15px !important;
    border-radius: 8px !important;
  }
  
  .post-creation-input {
    width: 100% !important;
    padding: 12px !important;
    border-radius: 6px !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
  }
  
  /* Mobile forum post styling */
  .forum-post,
  .newsfeed-post {
    margin-bottom: 15px !important;
    padding: 15px !important;
    border-radius: 8px !important;
  }
}

/* Extra small mobile screens */
@media screen and (max-width: 480px) {
  
  .studio-tab {
    padding: 10px 15px !important;
    font-size: 13px !important;
    min-width: 80px !important;
  }
  
  .layout.forum-layout .main-content {
    padding: 10px !important;
  }
  
  .post-creation-box {
    padding: 12px !important;
  }
}