/* ==========================================================================
   assets/css/mobile_app.css - Mobile WebApp / PWA Dedicated Stylesheet
   App-like Touch UX, Bottom Navigation Dock, Mobile Bottom Sheets & Cards
   ========================================================================== */

/* Standalone & Touch Defaults */
@supports (padding: max(0px)) {
  body {
    padding-left: min(0vmin, env(safe-area-inset-left));
    padding-right: min(0vmin, env(safe-area-inset-right));
  }
}

/* Base Body Padding on Mobile to prevent content being covered by App Dock */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* Compact glass card layout for mobile */
  .glass-card {
    padding: 1.1rem 0.95rem;
    border-radius: 12px;
  }

  /* Touch micro-interactions */
  .btn-primary:active, .btn-secondary:active, .app-nav-item:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
  }
}

/* ==========================================================================
   1. BOTTOM APP NAVIGATION DOCK (Native App Feel on Mobile)
   ========================================================================== */
.mobile-app-dock {
  display: none;
}

@media (max-width: 768px) {
  .mobile-app-dock {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(11, 17, 32, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(245, 158, 11, 0.25);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: space-around;
  }

  .app-dock-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #94a3b8;
    height: 100%;
    position: relative;
    transition: color 0.2s ease;
  }

  .app-dock-item .dock-icon {
    font-size: 1.35rem;
    line-height: 1;
    margin-bottom: 2px;
    transition: transform 0.2s ease, filter 0.2s ease;
  }

  .app-dock-item .dock-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.2px;
  }

  /* Active Tab in App Dock */
  .app-dock-item.active {
    color: var(--primary-gold, #f59e0b);
  }

  .app-dock-item.active .dock-icon {
    transform: translateY(-2px);
    filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.6));
  }

  .app-dock-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
  }

  /* Center Highlighted Hero Button (e.g. Formazione 3D) */
  .app-dock-item.hero-dock-item {
    position: relative;
    top: -12px;
  }

  .hero-dock-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5), 0 0 0 4px #0b1120;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .hero-dock-btn:active {
    transform: scale(0.92);
  }

  .app-dock-item.hero-dock-item .dock-label {
    margin-top: 2px;
    color: var(--primary-gold);
    font-weight: 800;
  }
}

/* ==========================================================================
   2. MOBILE BOTTOM SHEET MENU (Drawer)
   ========================================================================== */
.mobile-bottom-sheet-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-bottom-sheet-backdrop.open {
  display: block;
  opacity: 1;
}

.mobile-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f172a;
  border-top: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 20px 20px 0 0;
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
  z-index: 10001;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.8);
  max-height: 82vh;
  overflow-y: auto;
}

.mobile-bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 44px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  margin: 0 auto 16px auto;
}

.bottom-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.bottom-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  text-decoration: none;
  color: #e2e8f0;
  text-align: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.bottom-sheet-item:active {
  background: rgba(245, 158, 11, 0.15);
  transform: scale(0.95);
}

.bottom-sheet-item .item-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.bottom-sheet-item .item-text {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ==========================================================================
   3. SMART PWA INSTALL BANNER
   ========================================================================== */
.pwa-install-banner {
  display: none;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 1.2rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slideInDown 0.4s ease;
}

@keyframes slideInDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--primary-gold);
  flex-shrink: 0;
}

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

.pwa-banner-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwa-banner-desc {
  font-size: 0.76rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.3;
}

.pwa-install-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.pwa-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* iOS Safari Install Tooltip Modal */
.ios-install-modal {
  display: none;
  position: fixed;
  bottom: 74px;
  left: 14px;
  right: 14px;
  background: #1e293b;
  border: 2px solid var(--accent-cyan);
  border-radius: 16px;
  padding: 16px;
  z-index: 10002;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   4. SCHEMATIC MOBILE CARD VIEWS (For Tables & Results on Phone)
   ========================================================================== */
@media (max-width: 768px) {
  /* Match Fixture Cards on Phone */
  .match-fixture-mobile-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }

  /* Compact Horizontal Scroller for Badges */
  .mobile-horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-horizontal-scroll::-webkit-scrollbar {
    display: none;
  }

  /* Compact Formations on Pitch */
  .football-pitch {
    border-radius: 14px;
  }

  /* High-density Schematic Tables for Smartphone */
  .custom-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
  }
  .custom-table td {
    padding: 10px;
    font-size: 0.8rem;
  }

  /* Role Badges High-Contrast Schematic */
  .badge-role {
    font-weight: 800;
    letter-spacing: 0.5px;
  }

  /* Sticky First Column only when explicitly requested via .sticky-first-col */
  .custom-table.sticky-first-col th:first-child,
  .custom-table.sticky-first-col td:first-child {
    position: sticky;
    left: 0;
    background: #0f172a;
    z-index: 2;
    box-shadow: 2px 0 6px rgba(0,0,0,0.4);
  }

  /* Responsive Typography & Spacing for Smartphone */
  main.main-content h1 {
    font-size: clamp(1.3rem, 4.8vw, 1.75rem) !important;
    line-height: 1.2 !important;
  }

  /* Clean Touch Card spacing */
  .grid-2, .grid-3, .grid-4 {
    gap: 10px !important;
  }
}

/* ==========================================================================
   5. STANDALONE PWA MODE OPTIMIZATIONS (When running as installed App)
   ========================================================================== */
@media all and (display-mode: standalone) {
  /* Hide Install Banners when already installed */
  #pwaInstallBanner, .pwa-install-banner {
    display: none !important;
  }

  /* Extra Notch and Safe Area Spacing on iPhone Fullscreen */
  header.navbar {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  /* App feel: disable user text selection on buttons and nav */
  .mobile-app-dock, .app-dock-item, .btn-primary, .btn-secondary {
    -webkit-user-select: none;
    user-select: none;
  }
}

