/* ============================================================
   JANOSCI — Mobile Friendliness polish
   Loaded after components.css; wins by cascade specificity.
   Target: phones (≤ 900px) with extra care ≤ 600px and ≤ 380px.
   ============================================================ */

/* Everything sizes correctly on small screens */
html, body {
  max-width: 100%;
}
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

/* Prevent iOS zoom on focus for small inputs */
@media (max-width: 900px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  textarea,
  select,
  .form-control {
    font-size: 16px; /* avoids iOS auto-zoom on focus */
  }
}

/* Comfortable tap target across the site */
@media (max-width: 900px) {
  .btn,
  .btn-sm,
  .btn-lg,
  .cart-btn,
  .user-btn,
  .mobile-action-btn,
  .bottom-nav-item,
  .qty-btn,
  .sidebar-close-btn,
  .scroll-top-btn {
    min-height: 44px;
  }
  .qty-btn { width: 40px; height: 40px; }
  .qty-input { height: 40px; }
}

/* ─── Reusable container breathing room ─── */
@media (max-width: 600px) {
  .container { padding-left: 1rem; padding-right: 1rem; }
  .section { padding: 2.5rem 0; }
  .section-sm { padding: 1.5rem 0; }
  .section-header { margin-bottom: 1.75rem; }
  .section-header h2 { font-size: 1.3rem; }
  .section-header p { font-size: .85rem; padding: 0 .5rem; }
}

/* ─── HERO SECTION ─── */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 3rem;
  }
  .hero-content h1 {
    font-size: 2.2rem;
  }
  .hero-badge {
    margin: 0 auto 1.5rem;
  }
  .hero-actions {
    justify-content: center;
  }
  .hero-trust-row {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }
  .hero-trust-sep {
    display: none;
  }
  .hero-img-side {
    order: -1;
    margin-bottom: 1rem;
  }
  .hero-img-side-ring {
    width: 300px !important;
    height: 300px !important;
    margin: 0 auto;
  }
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 500px;
    margin: 2rem auto 0;
  }
}

@media (max-width: 600px) {
  .hero-content h1 {
    font-size: 1.8rem;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero-stat .stat-num {
    font-size: 1.2rem;
  }
  .hero-stat .stat-label {
    font-size: 0.7rem;
  }
}

/* ─── FEATURES STRIP ─── */
@media (max-width: 900px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}
@media (max-width: 600px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .feature-item {
    justify-content: center;
    text-align: center;
    flex-direction: column;
  }
}

/* ─── PRODUCTS PAGE SIDEBAR ─── */
@media (max-width: 900px) {
  .filter-toggle-btn {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
    margin-bottom: 1rem;
  }
  .sidebar.mobile-active {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: var(--white);
    padding: 2rem;
    overflow-y: auto;
  }
  .sidebar-close-btn {
    display: block !important;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--navy);
  }
}

/* ─── PRODUCT DETAIL PAGE ─── */
@media (max-width: 900px) {
  .product-detail-grid {
    grid-template-columns: 1fr;
  }
  .product-gallery {
    max-width: 500px;
    margin: 0 auto 2rem;
  }
}

/* ─── FOOTER ─── */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }
}
@media (max-width: 600px) {
  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer-brand, .footer-links, .footer-contact {
    align-items: center;
  }
  .footer-social {
    justify-content: center;
  }
}


/* ─── CATEGORY TILES on narrow phones ─── */
@media (max-width: 380px) {
  .category-tiles {
    grid-template-columns: 1fr;
  }
  .cat-tile { padding: 1rem .9rem; }
  .cat-tile-icon { width: 50px; height: 50px; }
  .cat-tile-info h3 { font-size: .9rem; }
}

