/* ============================================
   RESPONSIVE DESIGN FOR MOBILE & TABLET
   ============================================ */

/* ============================================
   SWIPE INDICATOR FOR MOBILE
   ============================================ */

.swipe-indicator {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  z-index: 900;
  pointer-events: none;
  animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 1; }
}

@media (max-width: 768px) {
  .swipe-indicator {
    display: block;
  }
}

/* ============================================
   MOBILE HEADER WITH HAMBURGER MENU
   ============================================ */

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  z-index: 10500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: auto;
}

.mobile-hamburger {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 10501;
  pointer-events: auto;
}

.mobile-hamburger span {
  display: block;
  width: 28px;
  height: 3px;
  background: #fff;
  margin: 4px 0;
  border-radius: 2px;
  transition: all 0.3s;
}

.mobile-hamburger:active span {
  background: #94a3b8;
}

.mobile-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  text-align: center;
}

.mobile-back-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-back-btn:active {
  background: rgba(255,255,255,0.2);
  transform: scale(0.95);
}

/* Mobile Navigation Overlay */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: -300px;
  width: 280px;
  height: 100vh;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  z-index: 1001;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  transition: left 0.3s ease;
  overflow-y: auto;
}

.mobile-nav.active {
  left: 0;
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.mobile-nav-header h2 {
  color: #fff;
  margin: 0;
  font-size: 20px;
}

.mobile-nav-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mobile-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-nav-list li {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.mobile-nav-list li a {
  display: block;
  padding: 16px 20px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s;
}

.mobile-nav-list li a.disabled {
  opacity: 0.5;
  color: #9ca3af;
  pointer-events: none;
  cursor: not-allowed;
}

.mobile-nav-list li a:active {
  background: rgba(255,255,255,0.1);
}

.mobile-nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.2);
  margin: 8px 0;
}

/* Submenu styles */
.mobile-nav-item-with-submenu > a {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.submenu-arrow {
  font-size: 20px;
  transition: transform 0.3s;
}

.mobile-nav-item-with-submenu.open .submenu-arrow {
  transform: rotate(90deg);
}

.mobile-nav-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  overflow: hidden;
}

.mobile-nav-submenu li {
  margin: 0;
}

.mobile-nav-submenu li a {
  padding: 12px 20px 12px 40px !important;
  font-size: 14px;
}

.mobile-nav-submenu li a:hover {
  background: rgba(255,255,255,0.15);
}

/* Hide menu items when not logged in */
.logged-in-only {
  display: none;
}

body.logged-in .logged-in-only {
  display: block;
}

/* Mobile overlay backdrop */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.mobile-nav-overlay.active {
  display: block;
}

/* ============================================
   OLD MOBILE MENU (DEPRECATED)
   ============================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  background: #1e293b;
  color: #e2e8f0;
  border: none;
  border-radius: 8px;
  width: 48px;
  height: 48px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s;
}

.mobile-menu-toggle:hover {
  background: #334155;
  transform: scale(1.05);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

/* Mobile overlay when sidebar is open */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.mobile-overlay.active {
  display: block;
}

