/* ========================================
   MOBILE FIRST RESPONSIVE STYLES
   Clean, modular mobile optimization
   ======================================== */

/* ========================================
   GLOBAL MOBILE RESETS & BASE STYLES
   ======================================== */

@media (max-width: 480px) {
  /* Root mobile adjustments */
  html, body {
    font-size: 14px;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    height: 100%;
  }

  /* Reset default spacing */
  * {
    box-sizing: border-box;
  }

  /* Main app structure */
  .app-layout {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  /* ========================================
     SIDEBAR -> BOTTOM NAVIGATION
     ======================================== */

  .app-sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    order: 2;
    z-index: 1000 !important;
    background: var(--bg-primary);
    border-top: 1px solid rgba(139, 92, 246, 0.15) !important;
    border-right: none !important;
    padding: 4px 0 !important;
    backdrop-filter: blur(20px);
  }

  /* Hide sidebar when landing page is visible */
  #mainApp.hidden .app-sidebar {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .sidebar-brand {
    display: none !important;
  }

  .sidebar-nav {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 8px !important;
    margin: 0 !important;
    gap: 0 !important;
  }

  .nav-link {
    flex: 1 !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 4px 2px !important;
    margin: 0 !important;
    min-height: 44px !important;
    border-radius: 8px !important;
    gap: 2px !important;
    position: relative;
  }

  .nav-icon {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
  }

  .nav-text {
    font-size: 9px !important;
    display: block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50px;
    line-height: 1.1;
  }

  .nav-badge {
    font-size: 7px !important;
    padding: 1px 3px !important;
    min-width: 12px !important;
    height: 12px !important;
    position: absolute !important;
    top: 2px !important;
    right: 8px !important;
  }

  .sidebar-footer {
    display: none !important;
  }

  /* ========================================
     MAIN CONTENT AREA
     ======================================== */

  .app-header {
    order: 0;
    width: 100% !important;
    min-height: 50px !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  .header-title {
    font-size: 15px !important;
    font-weight: 700 !important;
  }

  .app-content {
    order: 1;
    flex: 1 !important;
    width: 100% !important;
    padding: 0 !important;
    padding-bottom: 65px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .page {
    padding: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - 64px) !important;
    max-height: calc(100vh - 64px) !important;
    overflow-y: auto !important;
  }

  /* ========================================
     FEED & POST STYLES
     ======================================== */

  .feed-container {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    gap: 0 !important;
    flex: 1;
    min-height: 0;
  }

  .feed-filters {
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding: 12px !important;
    padding-bottom: 8px !important;
    margin: 0 !important;
    flex-shrink: 0;
    scrollbar-width: none;
  }

  .feed-filters::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    padding: 6px 12px !important;
    font-size: 11px !important;
    white-space: nowrap;
    flex-shrink: 0;
    height: 32px;
  }

  .feed-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px !important;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Custom scrollbar styling for mobile */
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.5) transparent;
  }

  /* Webkit browsers (Chrome, Safari, Edge) scrollbar styling */
  .feed-content::-webkit-scrollbar {
    width: 6px;
  }

  .feed-content::-webkit-scrollbar-track {
    background: transparent;
  }

  .feed-content::-webkit-scrollbar-thumb {
    background-color: rgba(139, 92, 246, 0.5);
    border-radius: 3px;
    border: 2px solid transparent;
    background-clip: content-box;
  }

  .feed-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 92, 246, 0.8);
  }

  /* Post Card Component */
  .post-card {
    padding: 1.25rem !important;
    margin-bottom: 10px !important;
  }

  .post-header {
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  .post-avatar {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }

  .post-author-name {
    font-size: 13px !important;
  }

  .post-date {
    font-size: 10px !important;
  }

  .post-title {
    font-size: 16px !important;
    margin: 8px 0 !important;
  }

  .post-preview {
    font-size: 13px !important;
    margin-bottom: 10px !important;
  }

  .post-meta {
    font-size: 11px !important;
    gap: 8px !important;
    margin-bottom: 10px !important;
  }

  .post-actions {
    display: flex !important;
    gap: 6px !important;
  }

  .post-action-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
    flex: 1;
    min-width: 60px;
  }

  /* ========================================
     COMPOSE PAGE
     ======================================== */

  .compose-container {
    padding: 0 !important;
  }

  .compose-card {
    padding: 16px !important;
    gap: 12px !important;
  }

  .compose-title {
    font-size: 18px !important;
    margin-bottom: 16px !important;
  }

  .compose-form {
    gap: 16px !important;
  }

  .form-group {
    margin-bottom: 16px !important;
  }

  .form-group label {
    font-size: 13px !important;
    margin-bottom: 6px !important;
  }

  input, textarea, select {
    padding: 12px 14px !important;
    font-size: 15px !important;
  }

  select {
    padding-right: 40px !important;
    background-size: 18px !important;
    background-position: right 14px center !important;
  }

  textarea {
    min-height: 140px !important;
    line-height: 1.5;
  }

  .compose-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-top: 16px !important;
    padding-top: 16px !important;
  }

  .btn-compose {
    padding: 10px 14px !important;
    font-size: 13px !important;
    min-height: 40px !important;
    width: 100% !important;
  }

  /* ========================================
     EXPLORE PAGE
     ======================================== */

  .explore-container {
    padding: 0 !important;
  }

  .explore-header {
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .explore-header h2 {
    font-size: 18px !important;
  }

  .search-container input {
    padding: 12px 14px !important;
    font-size: 15px !important;
  }

  .posts-grid,
  .writers-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .grid-item {
    padding: 14px !important;
  }

  .grid-item h4 {
    font-size: 14px !important;
  }

  .grid-item p {
    font-size: 12px !important;
  }

  .writer-stats {
    font-size: 11px !important;
  }

  .explore-section h3 {
    font-size: 16px !important;
    margin: 20px 0 12px 0 !important;
  }

  /* ========================================
     MESSAGES / CHAT
     ======================================== */

  .messages-container {
    flex-direction: column !important;
    height: calc(100dvh - 120px) !important;
  }

  .conversations-panel {
    width: 100% !important;
    height: 140px !important;
    max-height: 140px !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1) !important;
    flex: 0 0 140px !important;
  }

  .conversations-header {
    padding: 12px !important;
  }

  .conversations-list {
    max-height: 100px !important;
  }

  .conversation-item {
    padding: 10px !important;
    margin-bottom: 4px;
  }

  .conversation-avatar {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
  }

  .conversation-info h4 {
    font-size: 12px !important;
  }

  .conversation-info p {
    font-size: 10px !important;
  }

  .chat-panel {
    flex: 1 !important;
  }

  .chat-header {
    padding: 12px !important;
    min-height: 54px;
  }

  .chat-user-pic {
    width: 36px !important;
    height: 36px !important;
  }

  .chat-user-name {
    font-size: 14px !important;
  }

  .chat-content {
    padding: 12px !important;
    gap: 8px !important;
  }

  .message-bubble {
    max-width: 85% !important;
    font-size: 14px !important;
    padding: 10px 12px !important;
  }

  .message-sender {
    font-size: 11px !important;
  }

  .chat-input {
    padding: 12px !important;
  }

  .message-form input {
    padding: 12px 14px !important;
    font-size: 15px !important;
    height: 46px;
  }

  .btn-icon {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    padding: 10px !important;
  }

  /* ========================================
     PROFILE PAGE
     ======================================== */

  .profile-container {
    padding: 0 !important;
    gap: 16px !important;
  }

  .profile-header {
    flex-direction: column !important;
    text-align: center !important;
    gap: 16px !important;
    padding: 16px !important;
  }

  .profile-avatar {
    width: 80px !important;
    height: 80px !important;
    margin: 0 0 12px 0 !important;
  }

  .profile-name {
    font-size: 20px !important;
    margin-bottom: 6px !important;
  }

  .profile-bio {
    font-size: 14px !important;
    margin-bottom: 12px !important;
  }

  .profile-stats {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
    margin: 12px 0 !important;
  }

  .stat-value {
    font-size: 20px !important;
  }

  .stat-label {
    font-size: 10px !important;
  }

  .profile-actions {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .btn-action {
    width: 100% !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    min-height: 46px;
  }

  .section-title {
    font-size: 18px !important;
    margin: 16px 0 12px 0 !important;
  }

  .posts-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Compact trending post cards on mobile */
  .post-card-new {
    padding: 12px !important;
    min-width: unset !important;
  }

  .post-card-header-new {
    margin-bottom: 8px !important;
    gap: 8px !important;
  }

  .post-author-avatar-new {
    width: 32px !important;
    height: 32px !important;
  }

  .post-author-name-new {
    font-size: 13px !important;
  }

  .post-author-date-new {
    font-size: 11px !important;
  }

  .post-type-badge {
    font-size: 9px !important;
    padding: 2px 6px !important;
  }

  .post-title-new {
    font-size: 14px !important;
    margin: 6px 0 !important;
    -webkit-line-clamp: 2 !important;
  }

  .post-content-preview-new {
    font-size: 12px !important;
    margin-bottom: 8px !important;
    -webkit-line-clamp: 2 !important;
    line-height: 1.4 !important;
  }

  .post-images-new {
    max-height: 120px !important;
    margin-bottom: 8px !important;
  }

  .post-image-thumbnail-new {
    height: 60px !important;
  }

  .post-stats-new {
    gap: 8px !important;
  }

  .post-stat-item-new {
    font-size: 11px !important;
  }

  .post-stat-item-new svg {
    width: 12px !important;
    height: 12px !important;
  }

  .badges-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .badge-item {
    padding: 14px !important;
  }

  .badge-icon {
    font-size: 28px !important;
  }

  .badge-name {
    font-size: 12px !important;
  }

  /* ========================================
     MODALS & OVERLAYS
     ======================================== */

  .modal {
    display: none !important;
    padding: 0 !important;
    align-items: flex-end !important;
    height: calc(100% - 60px) !important;
    max-height: calc(100dvh - 60px) !important;
    z-index: 999 !important;
  }

  .modal.active {
    display: flex !important;
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 85dvh !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 20px !important;
    margin: 0 !important;
  }

  .modal-close {
    top: 12px !important;
    right: 12px !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 18px !important;
  }

  /* Safe area support for notched phones */
  @supports(padding: max(0px)) {
    .modal-content {
      padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
    }
  }

  /* ========================================
     BUTTONS & CONTROLS
     ======================================== */

  .btn-primary,
  .btn-secondary {
    padding: 10px 16px !important;
    font-size: 14px !important;
    min-height: 40px !important;
  }

  .btn-block {
    width: 100% !important;
  }

  /* ========================================
     ADMIN PANEL
     ======================================== */

  .admin-page {
    padding: 0 !important;
  }

  .admin-tabs {
    gap: 6px !important;
    margin-bottom: 16px !important;
    flex-wrap: wrap;
  }

  .admin-tab-btn {
    padding: 10px 12px !important;
    font-size: 12px !important;
    flex: 1;
    min-width: 60px;
  }

  .admin-table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    font-size: 12px !important;
    min-width: 600px;
  }

  .admin-table th,
  .admin-table td {
    padding: 8px 6px !important;
  }

  .admin-table input,
  .admin-table select {
    font-size: 11px !important;
    padding: 6px 8px !important;
  }

  .admin-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  .status-badge {
    padding: 4px 6px !important;
    font-size: 10px !important;
  }

  /* ========================================
     UTILITIES & HELPERS
     ======================================== */

  .hidden-mobile {
    display: none !important;
  }

  .text-center-mobile {
    text-align: center !important;
  }

  .full-width-mobile {
    width: 100% !important;
  }

  .stack-mobile {
    flex-direction: column !important;
  }

  /* Loading states */
  .loader {
    width: 44px !important;
    height: 44px !important;
  }

  .loader-spinner {
    width: 44px !important;
    height: 44px !important;
    border-width: 3px !important;
  }

  /* Toast notifications */
  .toast {
    font-size: 14px !important;
    padding: 12px 16px !important;
    bottom: 80px !important;
    left: 12px !important;
    right: 12px !important;
  }

  /* Hide scrollbars but keep functionality */
  .feed-filters,
  .conversations-list {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .feed-filters::-webkit-scrollbar,
  .conversations-list::-webkit-scrollbar {
    display: none;
  }
}

