/* ================================================================
   responsive.css — Tune Tycoon Mobile / Tablet Responsive Layer
   Target: All viewports below 1150px
   ================================================================ */

/* === GLOBAL OVERFLOW FIX === */
html, body, #app {
  max-width: 100vw;
  overflow-x: hidden;
}

/* === TALL VIEWPORT FILL === */
#app main.row {
  display: flex !important;
  flex: 1;
}
#view-container,
#product-calculator-container {
  min-height: calc(100vh - 160px);
}


/* === STAT BAR: prevent overflow on any viewport === */
#stat-time,
#stat-level {
  white-space: nowrap;
  flex-shrink: 0;
}
#stat-time span,
#stat-level span {
  white-space: nowrap;
}
#header-row-2 > div {
  flex-shrink: 0;
}

/* === TABLET & DESKTOP COMPRESSION (769px – 1250px) === */
@media (max-width: 1250px) {

  /* Prevent nav button label wrapping */
  .nav-sidebar button {
    white-space: nowrap !important;
  }
}


/* === MOBILE NAV ICON-ONLY MODE (769px – 900px) === */
@media (max-width: 900px) and (min-width: 769px) {
  .nav-sidebar button span {
    display: none !important;
  }
  .nav-sidebar button i {
    margin: 0 auto;
    font-size: 1.5rem !important;
  }
  .nav-sidebar {
    width: 80px !important;
    align-items: center;
  }
}


/* === PAGE TITLE WRAP FIX (≤850px) === */
@media (max-width: 850px) {
  h1, h2, .page-title, #view-container h2 {
    font-size: clamp(1rem, 3.5vw, 1.75rem) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* === MOBILE (≤768px) === */
@media (max-width: 768px) {

  /* ============================================================
     RES-01: Mobile navigation — horizontal Tab Bar
     ============================================================ */
  #app main.row {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
  }

  #app .nav-sidebar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: 50px !important;
    max-height: 80px !important;
    padding: 0.25rem !important;
    gap: 0.25rem !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    border-right: none !important;
    border-bottom: 1px solid var(--bs-secondary) !important;
    background: rgba(0,0,0,0.8) !important;
    backdrop-filter: blur(10px);
  }

  /* View containers must have a definite height so overflow-y-auto can scroll.
     100px = fixed header, ~60px = horizontal nav tab bar. */
  #view-container,
  #product-calculator-container {
    height: calc(100vh - 160px) !important;
    overflow-y: auto !important;
  }

  /* Evenly distribute nav buttons in horizontal strip */
  #app .nav-sidebar .btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem 0.1rem !important;
    margin: 0 !important;
    gap: 0.15rem !important;
    text-align: center !important;
    border-radius: 4px !important;
    height: auto !important;
    align-self: center !important;
  }

  #app .nav-sidebar .btn i {
    font-size: 1.2rem !important;
  }

  #app .nav-sidebar .btn span {
    font-size: 0.42rem !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    width: 100% !important;
    letter-spacing: -0.015rem !important;
    font-weight: 600 !important;
  }

  /* Hide HR separators in horizontal mode */
  #app .nav-sidebar hr {
    display: none !important;
  }


  /* ============================================================
     RES-02: Header — keep the 2-row layout compact and readable
     The desktop header is 2 rows inside a 100px fixed bar.
     Mobile preserves this exact structure at the same height.
     ============================================================ */

  /* Row 1: Brand + Cash + SAVE — already handled by d-md-none/d-md-inline-block on buttons */

  /* Row 2: ensure level/time/auth tools stay on one line */
  #header-row-2 {
    font-size: 0.65rem !important;
  }

  #header-row-2 #stat-time span,
  #header-row-2 #stat-level span {
    font-size: 0.65rem !important;
    white-space: nowrap !important;
  }

  /* Keep XP progress bar sized correctly (do NOT apply column flex to it) */
  #stat-xp-container {
    width: 30px !important;
    height: 5px !important;
  }

  /* Tighten auth tool buttons in row 2 */
  #auth-status-container .btn {
    font-size: 0.6rem !important;
    padding: 0 6px !important;
    height: 24px !important;
  }
  #auth-status-container .btn span {
    display: none !important; /* Icon only on mobile — same as desktop collapsed */
  }
  #auth-status-container .btn i {
    margin: 0 !important;
    font-size: 0.85rem !important;
  }


  /* ============================================================
     VISUAL JUICE: Toast Depth & Card Consistency
     ============================================================ */
  .toast, #system-toast-container .toast, #game-toast-container .toast {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.95), 0 0 15px rgba(0, 210, 255, 0.15) !important;
    border: 1px solid rgba(0, 210, 255, 0.45) !important;
    backdrop-filter: blur(14px) !important;
    border-radius: 10px !important;
  }

  .card {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 12px !important;
  }

  /* Unified Page Header Spacing */
  #view-container > .container-fluid,
  #product-calculator-container {
    margin-top: 0 !important;
    padding-top: 0.8rem !important;
  }

  h2.text-uppercase {
    margin-top: 0 !important;
    font-size: 1.3rem !important;
    letter-spacing: 0.05rem !important;
  }

  /* Tutorial tooltip adjustments */
  #app .tutorial-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
    z-index: 10001;
    font-size: 18px;
    font-weight: bold;
  }
}


/* === SMALL PHONE (≤430px) === */
@media (max-width: 430px) {
  /* Hide secondary stats if still overflowing */
  #stat-vram,
  #stat-burn,
  #stat-level {
    display: none !important;
  }
}


/* === TALL VIEWPORTS FIX === */
@media (min-height: 900px) {
  #view-container {
    min-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
  }

  #view-container > .container-fluid,
  #view-container > .row {
    flex: 1;
  }
}


/* === PRODUCT TOOL BUTTON PROFESSIONALIZATION === */
#product-calculator-container .btn,
#view-container .btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  text-transform: uppercase !important;
  font-weight: 700 !important;
}

#product-calculator-container .btn-sm,
#view-container .btn-sm {
  padding: 6px 14px !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.3px !important;
  border-radius: 6px !important;
}

.btn-xs {
  padding: 3px 8px !important;
  font-size: 0.6rem !important;
  border-radius: 4px !important;
}

@media (max-width: 576px) {
  #product-calculator-container #game-run-simulation-btn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 0.85rem !important;
    margin-top: 5px;
  }

  .info-icon {
    width: 14px !important;
    height: 14px !important;
  }

  /* 8px left edge, 46px reserved on right for the 38px handle + breathing room */
  .tutorial-tooltip {
    width: calc(100vw - 56px) !important;
    left: 8px !important;
    bottom: 80px !important; /* Move up to clear bottom nav icons if any, and center slightly more */
    padding: 12px;
    font-size: 0.85rem;
    border-radius: 12px !important;
  }

  /* Compact the handle to fit in the reserved right margin */
  .tutorial-handle {
    width: 34px !important;
    height: 54px !important;
    font-size: 1.1rem !important;
  }

  .tutorial-avatar {
    width: 48px !important;
    height: 48px !important;
    flex-shrink: 0;
  }
}
