/**
 * Mobile-Optimized CSS for Ideation Hub PWA
 * Enhances mobile experience with better touch targets,
 * spacing, and PWA-specific UI elements
 * 
 * @version 1.0.0
 */

/* ========================================
   PWA Install Banner
   ======================================== */

.pwa-install-banner {
  position: fixed;
  bottom: -100px;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transition: bottom 0.3s ease;
}

.pwa-install-banner.show {
  bottom: 0;
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 15px;
  max-width: 800px;
  margin: 0 auto;
}

.pwa-install-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
}

.pwa-install-text h4 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.pwa-install-text p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

.pwa-install-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

#pwa-install-btn {
  background: white;
  color: #667eea;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

#pwa-dismiss-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
}

/* Update Banner */
.pwa-update-banner {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #fbbf24;
  color: #78350f;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transition: top 0.3s ease;
}

.pwa-update-banner.show {
  top: 20px;
}

.pwa-update-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.pwa-update-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

#pwa-update-btn {
  background: #78350f;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

/* iOS Install Modal */
.ios-install-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
}

.ios-install-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  text-align: center;
}

.ios-install-content h3 {
  margin: 0 0 20px;
  color: #333;
}

.ios-install-content ol {
  text-align: left;
  margin: 20px 0;
  padding-left: 20px;
}

.ios-install-content li {
  margin: 12px 0;
  line-height: 1.6;
}

.ios-install-content i {
  color: #667eea;
  margin: 0 4px;
}

/* ========================================
   Mobile Optimizations
   ======================================== */

@media (max-width: 768px) {
  
  /* Larger Touch Targets */
  .btn,
  a.btn,
  button {
    min-height: 44px;
    padding: 10px 16px;
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 8px 12px;
  }
  
  /* Better Input Fields */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    min-height: 44px;
    padding: 10px 12px;
  }
  
  textarea {
    min-height: 120px;
  }
  
  /* Card Spacing */
  .card {
    margin-bottom: 15px;
  }
  
  .card-body {
    padding: 15px;
  }
  
  /* Navigation */
  .navbar {
    padding: 10px 15px;
  }
  
  .navbar-brand {
    font-size: 18px;
  }
  
  /* Dashboard Grid */
  .idea-grid {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 10px;
  }
  
  .idea-card {
    padding: 15px;
  }
  
  /* Modal Dialogs */
  .modal-dialog {
    margin: 10px;
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-header,
  .modal-footer {
    padding: 15px;
  }
  
  .modal-body {
    padding: 20px 15px;
  }
  
  /* Tables */
  .table-responsive {
    border: none;
  }
  
  table {
    font-size: 14px;
  }
  
  table td,
  table th {
    padding: 8px 6px;
  }
  
  /* Form Groups */
  .form-group {
    margin-bottom: 15px;
  }
  
  label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
  }
  
  /* Alerts */
  .alert {
    padding: 12px 15px;
    font-size: 14px;
  }
  
  /* Badges */
  .badge {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  /* Action Buttons */
  .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .action-buttons .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Filters */
  .filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  .filters .form-control {
    width: 100%;
  }
  
  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .page-item .page-link {
    padding: 8px 12px;
  }
}

/* ========================================
   Pull-to-Refresh Indicator
   ======================================== */

.pull-to-refresh {
  position: fixed;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 10px 20px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 9998;
  transition: top 0.3s ease;
}

.pull-to-refresh.active {
  top: 70px;
}

.pull-to-refresh i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========================================
   Offline Indicator
   ======================================== */

.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ef4444;
  color: white;
  padding: 8px 15px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.show {
  transform: translateY(0);
}

.offline-indicator i {
  margin-right: 8px;
}

/* ========================================
   Bottom Navigation (Mobile)
   ======================================== */

@media (max-width: 768px) {
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 8px 0;
    display: flex;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  }
  
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    color: #6b7280;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: color 0.2s;
  }
  
  .bottom-nav-item i {
    font-size: 20px;
  }
  
  .bottom-nav-item.active {
    color: #667eea;
  }
  
  .bottom-nav-item:hover {
    color: #667eea;
  }
  
  /* Add padding to body to account for bottom nav */
  body.has-bottom-nav {
    padding-bottom: 65px;
  }
}

/* ========================================
   Swipe Gestures Visual Feedback
   ======================================== */

.swipe-action-left,
.swipe-action-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  opacity: 0;
  transition: opacity 0.2s;
}

.swipe-action-left {
  left: 0;
  background: #10b981;
}

.swipe-action-right {
  right: 0;
  background: #ef4444;
}

.swiping-left .swipe-action-left,
.swiping-right .swipe-action-right {
  opacity: 1;
}

/* ========================================
   Loading States
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 16px;
  margin: 8px 0;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin: 12px 0;
}

.skeleton-card {
  height: 200px;
  margin: 15px 0;
}

/* ========================================
   Safe Area Insets (for iPhone X and newer)
   ======================================== */

@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .navbar,
  .bottom-nav {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
  
  .bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* ========================================
   Standalone Mode (Installed PWA)
   ======================================== */

@media all and (display-mode: standalone) {
  /* Hide browser-specific elements */
  .browser-only {
    display: none;
  }
  
  /* Adjust header for status bar */
  .navbar {
    padding-top: max(10px, env(safe-area-inset-top));
  }
  
  /* Custom status bar color simulation */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: #667eea;
    z-index: 9999;
  }
}

/* ========================================
   Landscape Orientation
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
  .modal-dialog {
    max-width: 90%;
    margin: 10px auto;
  }
  
  .bottom-nav {
    flex-direction: row;
  }
  
  .bottom-nav-item {
    flex-direction: row;
    gap: 8px;
  }
  
  .bottom-nav-item i {
    font-size: 18px;
  }
}

/* ========================================
   Accessibility Improvements
   ======================================== */

/* Larger tap targets for important actions */
.important-action {
  min-width: 48px;
  min-height: 48px;
}

/* Focus indicators */
*:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

button:focus,
a:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 2px solid #333;
  }
}