/* ─── PRODUCT CARDS: single column on very small phones ─── */
@media (max-width: 380px) {
  .products-grid,
  .product-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Keep product action buttons wrapping well on narrow phones */
@media (max-width: 420px) {
  .product-actions {
    flex-wrap: wrap;
    gap: .4rem;
  }
  .product-actions .btn {
    font-size: .78rem;
    padding: .55rem .7rem;
  }
  .product-info { padding: .85rem; }
  .product-name { font-size: .85rem; }
  .product-price,
  .price-current { font-size: 1rem; }
}

/* ─── CART LAYOUT ─── */
@media (max-width: 600px) {
  .cart-item {
    flex-direction: column;
    align-items: stretch;
    gap: .85rem;
  }
  .cart-item-image {
    width: 100%;
    height: 160px;
  }
  .cart-item > div[style*="text-align:right"],
  .cart-item > div[style*="text-align: right"] {
    text-align: left !important;
  }
  .cart-summary {
    padding: 1.25rem;
    border-radius: 16px;
  }
  .coupon-form {
    flex-wrap: wrap;
  }
  .coupon-form input { min-width: 0; flex: 1; }
}

/* ─── CHECKOUT ─── */
@media (max-width: 900px) {
  .checkout-grid { gap: 1rem; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .payment-option {
    padding: .85rem;
    flex-wrap: wrap;
  }
  .payment-option > div { flex: 1 1 180px; min-width: 0; }
}

/* ─── PRODUCT DETAIL ─── */
@media (max-width: 900px) {
  .product-detail-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
  .gallery-main { aspect-ratio: 1/1; }
  .gallery-thumbs { gap: .5rem; }
  .gallery-thumb { width: 68px; height: 68px; }
  .qty-add-row .qty-control { flex-shrink: 0; }
  .qty-add-row .btn-lg { flex: 1 1 220px; }
}
@media (max-width: 420px) {
  .rating-summary {
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
    padding: 1rem;
  }
  .rating-big { min-width: 0; }
  .rating-bars { min-width: 0; }
  .spec-pills { gap: .35rem; }
  .spec-pill { font-size: .72rem; padding: .3rem .65rem; }
}

/* ─── PROFILE ─── */
@media (max-width: 900px) {
  .profile-layout { gap: 1rem; }
  .profile-sidebar {
    order: -1; /* put sidebar on top for small screens */
  }
  .profile-avatar { padding: 1.5rem; }
  .avatar-circle { width: 64px; height: 64px; font-size: 1.5rem; }
}

/* ─── ORDERS PAGE ─── */
@media (max-width: 600px) {
  .order-status,
  .badge { font-size: .65rem; }
}
@media (max-width: 480px) {
  .card .card-body > div[style*="grid-template-columns:1fr auto"] {
    grid-template-columns: 1fr !important;
    text-align: left;
  }
  .card .card-body > div[style*="grid-template-columns:1fr auto"] > div:last-child {
    text-align: left !important;
  }
}

/* ─── AUTH PAGES ─── */
@media (max-width: 480px) {
  .auth-card-header { padding: 1.5rem 1rem 1rem; }
  .auth-card-body { padding: 1.25rem 1rem 1.5rem; }
  .otp-input { font-size: 1.3rem !important; letter-spacing: .3rem; }
  .auth-tab { font-size: .72rem; }
}

/* ─── REGISTER FORM ─── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ─── NAVBAR DROPDOWN on mobile — unreachable; hide cleanly ─── */
@media (max-width: 900px) {
  .user-menu,
  .user-dropdown { display: none !important; }
}

/* ─── FOOTER ─── */
@media (max-width: 600px) {
  .footer { padding-top: 3rem; }
  .footer h4 { margin-bottom: 1rem; font-size: .88rem; }
  .footer-desc { font-size: .85rem; }
  .footer-bottom p { font-size: .75rem; }
}

/* ─── PROMOTIONAL STRIPS ─── */
@media (max-width: 600px) {
  .promo-banner {
    flex-direction: column;
    align-items: flex-start !important;
    text-align: left;
    gap: 1rem !important;
  }
  .promo-code { font-size: .9rem; padding: .4rem 1rem; }
}

/* ─── HERO adjustments for very small phones ─── */
@media (max-width: 380px) {
  .hero-content h1 { font-size: 1.5rem; }
  .hero-badge { font-size: .72rem; padding: .35rem .75rem; }
  .hero-stat { padding: .7rem .5rem; }
  .stat-num { font-size: 1.35rem; }
  .stat-label { font-size: .65rem; }
}

/* ─── ADMIN CALLBACK (basic): keep admin tables scrolling ─── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── TRUST STRIP horizontal scroll on phones ─── */
@media (max-width: 600px) {
  .trust-section { padding: 1.25rem 0; }
}

/* ─── TESTIMONIALS ─── */
@media (max-width: 480px) {
  .testimonial-card { padding: 1.5rem 1.25rem; }
  .testimonial-text { font-size: .86rem; }
}

/* ─── NEWSLETTER small phones ─── */
@media (max-width: 420px) {
  .newsletter-section h2 { font-size: 1.35rem; }
  .newsletter-section p { font-size: .85rem; }
  .newsletter-form input,
  .newsletter-form button { padding: .8rem 1.15rem; font-size: .9rem; }
}

/* ─── BLOG ─── */
@media (max-width: 600px) {
  .blog-grid { grid-template-columns: 1fr; }
  .blog-single-title { font-size: 1.6rem; }
  .blog-single-lead { font-size: .95rem; }
}

/* ─── MISC: prevent horizontal overflow from long words ─── */
h1, h2, h3, h4, .product-name, .blog-card-title, .cart-item-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ─── MISC: bottom nav respects safe area + avoid page overlap ─── */
@media (max-width: 900px) {
  .sticky-atc-bar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    flex-wrap: wrap;
    gap: .75rem;
  }
  .sticky-atc-bar .atc-product-name {
    flex: 1 1 100%;
    order: -1;
    font-size: .82rem;
  }
}

/* ─── Flash message on phones ─── */
@media (max-width: 600px) {
  .flash-message {
    font-size: .82rem;
    padding: .75rem 1rem;
  }
}


/* ============================================================
   FINAL MOBILE FIXES (critical UI improvements)
   ============================================================ */

/* ─── Product card badge text overflow fix ─── */
.janosci-product-card .sale-badge {
  font-size: 0.62rem;
  padding: 0.2rem 0.5rem;
  max-width: 70px;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .janosci-product-card .sale-badge {
    font-size: 0.58rem;
    padding: 0.15rem 0.4rem;
    top: 8px;
    left: 8px;
  }
  .janosci-product-card .wishlist-btn {
    width: 30px;
    height: 30px;
    top: 8px;
    right: 8px;
  }
  .janosci-product-card .wishlist-btn i {
    font-size: 0.8rem;
  }
}

/* ─── Make sure card images load with proper aspect ratio ─── */
.janosci-product-card .card-img-wrap {
  background: #fff;
  position: relative;
}
.janosci-product-card .card-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 70%, rgba(0,0,0,0.02) 100%);
}