/* ============================================
   TABLET SIZE (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
  /* Reduce sidebar width on tablets */
  :root {
    --sidebar-width: 260px;
  }
  
  #app {
    grid-template-columns: var(--sidebar-width) 6px 1fr;
  }
  
  /* Make tiles slightly smaller */
  .project-tiles-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  
  /* Compact toolbar buttons */
  .bottom-toolbar {
    padding: 8px 12px;
  }
  
  .toolbar-btn {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* ============================================
   MOBILE SIZE (< 768px)
   ============================================ */
@media (max-width: 768px) {
  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Convert to mobile layout - main content + bottom project name bar */
  #app {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr auto !important;
    grid-template-areas: 
      "main"
      "toolbar" !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* HIDE BOTTOM TOOLBAR COMPLETELY ON MOBILE */
  .bottom-toolbar {
    display: none !important;
  }
  
  /* HIDE SIDEBAR COMPLETELY ON MOBILE - No sliding drawer complexity */
  .sidebar {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
  }
  
  /* Hide resizer on mobile */
  .resizer {
    display: none !important;
    width: 0 !important;
  }
  
  /* Main content takes full width - use viewport width for true full width */
  .main {
    padding: 80px 20px 70px 20px !important; /* Top padding for header, bottom padding for project name bar */
    grid-area: main;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    margin: 0 !important;
    left: 0 !important;
    right: 0 !important;
    position: relative !important;
    box-sizing: border-box !important;
    background: #f8fafc !important; /* Light background to see content area */
  }
  
  /* Body and html full width - use viewport width */
  body, html {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #f8fafc !important; /* Match .main background to prevent white gaps */
  }
  
  #app {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Content containers inside main should also be full width */
  .main > * {
    max-width: 100vw !important;
  }
  
  /* Auth views full width on mobile */
  #initialAuthView,
  #loginView,
  #registerView,
  #loggedInView {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Auth forms full width */
  .initial-auth-view,
  .login-view,
  .register-view {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Touch-friendly buttons (minimum 44x44px) */
  button, .btn, .primary-btn, .secondary-btn, .toolbar-btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation; /* Prevent zoom on double-tap */
  }
  
  /* Input fields - larger for mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* Prevent iOS zoom */
    padding: 12px;
  }
  
  /* Project tiles - 2 columns on mobile */
  .project-tiles-container {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  
  .project-tile {
    height: 70px !important;
    font-size: 12px !important;
    padding: 8px 10px !important;
    min-height: unset !important;
  }
  
  .project-tile-name {
    font-size: 12px !important;
  }
  
  /* Auth panel - full width */
  .auth input {
    font-size: 16px;
    padding: 12px;
  }
  
  .auth-buttons {
    flex-direction: column;
  }
  
  .auth-buttons button {
    width: 100%;
    margin-bottom: 8px;
  }
  
  /* Task form - stack vertically */
  .task-form {
    gap: 12px;
  }
  
  .priority-status-row,
  .date-row,
  .assignment-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .priority-status-row > *,
  .date-row > * {
    width: 100% !important;
    flex: none !important;
  }
  
  /* Task list - single column */
  .tasks-list {
    gap: 12px;
  }
  
  .task-item {
    padding: 12px;
  }
  
  .task-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  /* Modals - full screen on mobile */
  .modal-content {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }
  
  .modal {
    padding: 0;
  }
  
  /* Bottom toolbar - compact and scrollable */
  .bottom-toolbar {
    padding: 6px 4px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 3px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
  }
  
  .toolbar-btn {
    padding: 6px 8px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    min-width: auto !important;
  }
  
  /* Intermap - mobile friendly */
  .intermap-toolbar {
    padding: 12px;
  }
  
  .map-selector-row,
  .marker-controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .control-group {
    width: 100%;
  }
  
  .compact-select,
  .map-select {
    width: 100%;
  }
  
  .map-container {
    height: 400px;
  }
  
  /* Calendar view - responsive */
  .calendar-view {
    padding: 8px;
  }
  
  /* Schedule view - stack on mobile */
  .schedule-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  
  .schedule-label {
    font-size: 12px;
  }
  
  /* Comments - mobile optimized */
  .comment-item {
    padding: 10px;
  }
  
  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  /* User management - responsive */
  .user-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
  }
  
  .edit-roles-btn {
    width: 100%;
  }
  
  /* Hide top-right icon buttons on mobile - moved to hamburger menu */
  .language-btn,
  .language-dropdown,
  .user-management-btn,
  .role-management-btn,
  .super-admin-btn,
  .trash-btn {
    display: none !important;
  }
  
  /* Notification bell - larger touch target */
  .notification-bell,
  .time-tracker-btn,
  .user-management-btn,
  .trash-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  /* Context menus - better positioning */
  .project-context-menu,
  .marker-context-menu {
    max-width: 90vw;
    left: 50% !important;
    transform: translateX(-50%);
  }
  
  /* Hide drag handles on mobile */
  .task-drag-handle,
  .project-drag-handle {
    display: none;
  }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
  /* Single column layout */
  .project-tiles-container {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .project-tile {
    height: 80px;
  }
  
  /* Compact headers */
  h1 {
    font-size: 16px !important;
  }
  
  h2 {
    font-size: 14px !important;
  }
  
  h3 {
    font-size: 12px !important;
  }
  
  /* Compact body text */
  body {
    font-size: 12px !important;
  }
  
  p, li, span {
    font-size: 11px !important;
  }
  
  /* Toolbar - icons only with tooltips */
  .toolbar-btn span:last-child {
    display: none;
  }
  
  .toolbar-btn {
    min-width: 44px;
    padding: 12px;
    position: relative;
  }
  
  .toolbar-btn span:first-child {
    font-size: 20px;
  }
  
  /* Add tooltips on long press */
  .toolbar-btn:active::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
  }
  
  /* Sidebar full width */
  .sidebar {
    width: 100%;
    max-width: 100%;
  }
  
  /* Compact form labels */
  label {
    font-size: 14px;
  }
  
  /* Task cards - compact */
  .card {
    padding: 12px;
  }
  
  /* Priority/Status badges - smaller */
  .status-badge {
    font-size: 11px;
    padding: 2px 6px;
  }
  
  /* Intermap controls - stacked */
  .marker-action-group {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
  }
  
  .marker-action-group button {
    width: 100%;
  }
  
  /* Map markers - larger for touch */
  .map-marker {
    font-size: 32px;
  }
  
  .marker-delete-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  
  /* Undo toast - position for mobile */
  .undo-toast {
    left: 10px;
    right: 10px;
    bottom: 80px; /* Above toolbar */
  }
  
  /* Color picker - full width grid */
  .colors-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  }
}