/* ========================================
   BOTTOM NAV FORCE FOR ALL MOBILE/TABLET
   ======================================== */

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 60px !important;
    z-index: 1000 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  .app-content {
    padding-bottom: calc(65px + env(safe-area-inset-bottom)) !important;
  }
}

/* ========================================
   EXTRA SMALL DEVICES & LANDSCAPE FIXES
   ======================================== */

/* Very small phones */
@media (max-width: 380px) {
  .app-sidebar {
    height: 55px !important;
    min-height: 55px !important;
    max-height: 55px !important;
  }

  .app-content {
    padding-bottom: 60px !important;
  }

  .nav-link {
    padding: 2px 1px !important;
    min-height: 40px !important;
  }

  .nav-icon {
    width: 18px !important;
    height: 18px !important;
  }

  .nav-text {
    font-size: 8px !important;
    max-width: 45px;
  }
}

/* Landscape mode */
@media (max-width: 900px) and (orientation: landscape) {
  .app-sidebar {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
  }

  .app-content {
    padding-bottom: 55px !important;
  }

  .nav-text {
    display: none !important;
  }

  .nav-link {
    gap: 0 !important;
  }
}

/* Tall screens optimization */
@media (max-height: 700px) and (max-width: 900px) {
  .app-sidebar {
    height: 55px !important;
    min-height: 55px !important;
    max-height: 55px !important;
  }
  
  .app-content {
    padding-bottom: 60px !important;
  }
}

