/*
 * RR Academy responsive stability layer
 * Purpose: preserve layout integrity on small screens without global destructive overrides.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

img,
picture,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Override AOS animations on small screens - use higher specificity */
.col-lg-7[data-aos="fade-right"].aos-animate,
.col-lg-7[data-aos="fade-left"].aos-animate,
.col-lg-5[data-aos="fade-right"].aos-animate,
.col-lg-5[data-aos="fade-left"].aos-animate,
[class*="col-"][data-aos*="fade"][class*="animate"],
[class*="col-"][data-aos*="slide"][class*="animate"] {
  transform: none !important;
  animation: none !important;
}

/* Keep interactive controls comfortable on touch devices */
@media screen and (max-width: 1024px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  textarea,
  select,
  .form-control,
  .form_style {
    font-size: 16px;
  }
}

@media screen and (max-width: 991px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Only apply max-height to expanded navbar menu */
  .header .navbar-collapse.show {
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }

  /* Ensure nav links don't overflow when menu is collapsed */
  .header .navbar-collapse.collapse:not(.show) .navbar-nav {
    display: none;
  }

  .header .navbar-nav {
    row-gap: 0;
  }

  .footer-social-bubble {
    position: static;
    margin-bottom: 14px;
    justify-content: flex-start;
  }

  /* Fix row overflow issues with negative margins */
  .row {
    margin-left: -8px;
    margin-right: -8px;
    overflow: hidden;
  }

  [class*="col-"] {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Prevent content from overflowing columns */
  [class*="col-"] > div {
    overflow: hidden;
  }

  /* Fix pricing story heading overflow */
  .pricing-story {
    overflow: hidden;
  }

  /* Force large columns to stack properly at tablet */
  .col-lg-7 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-lg-5 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Ensure table responsiveness and proper alignment */
  .table-responsive {
    margin-left: 0;
    margin-right: 0;
    border: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 100%;
  }

  /* Improve form field spacing */
  .form-group {
    margin-bottom: 12px;
  }

  input,
  textarea,
  select,
  .form-control,
  .form_style {
    width: 100%;
    max-width: 100%;
    padding: 12px 12px;
    min-height: 44px;
  }

  /* Ensure all interactive elements meet minimum touch target size */
  button,
  a.btn,
  .primary_btn,
  .secondary_btn,
  .submit_now,
  [role="button"] {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Specific fix for remove/action buttons */
  button.remove-product,
  button.remove-item {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
  }

  /* Data visibility improvements */
  .card,
  .pricing-card,
  .package-card,
  .course-box,
  .detail-card {
    width: 100%;
    overflow: visible;
  }

  /* Ensure text is visible and not truncated */
  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  li,
  td,
  th,
  label,
  span {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
}

@media screen and (max-width: 767px) {
  h1 {
    font-size: clamp(30px, 8vw, 40px);
    line-height: 1.15;
  }

  h2 {
    font-size: clamp(24px, 6.6vw, 32px);
    line-height: 1.2;
  }

  h3 {
    font-size: clamp(19px, 5vw, 25px);
    line-height: 1.3;
  }

  .sub_banner .sub_banner_con {
    padding: 72px 0;
  }

  .button_wrap {
    gap: 10px;
    flex-wrap: wrap;
  }

  .button_wrap .primary_btn,
  .button_wrap .video-icon {
    width: 100%;
    justify-content: center;
  }

  .banner-con,
  .banner2-con {
    overflow: hidden;
  }

  .form-row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .checkout-section .create-nft-box .form-group,
  .contact-form-card .form-group,
  #orientationForm .form-group {
    margin-bottom: 12px;
  }

  .course-grid,
  .services-grid,
  .trust-cards-grid,
  .pricing-grid,
  .package-grid,
  .contact-cards {
    row-gap: 14px;
  }

  .director-message-card,
  .contact-form-card,
  .detail-card,
  .package-card,
  .pricing-card {
    padding: 20px 16px;
  }

  .footer-newsletter .newsletter-field {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .footer-newsletter .newsletter-field .mail-icon {
    display: none;
  }

  .footer-newsletter .newsletter-field button {
    width: 100%;
  }

  /* Card-style mobile layout only for the cart product list */
  .cart-section .column-labels {
    display: none;
  }

  .cart-section .product {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
  }

  .cart-section .product-image {
    width: 100%;
    height: auto;
  }

  .cart-section .product-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
  }

  .cart-section .product-price,
  .cart-section .product-quantity,
  .cart-section .product-line-price,
  .cart-section .product-removal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .cart-section .product-price::before {
    content: "Price";
    font-weight: 700;
  }

  .cart-section .product-quantity::before {
    content: "Quantity";
    font-weight: 700;
  }

  .cart-section .product-line-price::before {
    content: "Total";
    font-weight: 700;
  }

  .cart-section .product-removal button {
    width: auto;
    min-height: 40px;
  }

  /* Image overflow prevention */
  figure {
    width: 100%;
    overflow: hidden;
  }

  figure img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* Improved data visibility at tablet/mobile */
  .detail-card {
    width: 100%;
  }

  .detail-card h3,
  .detail-card h4,
  .detail-card p,
  .detail-card li {
    line-height: 1.6;
    margin-bottom: 10px;
  }

  /* Ensure pricing table is visible */
  .pricing-service-table {
    width: 100%;
    display: block;
    overflow-x: auto;
  }

  .pricing-service-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .pricing-service-table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  /* Align list items properly */
  ul, ol {
    padding-left: 20px;
  }

  li {
    margin-bottom: 8px;
    line-height: 1.6;
  }

  /* Improve form label alignment */
  label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
  }

  /* Checkbox and radio improvements */
  input[type="checkbox"],
  input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
  }

  /* Improved data visibility at tablet/mobile */
  .detail-card {
    width: 100%;
  }

  .detail-card h3,
  .detail-card h4,
  .detail-card p,
  .detail-card li {
    line-height: 1.6;
    margin-bottom: 10px;
  }

  /* Ensure pricing table is visible */
  .pricing-service-table {
    width: 100%;
    display: block;
    overflow-x: auto;
  }

  .pricing-service-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .pricing-service-table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  /* Align list items properly */
  ul, ol {
    padding-left: 20px;
  }

  li {
    margin-bottom: 8px;
    line-height: 1.6;
  }

  /* Improve form label alignment */
  label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
  }

  /* Checkbox and radio improvements */
  input[type="checkbox"],
  input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
  }
}

