/* ================================================
   PWA Mobile Optimized Styles
   Video Converter - Tigres TV
   ================================================ */

/* ==================== CSS Variables ==================== */
:root {
  --pwa-primary: #667eea;
  --pwa-primary-dark: #5a6fd6;
  --pwa-secondary: #764ba2;
  --pwa-bg-dark: #1a1a2e;
  --pwa-bg-darker: #16213e;
  --pwa-text-light: #ffffff;
  --pwa-text-muted: #8899aa;
  --pwa-success: #28a745;
  --pwa-warning: #ffc107;
  --pwa-danger: #dc3545;
  --pwa-border-radius: 12px;
  --pwa-bottom-nav-height: 64px;
  --pwa-safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==================== Base Mobile Styles ==================== */
@media (max-width: 768px) {
  /* Hide desktop sidebar on mobile */
  .sidebar {
    display: none !important;
  }
  
  /* Full width main content */
  .main-content {
    margin-left: 0 !important;
    padding-bottom: calc(var(--pwa-bottom-nav-height) + var(--pwa-safe-area-bottom) + 20px) !important;
  }
  
  .col-md-10 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Smaller page titles */
  h2 {
    font-size: 1.5rem;
  }
  
  /* Stack buttons on mobile */
  .d-flex.gap-2 {
    flex-wrap: wrap;
  }
  
  /* Full width cards on mobile */
  .col-md-4, .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Smaller table font */
  table {
    font-size: 0.85rem;
  }
  
  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none !important;
  }
}

/* ==================== Bottom Navigation ==================== */
.pwa-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--pwa-bottom-nav-height);
  background: var(--pwa-bg-dark);
  border-top: 1px solid rgba(255,255,255,0.1);
  z-index: 1050;
  padding-bottom: var(--pwa-safe-area-bottom);
}

@media (max-width: 768px) {
  .pwa-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
}

.pwa-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--pwa-text-muted);
  padding: 8px 12px;
  border-radius: 12px;
  transition: all 0.2s ease;
  min-width: 64px;
}

.pwa-nav-item:hover,
.pwa-nav-item:focus {
  color: var(--pwa-text-light);
  background: rgba(255,255,255,0.1);
}

.pwa-nav-item.active {
  color: var(--pwa-primary);
  background: rgba(102, 126, 234, 0.15);
}

.pwa-nav-item i {
  font-size: 1.4rem;
  margin-bottom: 2px;
}

.pwa-nav-item span {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ==================== Install Prompt ==================== */
.pwa-install-prompt {
  display: none;
  position: fixed;
  bottom: calc(var(--pwa-bottom-nav-height) + var(--pwa-safe-area-bottom) + 16px);
  left: 16px;
  right: 16px;
  background: linear-gradient(135deg, var(--pwa-primary) 0%, var(--pwa-secondary) 100%);
  border-radius: var(--pwa-border-radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 1040;
  animation: slideUp 0.3s ease-out;
}

.pwa-install-prompt.show {
  display: block;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-install-icon {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-install-icon i {
  font-size: 1.5rem;
  color: white;
}

.pwa-install-text {
  flex: 1;
}

.pwa-install-text h6 {
  margin: 0 0 4px;
  color: white;
  font-weight: 600;
}

.pwa-install-text p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
}

.pwa-install-actions {
  display: flex;
  gap: 8px;
}

.pwa-install-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.pwa-install-btn.primary {
  background: white;
  color: var(--pwa-primary);
}

.pwa-install-btn.primary:hover {
  background: rgba(255,255,255,0.9);
  transform: scale(1.02);
}

.pwa-install-btn.secondary {
  background: rgba(255,255,255,0.2);
  color: white;
}

.pwa-install-btn.secondary:hover {
  background: rgba(255,255,255,0.3);
}

/* ==================== Offline Indicator ==================== */
.pwa-offline-indicator {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--pwa-warning);
  color: #000;
  text-align: center;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 1060;
}

.pwa-offline-indicator.show {
  display: block;
}

body.offline .pwa-offline-indicator {
  display: block;
}

/* ==================== Pull to Refresh ==================== */
.pwa-pull-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pwa-bg-dark);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: top 0.3s;
  z-index: 1055;
}

