/**
 * Banding Page Responsive Styles
 * Improves mobile and tablet layout for product comparison
 */

/* ===== DESKTOP (1024px+) ===== */
.compare-wrapper {
  width: 100%;
  max-width: 100%;
}

.table-compare-wrapper {
  overflow-x: auto;
  margin: 30px 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.table-compare {
  width: 100%;
  min-width: 500px;
}

.table-compare img {
  max-width: 150px;
  max-height: 150px;
}

/* ===== TABLET (768px - 1023px) ===== */
@media (max-width: 1023px) {
  .box-wrapper {
    padding: 20px 16px 16px 16px;
  }

  .table-compare-wrapper {
    padding: 14px;
    margin: 20px 0;
  }

  .table-compare {
    font-size: 0.95rem;
  }

  .table-compare th,
  .table-compare td {
    padding: 12px 8px;
  }

  .table-compare tr.product-image td {
    padding: 12px 6px;
  }

  .table-compare img {
    max-width: 120px;
    max-height: 120px;
  }

  .product-list li {
    width: calc(33.333% - 12px);
    min-height: 280px;
  }

  .compare-description-box {
    padding: 16px;
    max-width: 100%;
  }
}

/* ===== SMALL TABLET (600px - 767px) ===== */
@media (max-width: 767px) {
  html,
  body {
    font-size: 15px;
  }

  .compare-wrapper {
    padding: 0;
  }

  .box-wrapper {
    padding: 16px 12px 12px 12px;
    margin: 0;
    border-radius: 0;
  }

  .title-page {
    font-size: 1.3rem;
    margin: 12px 0;
    padding: 0 12px;
  }

  h1.title-page {
    padding: 0 12px;
  }

  .table-compare-wrapper {
    padding: 10px;
    margin: 16px -12px;
    border-radius: 0;
    overflow: -webkit-paged-x;
    overflow-x: auto;
  }

  .table-compare {
    font-size: 0.9rem;
    min-width: 450px;
  }

  .table-compare th,
  .table-compare td {
    padding: 10px 6px;
    word-wrap: break-word;
  }

  .table-compare tr.product-image td {
    padding: 10px 4px;
  }

  .table-compare tr.product-image td.thumb {
    min-width: 90px;
  }

  .table-compare img {
    max-width: 100px;
    max-height: 100px;
  }

  .table-compare td .remove {
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: 0.95em;
  }

  .product-list li {
    width: calc(50% - 6px);
    min-height: 260px;
    padding: 8px 6px;
  }

  .product-list .title {
    font-size: 0.9rem;
    min-height: 36px;
  }

  .product-list .thumb img {
    max-height: 70px;
  }

  .button,
  button {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-height: 36px;
  }

  .table-compare .button,
  .table-compare .primary {
    font-size: 0.8rem;
    padding: 6px 10px;
    min-height: 32px;
  }

  .compare-description-box {
    padding: 12px 10px 10px 10px;
    border-left: 3px solid #ff9f37;
    margin: 14px -12px;
    border-radius: 0;
    font-size: 0.98em;
  }

  .compare-description-box i.bi {
    left: 8px;
    top: 8px;
    font-size: 1.2em;
  }

  .compare-description-box p {
    margin-left: 24px;
    line-height: 1.5;
  }

  .search-product-wrapper {
    padding: 12px;
    max-width: 100%;
    margin: 12px -12px;
    border-radius: 0;
  }

  .form-search-product .form-row {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .form-search-product label {
    margin-bottom: 4px;
    min-width: none;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row .button,
  .button-row button {
    width: 100%;
  }

  .input-item {
    min-height: 38px;
  }

  .product-list-wrapper ul.product-list {
    gap: 12px;
  }
}

/* ===== MOBILE (< 600px) ===== */
@media (max-width: 599px) {
  html,
  body {
    font-size: 14px;
  }

  .compare-wrapper {
    padding: 0;
  }

  .box-wrapper {
    padding: 12px 10px 10px 10px;
    margin: 0;
    border-radius: 0;
    border: none;
    background: #f5f7fa;
  }

  .title-page,
  h1.title-page {
    font-size: 1.2rem;
    margin: 10px 0;
    padding: 0 10px;
    line-height: 1.3;
  }

  .content {
    padding: 0;
  }

  .table-compare-wrapper {
    padding: 8px;
    margin: 12px -10px;
    border-radius: 0;
    box-shadow: none;
    border: 1px solid #e0e0e0;
    background: #fff;
  }

  .table-compare {
    font-size: 0.85rem;
    min-width: 320px;
  }

  .table-compare th,
  .table-compare td {
    padding: 8px 4px;
    word-wrap: break-word;
    font-size: 0.85rem;
  }

  .table-compare tr.product-image td {
    padding: 8px 2px;
  }

  .table-compare tr.product-image td.thumb {
    min-width: 80px;
  }

  .table-compare img {
    max-width: 90px;
    max-height: 90px;
  }

  .table-compare td .remove {
    width: 22px;
    height: 22px;
    line-height: 22px;
    font-size: 0.9em;
    margin-top: 4px;
  }

  .button,
  button {
    padding: 7px 14px;
    font-size: 0.85rem;
    min-height: 34px;
    margin: 2px;
  }

  .table-compare .button,
  .table-compare .primary {
    font-size: 0.75rem;
    padding: 5px 8px;
    min-height: 30px;
    margin: 2px;
  }

  .product-list li {
    width: 100%;
    min-height: 240px;
    padding: 8px;
  }

  .product-list .title {
    font-size: 0.88rem;
    min-height: 32px;
  }

  .product-list .thumb {
    min-height: 100px;
  }

  .product-list .thumb img {
    max-height: 60px;
  }

  .product-list .button-action button {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .compare-description-box {
    padding: 10px 8px;
    border-left: 3px solid #ff9f37;
    margin: 12px -10px;
    border-radius: 0;
    font-size: 0.95em;
    background: #fffbf7;
  }

  .compare-description-box i.bi {
    position: static;
    display: block;
    margin-bottom: 6px;
    font-size: 1.1em;
    text-align: left;
    opacity: 1;
  }

  .compare-description-box p {
    margin-left: 0;
    line-height: 1.4;
  }

  .search-product-wrapper {
    padding: 14px 12px;
    max-width: 100%;
    margin: 12px -10px;
    border-radius: 0;
    background: #fafbfc;
    border: 1px solid #e0e0e0;
    box-shadow: none;
  }

  .form-search-product .form-row {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .form-search-product label {
    margin-bottom: 4px;
    min-width: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: #344054;
    display: block;
  }

  .form-search-product .form-item {
    flex: 1 1 auto;
    min-width: auto;
  }

  .button-row {
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
  }

  .button-row .button,
  .button-row button {
    width: 100%;
    min-height: 38px;
    font-size: 0.88rem;
    font-weight: 600;
  }

  .input-item {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .input-item:focus {
    padding: 7px 11px;
  }

  .input-item:focus {
    padding: 7px 9px;
  }

  .product-paging ul {
    gap: 4px;
    flex-wrap: wrap;
  }

  .product-paging li {
    margin: 0 1px;
  }

  .product-paging select {
    font-size: 0.9rem;
    padding: 4px 6px;
  }

  .align-center {
    padding: 0 10px;
  }

  /* Improve visibility of action buttons on small screens */
  .mt-8 {
    margin-top: 6px !important;
  }

  .mt-20 {
    margin-top: 14px !important;
  }

  .mt-30 {
    margin-top: 20px !important;
  }
}

/* ===== SMALL MOBILE (< 480px) ===== */
@media (max-width: 479px) {
  .table-compare {
    font-size: 0.8rem;
  }

  .table-compare th,
  .table-compare td {
    padding: 6px 3px;
  }

  .title-page,
  h1.title-page {
    font-size: 1.1rem;
  }

  .button,
  button {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 32px;
  }

  .product-list li {
    min-height: 220px;
  }
}

/* ===== LANDSCAPE MODE (Mobile) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .box-wrapper {
    padding: 10px 10px 8px 10px;
  }

  .table-compare th,
  .table-compare td {
    padding: 8px 4px;
  }

  .table-compare img {
    max-width: 80px;
    max-height: 80px;
  }
}

/* ===== ACCESSIBILITY & PRINT ===== */
@media print {
  .search-product-wrapper,
  .button-row,
  .align-center,
  .mobile-nav,
  nav {
    display: none;
  }

  .table-compare-wrapper {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .table-compare {
    font-size: 11pt;
  }

  .table-compare th,
  .table-compare td {
    padding: 8px;
    border: 1px solid #ccc;
  }

  .button {
    border: 1px solid #ccc;
    background: #f5f5f5;
  }
}

/* ===== MOBILE CAROUSEL VIEW - Better UX for small screens ===== */
@media (max-width: 599px) {
  /* Hide table on mobile, show carousel */
  .table-compare-wrapper {
    display: none !important;
  }

  /* Carousel wrapper */
  .mobile-carousel-wrapper {
    background: #fff;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    border: 1px solid #eef0f2;
  }

  .mobile-carousel-container {
    position: relative;
    width: 100%;
    background: #fff;
  }

  .mobile-carousel-slides {
    position: relative;
    width: 100%;
    height: auto;
    overflow: hidden;
  }

  .mobile-carousel-slide {
    display: none;
    padding: 16px 12px;
    animation: fadeIn 0.3s ease-in;
  }

  .mobile-carousel-slide.active {
    display: block;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  /* Header with close button */
  .mobile-carousel-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
  }

  .mobile-carousel-close {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.3em;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-carousel-close:disabled {
    opacity: 0.5;
  }

  /* Content */
  .mobile-carousel-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Image */
  .mobile-carousel-image {
    width: 100%;
    height: 200px;
    background: #f5f7fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .mobile-carousel-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  /* Title section */
  .mobile-carousel-title h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #101828;
    margin: 0 0 6px 0;
    line-height: 1.3;
  }

  .mobile-carousel-title .brand {
    font-size: 0.88rem;
    color: #667085;
    margin: 0;
    font-weight: 400;
  }

  /* Price */
  .mobile-carousel-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ff9f37;
    padding: 10px 12px;
    background: #fff3e0;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #ffe4c4;
  }

  /* Specs */
  .mobile-carousel-specs {
    background: #f9fafb;
    border-radius: 6px;
    padding: 12px;
  }

  .specs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .spec-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.85rem;
  }

  .spec-item:last-child {
    border-bottom: none;
  }

  .spec-label {
    font-weight: 500;
    color: #667085;
    flex: 0 0 40%;
  }

  .spec-value {
    font-weight: 600;
    color: #101828;
    text-align: right;
    flex: 1;
  }

  .specs-toggle {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #0077ac;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .specs-toggle:active {
    background: #0077ac;
    color: #fff;
  }

  .mobile-carousel-specs.expanded {
    max-height: none;
  }

  /* Actions */
  .mobile-carousel-actions {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap;
    margin-top: 8px !important;
    justify-content: center !important;
  }

  .mobile-carousel-actions > div {
    display: flex !important;
    gap: 8px !important;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center !important;
  }

  .mobile-carousel-actions .button,
  .mobile-carousel-actions a.button {
    flex: 1 1 auto;
    font-size: 0.85rem;
    padding: 12px 20px !important;
    min-height: 44px;
    margin: 0 !important;
    background: #fff !important;
    color: #0077ac !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-sizing: border-box;
  }

  .mobile-carousel-actions .button:active,
  .mobile-carousel-actions a.button:active {
    border: 1px solid #0077ac !important;
    transform: translateY(-1px);
  }

  .mobile-carousel-actions .primary,
  .mobile-carousel-actions a.primary {
    background: #ff9f37 !important;
    border: 1px solid #ff9f37 !important;
    color: #fff !important;
  }

  .mobile-carousel-actions .primary:active,
  .mobile-carousel-actions a.primary:active {
    background: #0077ac !important;
    border: 1px solid #0077ac !important;
  }

  .mobile-carousel-actions .buy,
  .mobile-carousel-actions .buyclick {
    flex: 1 1 auto;
  }

  /* Navigation */
  .mobile-carousel-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    background: #f9fafb;
    border-top: 1px solid #e0e0e0;
  }

  .carousel-prev,
  .carousel-next {
    background: none;
    border: 1px solid #d1d5db;
    color: #0077ac;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    transition: all 0.2s;
  }

  .carousel-prev:active,
  .carousel-next:active {
    background: #0077ac;
    color: #fff;
    border-color: #0077ac;
  }

  .carousel-indicators {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
  }

  .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
  }

  .indicator.active {
    background: #0077ac;
    width: 24px;
    border-radius: 4px;
  }
}

/* ===== TOUCH TARGETS & UX ===== */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices: increase tap targets */
  .button,
  button,
  .input-item,
  select,
  .product-list li {
    min-height: 44px;
  }

  .button,
  button {
    padding: 10px 16px;
  }

  /* Remove hover effects on touch devices */
  .table-compare tr:hover td {
    background: #fff;
  }

  .product-list li:hover {
    transform: none;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  }

  .button:hover,
  button:hover {
    transform: none;
  }
}
