/**
 * in7.ba — Mobile-first overrides
 * Učitava se globalno, dopunjuje postojeće CSS fajlove.
 *
 * Breakpoint referenca (koristiti uvijek ove vrijednosti):
 *   --bp-xs:  375px  — small phones
 *   --bp-sm:  480px  — large phones (landscape)
 *   --bp-md:  575px  — end of single-column (Bootstrap xs upper edge)
 *   --bp-lg:  768px  — tablet portrait
 *   --bp-xl:  991px  — tablet landscape / small laptop (Bootstrap md upper edge)
 *   --bp-2xl: 1280px — desktop
 *   --bp-3xl: 1600px — ultrawide
 *
 * Redosljed sekcija:
 *   1. Touch targets
 *   2. Hero
 *   3. Search bar
 *   4. Search results
 *   5. Listing cards
 *   6. Listing detail
 *   7. Navigation (hamburger)
 *   8. AI widget
 *   9. Bottom nav bar
 *  10. Dashboard panels
 *  11. Utility (safe-area, scroll, selection)
 */

/* =========================================================
   1. TOUCH TARGETS — sve interaktivno min 44×44px
   ========================================================= */

@media (max-width: 991px) {
  .btn,
  .btn-primary,
  .btn-ghost,
  .btn-icon,
  .btn-nav-ghost,
  .btn-nav-secondary,
  .btn-nav-pricing,
  .hero-btn-primary,
  .hero-btn-secondary,
  .search-btn,
  .nav-link-custom,
  .user-menu-link,
  .hero-segment-tab,
  .hero-cat,
  .in7-btn {
    min-height: 44px;
  }

  input,
  select,
  textarea,
  .form-control,
  .form-select,
  .search-control {
    min-height: 48px;
    font-size: 16px !important; /* sprečava auto-zoom na iOS */
  }
}

/* =========================================================
   2. HERO — mobile
   ========================================================= */

@media (max-width: 575px) {
  /* Hero section on non-home pages (standalone hero) */
  .hero-section {
    padding-top: 80px;
  }

  /* Home page hero is constrained by the viewport-shell grid (1fr row).
     Setting min-height:100dvh here would overflow the shell and clip the search dock. */
  body:not(.page-home) .hero-section {
    min-height: 100dvh;
  }

  .hero-title {
    font-size: clamp(1.9rem, 7vw, 2.8rem) !important;
    line-height: 1.15;
  }

  .hero-subtitle {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .hero-actions {
    flex-direction: column;
    gap: 12px;
  }

  .hero-btn-primary,
  .hero-btn-secondary {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 16px 24px;
    border-radius: 14px;
  }

  .hero-trust-line {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
  }

  .hero-segment-card {
    border-radius: 16px;
    padding: 16px;
  }

  .hero-segment-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 8px;
  }

  .hero-segment-tabs::-webkit-scrollbar {
    display: none;
  }

  .hero-segment-tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .hero-stat-card {
    padding: 10px 8px;
    border-radius: 12px;
  }

  .hero-stat-value {
    font-size: 1.2rem;
  }

  .hero-stat-label {
    font-size: 0.65rem;
  }
}

/* =========================================================
   3. SEARCH BAR — mobile
   ========================================================= */

@media (max-width: 991px) {
  .search-wrapper--premium {
    border-radius: 20px;
    padding: 20px 16px;
  }

  .search-form .row {
    gap: 12px !important;
  }

  .search-form .col-md-6,
  .search-form .col-lg-2,
  .search-form .col-lg-3 {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }

  .search-btn--premium {
    padding: 16px;
    font-size: 1rem;
    border-radius: 12px;
  }
}

@media (max-width: 575px) {
  /* Kompaktnija search sekcija na mobilima */
  .search-dock-row {
    gap: 10px;
  }

  .search-box {
    padding: 14px 16px !important;
  }

  .search-field-label {
    font-size: 12px !important;
  }

  .search-map-peek {
    padding: 12px 14px !important;
  }

  .search-map-peek__copy strong {
    font-size: 12px;
  }

  .search-map-peek__copy span {
    font-size: 10px;
  }

  /* Skryj popularno section na malim ekranima */
  .search-tags {
    display: none !important;
  }

  /* Smanjiti quick chips */
  .search-quick-chips {
    gap: 6px;
    margin-top: 10px;
  }

  .search-quick-chip {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
  }
}

/* =========================================================
   4. SEARCH RESULTS — mobile toolbar i kartice
   ========================================================= */