/* ─── Product card mobile layout — 2 columns with proper spacing ─── */
@media (max-width: 600px) {
  .products-grid,
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem !important;
    padding: 0 0.25rem;
  }
  .janosci-product-card {
    border-radius: 12px;
  }
  .janosci-product-card .card-body {
    padding: 0.7rem 0.65rem 0.85rem !important;
  }
  .janosci-product-card .card-brand {
    font-size: 0.55rem;
    margin-bottom: 0.2rem;
  }
  .janosci-product-card .card-title {
    font-size: 0.78rem !important;
    line-height: 1.25;
    min-height: 2.5em !important;
    margin-bottom: 0.3rem;
  }
  .janosci-product-card .card-price {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }
  .janosci-product-card .card-price del {
    font-size: 0.7rem;
    margin-left: 0.25rem;
  }
  .janosci-product-card .btn-add-cart {
    font-size: 0.7rem !important;
    padding: 0.45rem 0.3rem !important;
  }
  .janosci-product-card .btn-add-cart i {
    margin-right: 0.2rem;
  }
}

@media (max-width: 380px) {
  .janosci-product-card .btn-add-cart i + span,
  .janosci-product-card .btn-add-cart {
    font-size: 0.65rem !important;
  }
}

/* ─── HEADER: More polished mobile navbar ─── */
@media (max-width: 991px) {
  .navbar {
    height: 60px !important;
  }
  .navbar-inner {
    padding: 0 0.75rem !important;
    gap: 0.5rem !important;
  }
  .site-nav,
  .navbar-search-wrap,
  .navbar-actions {
    display: none !important;
  }
  .navbar-mobile-actions {
    display: flex !important;
    gap: 0.4rem;
    margin-left: auto;
  }
  .navbar-logo-wrap {
    padding: 4px 8px !important;
    border-radius: 8px;
  }
  .navbar-brand-logo {
    height: 28px !important;
  }
  .navbar-mobile-actions .navbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff;
  }
  body.has-annbar .navbar {
    top: 36px;
  }
}