/* ============================================
   VERY SMALL MOBILE (< 360px)
   ============================================ */
@media (max-width: 360px) {
  .main {
    padding: 70px 8px 8px 8px;
  }
  
  .mobile-menu-toggle {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  
  /* Ultra compact tiles */
  .project-tile {
    height: 70px;
    font-size: 11px;
  }
  
  /* Smaller buttons */
  button, .btn {
    font-size: 13px;
    padding: 10px;
  }
  
  /* Modal padding */
  .modal-content {
    padding: 12px;
  }
  
  .modal-header,
  .modal form {
    padding: 12px;
  }
}

/* ============================================
   LANDSCAPE MODE ADJUSTMENTS
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  /* Reduce vertical padding in landscape */
  .main {
    padding-top: 60px;
  }
  
  .mobile-menu-toggle {
    top: 8px;
    left: 8px;
    width: 40px;
    height: 40px;
  }
  
  .project-tile {
    height: 60px;
  }
  
  /* Compact sidebar */
  .sidebar {
    padding: 8px;
  }
  
  .auth {
    margin-bottom: 8px;
  }
  
  .auth input {
    margin-bottom: 6px;
    padding: 8px;
  }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* Auto dark mode support for mobile */
  .mobile-menu-toggle {
    background: #0f172a;
  }
  
  .mobile-overlay {
    background: rgba(0, 0, 0, 0.8);
  }
}

/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */

/* Remove hover effects on touch devices */
@media (hover: none) {
  .project-tile:hover,
  .task-item:hover,
  .toolbar-btn:hover {
    transform: none;
    background: inherit;
  }
  
  /* Add active states instead */
  .project-tile:active {
    transform: scale(0.97);
    opacity: 0.8;
  }
  
  .toolbar-btn:active {
    background: rgba(59, 130, 246, 0.1);
  }
  
  /* Disable drag handles completely on touch */
  [draggable="true"] {
    -webkit-user-drag: none;
  }
}