@media (max-width: 768px) {
  .results-hero {
    padding: 32px 0 16px;
  }

  .results-title {
    font-size: 1.6rem !important;
  }

  .results-toolbar-wrap {
    top: 64px;
    padding: 0 0 12px;
  }

  .results-toolbar {
    padding: 12px;
    border-radius: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .results-toolbar-grid {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: max-content;
  }
}

/* =========================================================
   5. LISTING CARDS — mobile
   ========================================================= */

@media (max-width: 575px) {
  .listing-card,
  .listing-card-v2 {
    border-radius: 16px;
    overflow: hidden;
  }

  .listing-card-img,
  .listing-card-v2-img {
    aspect-ratio: 16 / 9;
    width: 100%;
    object-fit: cover;
  }

  .listing-card-body {
    padding: 14px;
  }

  .listing-price {
    font-size: 1.1rem;
  }

  /* Poboljšanja za featured listing cards na mobilima */
  .lcard {
    border-radius: 14px;
  }

  .lcard-foot {
    padding-top: 8px;
    margin-top: auto;
  }

  /* Smanjiti CTA button na mobilima */
  .lcard-cta {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: var(--r-full);
    border: 1px solid rgba(45, 122, 82, .18);
  }

  .lcard-cta:hover {
    background: rgba(45, 122, 82, .05);
  }

  /* Manje kartice na mobilima */
  .lcard-title {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .lcard-price {
    font-size: 15px;
  }

  .lcard-chip {
    padding: 1px 6px;
    font-size: 10px;
  }
}

/* =========================================================
   6. LISTING DETAIL — mobile
   ========================================================= */

@media (max-width: 768px) {
  .listing-detail-hero {
    border-radius: 0;
    margin: 0 -12px;
  }

  .listing-detail-gallery {
    grid-template-columns: 1fr;
  }

  .listing-cta-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -8px 24px rgba(0,0,0,.1);
    z-index: var(--z-sticky);
    border-radius: 0;
    display: flex;
    gap: 10px;
  }

  .listing-cta-sticky .btn {
    flex: 1;
  }

  /* Prostor za sticky CTA */
  .listing-detail-content {
    padding-bottom: 90px;
  }
}

/* =========================================================
   7. NAVIGATION — mobile hamburger
   ========================================================= */

@media (max-width: 991px) {
  /*
   * FIXED: previous version set background: var(--color-accent) here,
   * making the mobile menu amber/gold. The correct bg is var(--bg-card)
   * which is set in header.css .navbar-collapse. This section now only
   * handles layout overrides — NO background override.
   */
  .navbar-collapse .navbar-nav {
    gap: 2px;
    margin-bottom: 8px;
  }

  /* Nav links in mobile menu — use theme text colors (not white) */
  .navbar-collapse .nav-link-custom {
    display: block;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
  }

  .navbar-collapse .nav-link-custom:hover {
    background: var(--border-subtle);
    color: var(--text-primary);
  }

  .navbar-collapse .nav-link-custom.active {
    background: var(--color-accent-light);
    color: var(--color-accent);
  }

  .navbar-collapse .action-area {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  /* Language + theme toggle share the first row */
  .navbar-collapse .language-switcher {
    flex: 0 0 auto;
  }

  .navbar-collapse .theme-toggle-btn {
    flex: 0 0 auto;
  }

  /* Auth buttons each take their own full-width row */
  .navbar-collapse .btn-nav-ghost,
  .navbar-collapse .btn-nav-secondary,
  .navbar-collapse .user-menu {
    flex: 0 0 100%;
    text-align: center;
    justify-content: center;
    min-height: 44px;
  }
}

/* =========================================================
   8. AI WIDGET — mobile positioning (iznad bottom-nav)
   ========================================================= */

@media (max-width: 768px) {
  .in7-ai-widget {
    bottom: max(80px, calc(80px + env(safe-area-inset-bottom))) !important;
    right: 16px !important;
  }

  .in7-ai-widget .in7-ai-toggle {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .in7-ai-widget .in7-ai-panel {
    bottom: 64px;
    width: min(340px, calc(100vw - 32px));
    height: 480px;
  }
}

/* =========================================================
   9. BOTTOM NAV BAR — samo mobile (nova navigacija)
   ========================================================= */

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    background: var(--bg-card);
    border-top: 1px solid var(--border-default);
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 10px;
    transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item.active,
  .bottom-nav-item:hover {
    color: var(--color-accent);
    background: var(--color-accent-light);
  }

  .bottom-nav-item i {
    font-size: 1.1rem;
    line-height: 1;
  }

  .bottom-nav-item.primary {
    color: #fff;
    background: var(--color-accent);
    border-radius: 14px;
    margin: -4px 4px;
    padding: 8px 12px;
  }

  .bottom-nav-item.primary:hover {
    background: var(--color-accent-hover);
    color: #fff;
  }

  /* Prostor za bottom nav na svim stranicama */
  body {
    padding-bottom: max(68px, calc(68px + env(safe-area-inset-bottom)));
  }
}

/* =========================================================
   10. DASHBOARD — mobile (agent/business panel)
   ========================================================= */

@media (max-width: 768px) {
  .dashboard-sidebar {
    display: none;
  }

  .dashboard-main {
    padding: 12px;
    margin-left: 0 !important;
  }

  .dashboard-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }
}

/* =========================================================
   11. UTILITY — safe area, smooth scroll, selection
   ========================================================= */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@supports (padding: env(safe-area-inset-bottom)) {
  .main-nav {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

::selection {
  background: rgba(197, 160, 89, 0.25);
  color: var(--color-accent);
}

img {
  max-width: 100%;
  height: auto;
}

/* Sprečava horizontalni scroll */
@media (max-width: 575px) {
  body {
    overflow-x: hidden;
  }
}