/* Safe area support for notches and home indicators */
@supports(padding: max(0px)) {
  @media (max-width: 900px) {
    .app-sidebar {
      padding-left: env(safe-area-inset-left) !important;
      padding-right: env(safe-area-inset-right) !important;
    }
  }
}

/* ========================================
   COMPOSE BUTTONS FIX FOR DESKTOP
   ======================================== */

/* Ensure mobile styles don't override desktop compose buttons */
@media (min-width: 769px) {
  .compose-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1.5rem !important;
    padding-top: 2rem !important;
  }
  
  .btn-compose {
    padding: 1.125rem 2rem !important;
    font-size: 1.125rem !important;
    min-height: 60px !important;
  }
}

/* Mobile-specific adjustments for compose buttons */
@media (max-width: 768px) {
  .compose-actions {
    grid-template-columns: 1fr !important;
    gap: 0.875rem !important;
  }
  
  .btn-compose {
    padding: 10px 14px !important;
    font-size: 14px !important;
    min-height: 42px !important;
  }
}

/* ========================================
   TABLET OPTIMIZATIONS (481px - 768px)
   ======================================== */

@media (min-width: 481px) and (max-width: 768px) {
  /* Compact sidebar */
  .app-sidebar {
    width: 80px !important;
    padding: 16px 0 !important;
  }

  .sidebar-brand {
    padding: 0 8px 16px 8px !important;
  }

  .brand-text {
    display: none !important;
  }

  .sidebar-nav {
    flex-direction: column !important;
    padding: 0 !important;
    gap: 8px !important;
  }

  .nav-link {
    flex-direction: column !important;
    padding: 10px 6px !important;
    gap: 6px !important;
  }

  .nav-text {
    font-size: 10px !important;
    display: block !important;
  }

  /* Main content adjustments */
  .app-header {
    padding: 12px 20px !important;
  }

  .app-content {
    padding: 16px !important;
  }

  /* Grid layouts */
  .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
    gap: 16px !important;
  }

  .writers-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    gap: 16px !important;
  }

  /* Modal sizing */
  .modal-content {
    max-width: 500px !important;
    max-height: 80vh !important;
    border-radius: 12px !important;
    margin: auto !important;
  }

  /* Button sizing */
  .btn-primary,
  .btn-secondary {
    padding: 10px 18px !important;
    font-size: 14px !important;
  }

  /* ========================================
     NOTIFICATION ICON & BADGE (MOBILE)
     ======================================== */

  .nav-badge {
    width: 18px !important;
    height: 18px !important;
    font-size: 10px !important;
    min-width: 18px !important;
  }

  #notificationBadge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ========================================
     NOTIFICATIONS PAGE (MOBILE)
     ======================================== */

  #notificationsPage {
    padding-bottom: 80px !important;
  }

  .page-header {
    padding: 16px !important;
  }

  .page-header h2 {
    font-size: 20px !important;
    margin: 0 !important;
  }

  .notifications-container {
    max-width: none !important;
    padding: 0 !important;
  }

  #notificationsList {
    padding: 0 !important;
  }

  .notification-item {
    padding: 12px !important;
    margin: 0 !important;
    gap: 10px !important;
    border-radius: 0 !important;
    flex-wrap: wrap !important;
  }

  .notification-item > div:first-child {
    font-size: 20px !important;
  }

  .notification-item > div:nth-child(2) {
    flex: 1 !important;
    min-width: 100% !important;
  }

  .notification-item button {
    font-size: 12px !important;
    padding: 8px 12px !important;
    flex: 0 1 auto !important;
  }

  .empty-state {
    padding: 40px 20px !important;
  }

  .empty-state > div {
    font-size: 36px !important;
  }

  /* ========================================
     COLLABORATION EDITOR (MOBILE)
     ======================================== */

  #collaborationPage {
    padding-bottom: 80px !important;
  }

  .collab-editor-container {
    height: auto !important;
    overflow-y: auto !important;
  }

  .collab-editor-container > div:first-child {
    padding: 12px !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .collab-editor-container > div:first-child > div:first-child {
    width: 100% !important;
  }

  .collab-editor-container > div:first-child > div:last-child {
    display: flex !important;
    gap: 8px !important;
    flex-direction: row !important;
  }

  .collab-editor-container > div:last-child {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 12px !important;
    width: 100% !important;
  }

  #collabContent {
    min-height: 300px !important;
    padding: 12px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  .collab-editor-container > div:last-child > div:nth-child(1),
  .collab-editor-container > div:last-child > div:nth-child(2) {
    width: 100% !important;
  }

  .collab-editor-container > div:last-child h4 {
    font-size: 13px !important;
    margin: 0 0 8px 0 !important;
  }

  #collabActiveUsersList {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  #collabActiveUsersList > div {
    padding: 8px !important;
    font-size: 12px !important;
  }

  #collabActiveUsersList img {
    width: 24px !important;
    height: 24px !important;
  }

  #collabChanges {
    font-size: 11px !important;
    line-height: 1.5 !important;
  }

  /* ========================================
     SHARE BUTTONS (MOBILE)
     ======================================== */

  .post-share-section {
    margin: 12px 0 !important;
    padding: 12px !important;
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }

  .post-share-section button {
    flex: 1 !important;
    min-width: 120px !important;
    padding: 10px 12px !important;
    font-size: 12px !important;
  }

  /* ========================================
     POST MODAL (MOBILE)
     ======================================== */

  .post-detail-modal {
    max-height: 85vh !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 12px 12px 0 0 !important;
    width: 100% !important;
  }

  .post-detail {
    padding: 16px !important;
  }

  .post-header {
    padding-bottom: 12px !important;
    margin-bottom: 12px !important;
  }

  .post-content h2 {
    font-size: 18px !important;
    margin-bottom: 12px !important;
  }

  .post-stats {
    flex-wrap: wrap !important;
    gap: 12px !important;
    font-size: 12px !important;
  }

  .rating-section label {
    font-size: 12px !important;
  }

  #starRating {
    gap: 6px !important;
  }

  .star svg {
    width: 16px !important;
    height: 16px !important;
  }

  #ratingComment {
    font-size: 14px !important;
    min-height: 80px !important;
    padding: 10px !important;
  }

  #submitRatingBtn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
  }

  .ratings-comments-section {
    padding-top: 16px !important;
  }

  .ratings-comments-section h4 {
    font-size: 14px !important;
    margin-bottom: 12px !important;
  }

  #ratingsCommentsList {
    max-height: 250px !important;
  }

  .collaborators-section {
    padding-top: 16px !important;
  }

  .collaborators-section h4 {
    font-size: 14px !important;
  }

  .collaborator-item {
    padding: 8px !important;
    font-size: 12px !important;
    gap: 8px !important;
  }

  .collaborator-item img {
    width: 24px !important;
    height: 24px !important;
  }

  /* ========================================
     COLLABORATION INVITE MODAL (MOBILE)
     ======================================== */

  #collabInviteModal .modal-content {
    max-width: 95% !important;
    width: 95% !important;
    max-height: 80vh !important;
    padding: 16px !important;
    border-radius: 12px !important;
  }

  #collabInviteModal h2 {
    font-size: 18px !important;
    margin-bottom: 12px !important;
  }

  #collabInviteModal p {
    font-size: 13px !important;
    margin-bottom: 16px !important;
  }

  #collabUsernameInput {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
    height: auto !important;
    min-height: 44px !important;
  }

  #collabInviteModal .modal-content > div:last-child {
    flex-direction: column !important;
    gap: 12px !important;
    margin-top: 16px !important;
  }

  #collabInviteModal button {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
    min-height: 44px !important;
  }

  /* ========================================
     COLLABORATION BUTTONS (MOBILE)
     ======================================== */

  .compose-actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  #startCollabBtn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 13px !important;
    min-height: 44px !important;
  }

  .btn-compose {
    flex: 1 !important;
    min-width: 100px !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    min-height: 44px !important;
  }

  /* Button alignment on mobile */
  .compose-actions button:nth-child(1) {
    flex: 1 !important;
  }

  .compose-actions button:nth-child(2) {
    flex: 1 !important;
  }

  .compose-actions button:nth-child(3) {
    flex: 0 1 auto !important;
  }

  /* ========================================
     MODAL GENERAL MOBILE FIXES
     ======================================== */

  .modal {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .modal-content {
    max-height: 90vh !important;
    overflow-y: auto !important;
    scrollbar-width: thin !important;
  }

  .modal-close {
    width: 32px !important;
    height: 32px !important;
    font-size: 24px !important;
    top: 8px !important;
    right: 8px !important;
  }

  /* ========================================
     TOUCH OPTIMIZATIONS
     ======================================== */

  /* Increase touch target sizes */
  button {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* Prevent zoom on input focus (iOS) */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Remove 300ms tap delay on buttons */
  button {
    touch-action: manipulation;
  }

  /* Optimize textarea for mobile */
  textarea {
    resize: vertical !important;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Better spacing for touch interactions */
  .nav-link {
    min-height: 50px !important;
    min-width: 50px !important;
  }

  /* ========================================
     VERTICAL SPLIT LAYOUT FIX (MOBILE)
     ======================================== */

  /* Stack sidebar items properly */
  .nav-link {
    padding: 6px 4px !important;
  }

  .nav-link span {
    display: block !important;
  }

  /* Ensure notification badge is visible */
  .nav-link {
    position: relative !important;
  }

  .nav-badge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    z-index: 10 !important;
  }

  /* ========================================
     LANDSCAPE MODE OPTIMIZATIONS
     ======================================== */

  @media (max-width: 900px) and (orientation: landscape) {
    .app-sidebar {
      height: 50px !important;
    }

    .nav-text {
      display: none !important;
    }

    .nav-icon {
      width: 18px !important;
      height: 18px !important;
    }

    #collabContent {
      min-height: 200px !important;
    }

    .post-detail-modal {
      max-height: 90vh !important;
    }
  }

  /* ========================================
     TABLET OPTIMIZATIONS (600px - 900px)
     ======================================== */

  @media (min-width: 481px) and (max-width: 900px) {
    .post-share-section button {
      flex: 0 1 calc(50% - 6px) !important;
    }

    .compose-actions {
      display: grid !important;
      grid-template-columns: 1fr 1fr !important;
      gap: 12px !important;
    }

    #startCollabBtn {
      grid-column: 1 / -1 !important;
    }

    .notification-item {
      flex-direction: column !important;
    }

    #collabActiveUsersList {
      grid-template-columns: 1fr 1fr 1fr !important;
    }

    .modal-content {
      width: 90% !important;
      max-height: 85vh !important;
    }
  }

  /* ========================================
     PROFILE PAGE OVERFLOW FIXES (MOBILE)
     ======================================== */

  .profile-wrapper {
    width: 100% !important;
    overflow-x: hidden !important;
    padding: 0 !important;
  }

  .profile-header-new {
    width: 100% !important;
    overflow: hidden !important;
  }

  .profile-header-bg {
    height: 120px !important;
    width: 100% !important;
  }

  .profile-header-content {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    padding: 0 16px !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .profile-pic-container {
    width: 60px !important;
    height: 60px !important;
    margin-top: -30px !important;
    flex-shrink: 0;
  }

  .profile-pic-large {
    width: 60px !important;
    height: 60px !important;
    border: 3px solid var(--bg-primary) !important;
  }

  .profile-header-info {
    flex: 1 !important;
    min-width: 0 !important;
  }

  #profileName {
    font-size: 18px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    margin-bottom: 4px !important;
  }

  #profileBio {
    font-size: 12px !important;
    line-height: 1.4 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    margin-bottom: 8px !important;
  }

  .profile-stats-row {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 12px !important;
    margin-top: 12px !important;
  }

  .stat-box {
    padding: 12px !important;
    text-align: center !important;
    font-size: 11px !important;
  }

  .stat-number {
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
  }

  .stat-name {
    font-size: 10px !important;
    margin-top: 4px !important;
    display: block !important;
  }

  .profile-header-actions {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    padding: 0 16px !important;
    margin: 12px 0 !important;
  }

  .profile-header-actions button {
    flex: 1 !important;
    min-width: 80px !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    min-height: 40px !important;
  }

  .profile-tabs {
    width: 100% !important;
    border-top: 1px solid var(--bg-tertiary) !important;
    padding: 0 !important;
    margin-top: 16px !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
  }

  .profile-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .profile-tab-btn {
    padding: 12px 16px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    border-bottom: 2px solid transparent !important;
  }

  .profile-content {
    width: 100% !important;
    padding: 16px !important;
    overflow-x: hidden !important;
  }

  .profile-content-new {
    width: 100% !important;
    padding: 0 !important;
    overflow-x: hidden !important;
  }

  .profile-section-new {
    width: 100% !important;
    padding: 16px !important;
    overflow-x: hidden !important;
  }

  .section-header {
    width: 100% !important;
    margin-bottom: 16px !important;
  }

  .section-header h2 {
    font-size: 16px !important;
    margin: 0 0 4px 0 !important;
  }

  .section-header p {
    font-size: 12px !important;
    color: var(--text-secondary) !important;
    margin: 0 !important;
  }

  .posts-grid-new {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .badges-grid-new {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .posts-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .post-card {
    width: 100% !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  .post-card-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    margin-bottom: 8px !important;
  }

  .post-card-content {
    font-size: 12px !important;
    line-height: 1.4 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  /* ========================================
     EXPLORE PAGE OVERFLOW FIXES (MOBILE)
     ======================================== */

  #explorePage {
    width: 100% !important;
    overflow-x: hidden !important;
    padding-bottom: 80px !important;
  }

  .explore-header {
    padding: 16px !important;
    gap: 12px !important;
  }

  .explore-header h2 {
    font-size: 20px !important;
    margin: 0 !important;
    white-space: normal !important;
  }

  .search-box {
    width: 100% !important;
    position: relative !important;
  }

  .search-box input {
    width: 100% !important;
    padding: 10px 36px 10px 12px !important;
    font-size: 14px !important;
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    border-radius: 8px !important;
  }

  .search-icon {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
  }

  .explore-content {
    padding: 16px !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .explore-section {
    margin-bottom: 24px !important;
    width: 100% !important;
  }

  .explore-section h3 {
    font-size: 16px !important;
    margin: 0 0 12px 0 !important;
    font-weight: 600 !important;
  }

  .posts-grid,
  .users-grid,
  .writers-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .post-item,
  .user-item,
  .writer-item {
    width: 100% !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  .post-item-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    margin-bottom: 8px !important;
  }

  .post-item-author,
  .post-item-date {
    font-size: 11px !important;
    color: var(--text-secondary) !important;
  }

  .user-item-info,
  .writer-item-info {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .user-item-name,
  .writer-item-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .user-item-bio,
  .writer-item-bio {
    font-size: 11px !important;
    color: var(--text-secondary) !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    margin-top: 4px !important;
  }

  /* ========================================
     ADMIN PAGE OVERFLOW FIXES (MOBILE)
     ======================================== */

  #adminPage {
    width: 100% !important;
    overflow-x: hidden !important;
    padding: 16px !important;
    padding-bottom: 80px !important;
  }

  .admin-page {
    width: 100% !important;
  }

  .admin-header {
    margin-bottom: 20px !important;
  }

  .admin-header h1 {
    font-size: 20px !important;
    margin: 0 !important;
  }

  .admin-tabs {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    margin-bottom: 20px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--bg-tertiary) !important;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .admin-tab-btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  .admin-tab-content {
    width: 100% !important;
  }

  .admin-section {
    margin-bottom: 24px !important;
  }

  .admin-section h2 {
    font-size: 16px !important;
    margin: 0 0 16px 0 !important;
  }

  .admin-table-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin !important;
    margin-bottom: 16px !important;
  }

  .admin-table {
    width: 100% !important;
    font-size: 11px !important;
    border-collapse: collapse !important;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 8px !important;
    text-align: left !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .admin-table th {
    background: var(--bg-secondary) !important;
    font-weight: 600 !important;
  }

  .admin-table td {
    border-bottom: 1px solid var(--bg-tertiary) !important;
  }

  .admin-table input,
  .admin-table select,
  .admin-table button {
    width: 100% !important;
    padding: 6px 4px !important;
    font-size: 11px !important;
    min-height: 32px !important;
  }

  .admin-form {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .admin-form-group {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .admin-form-group label {
    font-size: 12px !important;
    font-weight: 600 !important;
    margin-bottom: 6px !important;
  }

  .admin-form-group input,
  .admin-form-group select,
  .admin-form-group textarea {
    width: 100% !important;
    padding: 10px 8px !important;
    font-size: 14px !important;
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    border-radius: 6px !important;
    min-height: 40px !important;
  }

  .admin-btn-group {
    display: flex !important;
    gap: 8px !important;
    margin-top: 12px !important;
    flex-wrap: wrap !important;
  }

  .admin-btn-group button {
    flex: 1 !important;
    min-width: 80px !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    min-height: 40px !important;
  }

  /* ========================================
     HEADER OPTIMIZATION (MOBILE)
     ======================================== */

  .app-header {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 16px !important;
    height: auto !important;
    min-height: 50px !important;
  }

  .header-brand {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .brand-icon-mobile {
    font-size: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .brand-name-mobile {
    font-size: 16px !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    white-space: nowrap !important;
  }

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

  /* Show app name on mobile, hide on desktop */
  @media (min-width: 481px) {
    .brand-icon-mobile,
    .brand-name-mobile {
      display: none !important;
    }

    .header-title {
      display: block !important;
      font-size: 16px !important;
      font-weight: 600 !important;
    }
  }

  /* ========================================
     TABLET SPECIFIC FIXES (600px - 900px)
     ======================================== */

  @media (min-width: 481px) and (max-width: 900px) {
    .posts-grid,
    .users-grid,
    .writers-grid {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    }

    .profile-stats-row {
      grid-template-columns: repeat(3, 1fr) !important;
    }

    .admin-table {
      font-size: 12px !important;
    }

    .admin-table th,
    .admin-table td {
      padding: 12px !important;
    }

    .search-box input {
      font-size: 15px !important;
    }

    .explore-header h2 {
      font-size: 22px !important;
    }

    .profile-stats-row {
      width: 100% !important;
    }
  }
}