/* ============================================
   ACCESSIBILITY ON MOBILE
   ============================================ */

/* Larger focus indicators */
@media (max-width: 768px) {
  button:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
  }
  
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    button,
    input,
    select {
      border-width: 2px;
    }
  }
  
  /* Reduce motion for those who prefer */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
    
    .sidebar {
      transition: none;
    }
    
    .mobile-menu-toggle {
      transition: none;
    }
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .bottom-toolbar,
  .mobile-menu-toggle,
  .mobile-overlay,
  .mobile-header,
  .mobile-nav {
    display: none !important;
  }
  
  .main {
    padding: 0;
  }
  
  #app {
    display: block;
  }
}

/* ============================================
   MOBILE SPECIFIC (< 768px)
   ============================================ */
@media (max-width: 768px) {
  /* Show mobile header */
  .mobile-header {
    display: flex !important;
  }
  
  /* Show mobile nav when initialized */
  .mobile-nav {
    display: block;
  }
  
  /* Hide desktop sidebar completely on mobile */
  .sidebar {
    display: none !important;
  }
  
  /* Adjust main content area for mobile header */
  .main {
    margin-left: 0 !important;
    padding-top: 70px !important; /* Mobile header */
    padding-bottom: 100px !important; /* Space for search at bottom */
    width: 100% !important;
  }
  
  /* Show desktop header as search field at bottom on mobile */
  .main > header {
    display: block !important;
    padding: 12px !important;
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    z-index: 1000 !important;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15) !important;
    border-top: 1px solid #e5e7eb !important;
  }
  
  .header-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  .header-content h1 {
    display: none !important;
  }
  
  .global-search-container {
    width: 100% !important;
  }
  
  .global-search-input {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    border-radius: 8px !important;
    border: 1px solid #d1d5db !important;
  }
  
  .search-toggle-btn {
    display: none !important;
  }
  
  .header-filters {
    display: none !important;
  }
  
  /* Search results should appear above search field on mobile */
  .search-results {
    position: fixed !important;
    top: auto !important;
    bottom: 90px !important; /* Above search field */
    left: 10px !important;
    right: 10px !important;
    max-height: 60vh !important;
    margin: 0 !important;
    z-index: 10000 !important;
  }
  
  /* Hide bottom toolbar icons on mobile */
  .bottom-toolbar {
    display: none !important;
  }
  
  /* Project tiles - 2 columns on mobile, compact size */
  .project-tiles-container {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    padding: 8px;
  }
  
  .project-tile {
    width: 100% !important;
    padding: 10px 12px !important;
    min-height: 60px !important;
  }
  
  .project-tile-name {
    font-size: 11px !important;
  }
  
  /* Content cards - full width */
  .card {
    margin: 12px;
    padding: 16px;
  }
  
  /* Modals - fullscreen on mobile */
  .modal-content {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  
  /* Forms - better spacing */
  .form-group {
    margin-bottom: 16px;
  }
  
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 14px !important; /* Still large enough to prevent iOS zoom */
  }
  
  /* Task list - stacked */
  .task-item {
    padding: 12px;
  }
  
  /* Kanban columns - horizontal scroll */
  .kanban-board {
    flex-direction: row;
    overflow-x: auto;
    gap: 12px;
    padding: 12px;
  }
  
  .kanban-column {
    min-width: 300px;
    flex-shrink: 0;
  }
  
  /* Calendar - compact */
  .calendar-grid {
    font-size: 10px;
  }
  
  .calendar-day {
    min-height: 60px;
  }
  
  /* Chat - full height */
  #chatMessagesContainer {
    height: calc(100vh - 250px);
  }
  
  /* Intermap - full width */
  .intermap-container {
    padding: 12px;
  }
  
  .map-view {
    height: 400px;
  }
  
  /* Hide unnecessary elements on mobile */
  .auth-minimize-btn,
  .user-management-btn,
  .trash-btn {
    display: none !important;
  }
}