.pwa-pull-indicator.pulling {
  top: 16px;
}

.pwa-pull-indicator i {
  color: var(--pwa-primary);
  font-size: 1.5rem;
  transition: transform 0.3s;
}

.pwa-pull-indicator.refreshing i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==================== Mobile Cards ==================== */
@media (max-width: 768px) {
  .card {
    margin-bottom: 12px;
    border-radius: 16px;
  }
  
  .card-body {
    padding: 16px;
  }
  
  /* Swipeable card actions */
  .card-swipe-actions {
    position: absolute;
    right: -80px;
    top: 0;
    bottom: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pwa-danger);
    border-radius: 0 16px 16px 0;
  }
}

/* ==================== Touch Optimizations ==================== */
@media (max-width: 768px) {
  /* Larger touch targets */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 6px 12px;
  }
  
  /* Prevent text selection on interactive elements */
  .pwa-nav-item,
  .btn,
  .card {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Smooth scrolling */
  .main-content,
  .video-list-container {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==================== Floating Action Button ==================== */
.pwa-fab {
  display: none;
  position: fixed;
  bottom: calc(var(--pwa-bottom-nav-height) + var(--pwa-safe-area-bottom) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pwa-primary) 0%, var(--pwa-secondary) 100%);
  border: none;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1030;
}

@media (max-width: 768px) {
  .pwa-fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.pwa-fab:hover,
.pwa-fab:focus {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.pwa-fab:active {
  transform: scale(0.95);
}

/* ==================== Status Bar Theming ==================== */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top, 0px);
  }
  
  /* Hide address bar related UI */
  .browser-only {
    display: none !important;
  }
}

/* ==================== Loading States ==================== */
.pwa-skeleton {
  background: linear-gradient(90deg, #2a3a4a 25%, #3a4a5a 50%, #2a3a4a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.pwa-skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.pwa-skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

.pwa-skeleton-card {
  height: 120px;
  margin-bottom: 16px;
}

/* ==================== Toast Notifications ==================== */
.pwa-toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1070;
  pointer-events: none;
}

@media (min-width: 768px) {
  .pwa-toast-container {
    left: auto;
    width: 360px;
  }
}

.pwa-toast {
  background: var(--pwa-bg-dark);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  pointer-events: auto;
  animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-toast.success { border-left: 4px solid var(--pwa-success); }
.pwa-toast.warning { border-left: 4px solid var(--pwa-warning); }
.pwa-toast.error { border-left: 4px solid var(--pwa-danger); }
.pwa-toast.info { border-left: 4px solid var(--pwa-primary); }

/* ==================== Responsive Modals ==================== */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100%;
  }
  
  .modal-content {
    height: 100%;
    border-radius: 0;
    border: none;
  }
  
  .modal-xl .modal-dialog {
    max-width: 100%;
  }
  
  /* Slide up animation for modals */
  .modal.fade .modal-dialog {
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
  }
  
  .modal.show .modal-dialog {
    transform: translateY(0);
  }
}

/* ==================== Dark Mode Optimizations ==================== */
/* Note: Dark mode styling is disabled to maintain consistent light theme 
   across all devices. Uncomment and extend if full dark mode support is needed. */
/*
@media (prefers-color-scheme: dark) {
  body {
    background-color: var(--pwa-bg-dark);
    color: var(--pwa-text-light);
  }
  
  .card {
    background: var(--pwa-bg-darker);
    border-color: rgba(255,255,255,0.1);
  }
  
  .card-title, .card-body h6, .card-header {
    color: var(--pwa-text-light);
  }
  
  .text-muted {
    color: var(--pwa-text-muted) !important;
  }
  
  .form-control,
  .form-select {
    background: var(--pwa-bg-dark);
    border-color: rgba(255,255,255,0.1);
    color: var(--pwa-text-light);
  }
  
  .form-control:focus,
  .form-select:focus {
    background: var(--pwa-bg-dark);
    border-color: var(--pwa-primary);
    color: var(--pwa-text-light);
  }
}
*/