/* ─── HERO mobile improvements ─── */
@media (max-width: 768px) {
  .hero {
    min-height: auto !important;
    padding: 4rem 0 2.5rem !important;
  }
  .hero-content {
    text-align: center;
  }
  .hero-content h1 {
    font-size: clamp(1.5rem, 7vw, 2rem) !important;
    line-height: 1.15 !important;
  }
  .hero-content p {
    font-size: 0.88rem !important;
    margin-bottom: 1.5rem !important;
  }
  .hero-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    margin-top: 1.25rem !important;
  }
  .hero-stat {
    padding: 0.75rem 0.4rem !important;
    min-width: 0 !important;
  }
  .hero-stat .stat-num {
    font-size: 1.1rem !important;
  }
  .hero-stat .stat-label {
    font-size: 0.62rem !important;
  }
  .hero-img-side {
    display: none !important;
  }
}

/* ─── ANNOUNCEMENT BAR — compact on mobile ─── */
@media (max-width: 600px) {
  .ann-bar {
    font-size: 0.7rem;
    padding: 0.4rem 0;
    height: auto;
  }
  .ann-bar .ann-item {
    font-size: 0.7rem;
  }
}

/* ─── CATEGORY TILES — clean mobile grid ─── */
@media (max-width: 600px) {
  .category-tiles {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem;
  }
  .cat-tile {
    padding: 0.85rem 0.65rem !important;
    flex-direction: column;
    text-align: center;
    gap: 0.5rem !important;
  }
  .cat-tile-icon {
    width: 42px !important;
    height: 42px !important;
    font-size: 1rem;
  }
  .cat-tile-info h3 {
    font-size: 0.78rem !important;
    line-height: 1.2;
  }
  .cat-tile-info p {
    font-size: 0.65rem !important;
  }
  .cat-tile-arrow {
    display: none;
  }
}

/* ─── FOOTER mobile cleanup ─── */
@media (max-width: 600px) {
  .footer {
    padding: 2.5rem 0 1.5rem !important;
    margin-top: 2rem !important;
  }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    text-align: left;
  }
  .footer h4 {
    font-size: 0.85rem !important;
    margin-bottom: 0.85rem !important;
  }
  .footer-links li {
    margin-bottom: 0.55rem;
  }
  .footer-links li a {
    font-size: 0.85rem;
  }
  .footer-desc {
    font-size: 0.85rem !important;
    margin-bottom: 1rem !important;
  }
  .footer-contact-item {
    font-size: 0.82rem;
  }
  .social-links {
    justify-content: flex-start;
    margin-top: 0.5rem;
  }
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding-top: 1.5rem !important;
  }
  .footer-bottom p {
    font-size: 0.72rem !important;
  }
}

/* ─── Bottom nav doesn't get hidden on scroll up issue ─── */
@media (max-width: 900px) {
  .bottom-nav {
    transform: translateY(0) !important;
  }
}

/* ─── Section header on mobile ─── */
@media (max-width: 600px) {
  .section-header h2 {
    font-size: 1.25rem !important;
  }
  .section-header p {
    font-size: 0.82rem;
  }
  .section-tag {
    font-size: 0.65rem;
  }
}

/* ─── Trust section horizontal scroll on mobile ─── */
@media (max-width: 768px) {
  .trust-grid {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 0 0.5rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .trust-grid::-webkit-scrollbar { display: none; }
  .trust-divider { display: none; }
  .trust-badge {
    flex-shrink: 0;
    min-width: 175px;
    padding: 0.85rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  }
}

/* ─── Newsletter mobile fix ─── */
@media (max-width: 600px) {
  .newsletter-section {
    padding: 2.5rem 0 !important;
  }
  .newsletter-form {
    flex-direction: column;
    gap: 0.5rem;
  }
  .newsletter-form input,
  .newsletter-form button {
    width: 100%;
  }
}

/* ─── Page hero on internal pages ─── */
@media (max-width: 600px) {
  .page-hero {
    padding: 1.5rem 0 1rem !important;
  }
  .page-hero-title {
    font-size: 1.3rem !important;
  }
  .page-hero-desc {
    font-size: 0.85rem;
  }
}

/* ─── Cart and checkout mobile ─── */
@media (max-width: 600px) {
  .cart-layout {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

/* ─── Image loading state - prevent broken icon flash ─── */
img[loading="lazy"]:not(.loaded) {
  opacity: 0;
}
img[loading="lazy"].loaded,
img:not([loading]) {
  opacity: 1;
  transition: opacity 0.3s ease;
}