/* Extra small devices (< 480px) */
@media (max-width: 480px) {
  .mobile-title {
    font-size: 16px;
  }
  
  .mobile-back-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .project-tiles-container {
    gap: 6px !important;
    padding: 6px !important;
  }
  
  .project-tile {
    padding: 8px !important;
    height: 60px !important;
  }
  
  .project-tile-name {
    font-size: 11px !important;
  }
  
  .toolbar-btn {
    padding: 5px 7px !important;
    font-size: 9px !important;
    white-space: nowrap !important;
  }
  
  .bottom-toolbar {
    padding: 5px 3px !important;
    gap: 2px !important;
  }
  
  /* Stack form elements vertically */
  .priority-status-row,
  .date-row,
  .assignment-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  .priority-status-row > *,
  .date-row > *,
  .assignment-row > * {
    width: 100% !important;
  }
  
  /* ============================================
     MOBILE VIEW SPECIFIC FIXES
     ============================================ */
  
  /* 2. CALENDAR - Compact and scrollable */
  .calendar-view:not([style*="display: none"]) {
    padding: 12px 8px !important;
    overflow-y: auto !important;
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .calendar-grid {
    font-size: 9px !important;
    overflow-x: auto !important;
  }
  
  .calendar-day {
    min-height: 50px !important;
    padding: 4px !important;
    font-size: 8px !important;
  }
  
  .calendar-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 0 !important;
    margin-bottom: 16px !important;
  }
  
  .calendar-header h2 {
    font-size: 16px !important;
    margin: 0 !important;
  }
  
  .calendar-nav {
    width: 100% !important;
    justify-content: space-between !important;
  }
  
  .calendar-nav button {
    padding: 8px 12px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
  }
  
  .calendar-nav span {
    flex: 1 !important;
    text-align: center !important;
    font-size: 12px !important;
  }
  
  .calendar-quick-nav {
    margin-top: 0 !important;
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  
  .calendar-quick-nav button {
    padding: 6px 12px !important;
    font-size: 12px !important;
    flex: 1 !important;
    min-width: 80px !important;
  }
  
  /* 3. KANBAN - Horizontal scroll, compact columns */
  .kanban-view:not([style*="display: none"]) {
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    overflow: hidden !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  .kanban-header {
    flex-shrink: 0 !important;
    padding: 12px !important;
  }
  
  .kanban-board {
    flex: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 12px !important;
    padding: 12px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .kanban-column {
    min-width: 280px !important;
    max-width: 280px !important;
    flex-shrink: 0 !important;
  }
  
  .kanban-column-header {
    padding: 12px !important;
    font-size: 12px !important;
  }
  
  .kanban-column-header h3 {
    font-size: 12px !important;
  }
  
  .kanban-task {
    padding: 10px !important;
    margin-bottom: 8px !important;
    font-size: 11px !important;
  }
  
  /* 5. CONCEPT MAP / PROJECT MAP - Touch friendly */
  .concept-map-view:not([style*="display: none"]) {
    padding: 12px 8px !important;
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    overflow: hidden !important;
  }
  
  .concept-map-container {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    touch-action: pan-x pan-y !important;
  }
  
  .concept-map-container svg {
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;
  }
  
  /* Larger touch targets for map nodes */
  .concept-map-container circle,
  .concept-map-container rect {
    cursor: pointer !important;
  }
  
  /* 6. REPORTS - Scrollable, compact tables */
  .reports-view:not([style*="display: none"]) {
    padding: 12px 8px !important;
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .reports-content {
    overflow-y: auto !important;
    height: auto !important;
  }
  
  .report-section {
    padding: 12px !important;
  }
  
  .report-table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .report-table {
    font-size: 11px !important;
  }
  
  .report-table th,
  .report-table td {
    padding: 6px 8px !important;
    font-size: 11px !important;
  }
  
  .report-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  .report-chart-container {
    height: 250px !important;
  }
  
  .report-stat-cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  
  .report-stat-card {
    padding: 10px !important;
  }
  
  .stat-value {
    font-size: 20px !important;
  }
  
  .stat-label {
    font-size: 11px !important;
  }
  
  /* 7. CHAT - Compact formatting toolbar, mobile-optimized */
  .chat-view:not([style*="display: none"]) {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 140px) !important;
    max-height: calc(100vh - 140px) !important;
    overflow: hidden !important;
    position: relative !important;
  }
  
  .chat-header {
    flex-shrink: 0 !important;
    padding: 12px !important;
  }
  
  .chat-messages-container {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 0 !important;
    padding-bottom: 160px !important;
  }
  
  #chatMessagesContainer {
    height: 100% !important;
    max-height: none !important;
  }
  
  .chat-input-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 8px !important;
    border-top: 1px solid #e5e7eb !important;
    background: #fff !important;
    z-index: 1000 !important;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1) !important;
  }
  
  .chat-formatting-toolbar {
    padding: 6px 8px !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 8px !important;
  }
  
  .format-btn {
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 4px !important;
    font-size: 10px !important;
    flex-shrink: 0 !important;
  }
  
  .format-btn strong,
  .format-btn em,
  .format-btn u,
  .format-btn s,
  .format-btn span {
    font-size: 10px !important;
  }
  
  .chat-input-wrapper {
    display: flex !important;
    gap: 8px !important;
    align-items: flex-end !important;
  }
  
  .chat-input {
    flex: 1 !important;
    font-size: 12px !important;
    padding: 10px !important;
    min-height: 60px !important;
    max-height: 120px !important;
    resize: vertical !important;
  }
  
  .send-chat-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
    flex-shrink: 0 !important;
  }
  
  .chat-message {
    padding: 8px !important;
    font-size: 11px !important;
  }
  
  /* Dashboard - better mobile layout */
  .dashboard-view:not([style*="display: none"]) {
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .dashboard-grid {
    padding: 12px 8px !important;
  }
  
  .charts-section {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  .chart-container {
    padding: 12px !important;
  }
  
  .chart-container canvas {
    max-height: 250px !important;
  }
  
  /* Tasks view - mobile friendly */
  .tasks-view:not([style*="display: none"]) {
    padding: 12px 8px !important;
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .tasks-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding-bottom: 120px !important;
  }
  
  /* Sökfilter - en kolumn */
  .filter-row {
    display: block !important;
  }
  
  .filter-group {
    display: block !important;
    width: 100% !important;
    margin-bottom: 12px !important;
  }
  
  .filter-group input,
  .filter-group select {
    display: block !important;
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
  }
  
  /* Intermap - touch friendly */
  .intermap-container:not([style*="display: none"]) {
    padding: 12px 8px !important;
    height: calc(100vh - 130px) !important; /* 60px header + 60px toolbar + 10px margin */
    max-height: calc(100vh - 130px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .intermap-toolbar {
    padding: 12px 8px !important;
  }
  
  .map-selector-row,
  .marker-controls-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  .control-group {
    width: 100% !important;
  }
  
  .map-view {
    height: 400px !important;
    overflow: auto !important;
    touch-action: pan-x pan-y !important;
  }
  
  .map-container {
    min-width: 100% !important;
    touch-action: pan-x pan-y !important;
  }
  
  /* Map markers - larger for touch */
  .map-marker {
    font-size: 28px !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  
  .marker-delete-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 14px !important;
  }
  
  /* ============================================
     MOBILE CHECKLIST IMPROVEMENTS
     ============================================ */
  
  /* Checklist items - easier to tap */
  .checklist-item {
    padding: 14px !important;
    margin-bottom: 10px !important;
    min-height: 50px !important;
    touch-action: manipulation !important;
  }
  
  .checklist-item input[type="checkbox"] {
    width: 24px !important;
    height: 24px !important;
    margin-right: 12px !important;
    flex-shrink: 0 !important;
  }
  
  /* Checklist buttons - larger touch targets */
  .checklist-item button {
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 8px !important;
    font-size: 18px !important;
  }
  
  /* ============================================
     IMPROVED TOUCH FEEDBACK
     ============================================ */
  
  /* Remove hover states, add active states for touch */
  button:active,
  .btn:active,
  .toolbar-btn:active {
    transform: scale(0.95) !important;
    opacity: 0.8 !important;
  }
  
  /* Kanban cards - better touch feedback */
  .kanban-task:active {
    transform: scale(0.98) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  }
  
  /* Project tiles - visual feedback */
  .project-tile:active {
    transform: scale(0.95) !important;
    opacity: 0.9 !important;
  }
  
  /* ============================================
     BETTER SCROLL INDICATORS
     ============================================ */
  
  /* Show scrollbar hints on touch devices */
  .kanban-board::-webkit-scrollbar,
  .bottom-toolbar::-webkit-scrollbar {
    height: 8px !important;
  }
  
  .kanban-board::-webkit-scrollbar-track,
  .bottom-toolbar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1) !important;
    border-radius: 4px !important;
  }
  
  .kanban-board::-webkit-scrollbar-thumb,
  .bottom-toolbar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3) !important;
    border-radius: 4px !important;
  }
  
  /* ============================================
     MOBILE MODAL IMPROVEMENTS
     ============================================ */
  
  /* Modal close button - larger */
  .modal-close {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Modal headers - more padding */
  .modal-header {
    padding: 16px !important;
    position: sticky !important;
    top: 0 !important;
    background: white !important;
    z-index: 10 !important;
    border-bottom: 1px solid #e5e7eb !important;
  }
  
  /* Modal footer - sticky on mobile */
  .modal-footer {
    padding: 16px !important;
    position: sticky !important;
    bottom: 0 !important;
    background: white !important;
    border-top: 1px solid #e5e7eb !important;
    z-index: 10 !important;
  }
  
  /* Modal content - scrollable middle section */
  .modal form,
  .modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 16px !important;
  }
  
  /* ============================================
     SAFE AREA SUPPORT (iPhone X+)
     ============================================ */
  
  .mobile-header {
    padding-top: env(safe-area-inset-top) !important;
    height: calc(60px + env(safe-area-inset-top)) !important;
  }
  
  .mobile-nav {
    padding-top: env(safe-area-inset-top) !important;
    height: calc(100vh) !important;
  }
  
  .bottom-toolbar {
    padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
  }
  
  .main {
    padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  }
  
  .main.search-collapsed {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }
  
  /* Search header at bottom needs safe area too */
  header {
    bottom: calc(60px + env(safe-area-inset-bottom)) !important;
  }
  
  /* Dark mode support for fixed header on mobile */
  body.dark-mode header {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-top: 1px solid #334155 !important;
  }
  
  body.dark-mode .header-content h1 {
    color: #e2e8f0 !important;
  }
  
  /* ============================================
     WHITEBOARD - HIDE ZOOM/PAN BUTTONS ON MOBILE
     ============================================ */
  
  /* Hide zoom and pan control buttons on mobile - use touch gestures instead */
  /* Keep reset zoom button visible */
  #whiteboardPanUpBtn,
  #whiteboardPanDownBtn,
  #whiteboardPanLeftBtn,
  #whiteboardPanRightBtn,
  #whiteboardZoomOutBtn,
  #whiteboardZoomInBtn,
  #whiteboardZoomLevel {
    display: none !important;
  }
  
  /* Keep the separator visible but adjust spacing */
  .whiteboard-header > div > div[style*="margin-left: auto"] {
    gap: 8px !important;
  }
}