@media screen and (max-width: 575px) {
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  [class*="col-"] {
    padding-left: 7px;
    padding-right: 7px;
  }

  .header .navbar-brand img {
    max-width: 132px;
  }

  .sub_banner .sub_banner_con p,
  .hero-subtitle,
  .pricing-lead,
  .contact-lead {
    font-size: 14px;
    line-height: 1.55;
  }

  .pricing-service-table {
    font-size: 13px;
  }

  .pricing-service-table th,
  .pricing-service-table td {
    padding: 10px 8px;
  }

  /* Form field consistency at smaller screens */
  .checkout-section .form-group,
  .create-nft-box .form-group,
  .contact-form-card .form-group,
  #orientationForm .form-group {
    width: 100%;
    margin-bottom: 12px;
  }

  /* Ensure two-column forms stack properly */
  .row .col-md-6,
  .row .col-lg-6,
  .form-row [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Image sizing at mobile */
  .sub_banner img,
  .banner-image,
  .hero-image {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* Remove button sizing */
  button.remove-product,
  button.remove-item {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px;
  }
}

@media screen and (max-width: 360px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow: visible;
  }

  [class*="col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Reset AOS animations that cause horizontal offset */
  .aos-animate {
    transform: none !important;
  }

  [class*="col-"].aos-animate {
    transform: none !important;
  }

  .pricing-story,
  .contact-form-card,
  .detail-card,
  section > div {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sub_banner .sub_banner_con {
    padding: 58px 0;
  }

  .header .navbar-nav .nav-item a {
    font-size: 14px;
    padding: 11px 12px;
  }

  /* Ultra-compact layout for smallest screens */
  h1 {
    font-size: 24px;
    line-height: 1.2;
  }

  h2 {
    font-size: 20px;
    line-height: 1.2;
  }

  h3 {
    font-size: 16px;
    line-height: 1.3;
  }

  h4 {
    font-size: 14px;
  }

  p {
    font-size: 13px;
    line-height: 1.5;
  }

  /* Form field optimization for touch */
  input,
  textarea,
  select,
  .form-control {
    padding: 10px 8px;
    font-size: 14px;
    min-height: 40px;
  }

  .form-group {
    margin-bottom: 10px;
  }

  /* Minimum button size for touch */
  button,
  a.btn,
  .primary_btn,
  .submit_now {
    min-height: 40px;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Aggressive image containment */
  img {
    max-width: 100%;
    height: auto !important;
  }

  .sub_banner img,
  .banner-image,
  .hero-image,
  figure img {
    width: 100%;
    max-width: 100% !important;
    height: auto;
    display: block;
  }

  /* Prevent section overflow */
  section {
    overflow: hidden;
  }

  /* Table optimization */
  .pricing-service-table {
    font-size: 12px;
  }

  .pricing-service-table th,
  .pricing-service-table td {
    padding: 8px 6px;
  }

  /* Card optimization */
  .card,
  .detail-card,
  .package-card,
  .pricing-card {
    padding: 14px 10px;
    margin-bottom: 10px;
  }

  /* Spacing optimization */
  li {
    margin-bottom: 4px;
    font-size: 13px;
  }

  .detail-card h3,
  .detail-card h4 {
    font-size: 14px;
    margin-bottom: 8px;
  }

  /* Ensure proper alignment for all data elements */
  .detail-card p,
  .pricing-card p,
  .package-card p {
    font-size: 12px;
  }

  /* Improve list alignment */
  ul,
  ol {
    padding-left: 18px;
    margin-bottom: 8px;
  }

  /* Navigation improvements */
  .nav-link {
    padding: 8px 10px;
  }

  /* Button row alignment */
  .button_wrap {
    gap: 8px;
  }

  /* Remove button sizing at 360px */
  button.remove-product,
  button.remove-item {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 8px;
    font-size: 12px;
  }

}

@media screen and (max-width: 480px) {
  [class*="col-"] {
    padding-left: 0;
    padding-right: 0;
  }

  .pricing-story {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media print {
  .loader-mask,
  #button {
    display: none !important;
  }
}
