/**
 * RR Academy - Mobile First Responsive CSS Fixes
 * Includes 360px and 480px breakpoints
 * Modern approach with clamp() for fluid typography
 */

:root {
    /* Fluid Typography */
    --font-size-h1-min: 24px;
    --font-size-h1-max: 60px;
    --font-size-h2-min: 20px;
    --font-size-h2-max: 46px;
    --font-size-h3-min: 18px;
    --font-size-h3-max: 32px;
    --font-size-body-min: 14px;
    --font-size-body-max: 16px;
}

/* ========================================
   ULTRA SMALL SCREENS (320px - 360px)
   ======================================== */
@media screen and (max-width: 360px) {
    * {
        /* Prevent horizontal overflow */
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }

    html {
        font-size: 14px;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 12px !important;
    }

    /* Typography - Very small screens */
    h1 {
        font-size: 22px !important;
        line-height: 26px !important;
        margin-bottom: 10px !important;
    }

    h2 {
        font-size: 18px !important;
        line-height: 22px !important;
        margin-bottom: 10px !important;
    }

    h3 {
        font-size: 16px !important;
        line-height: 20px !important;
    }

    h4, h5, h6 {
        font-size: 14px !important;
    }

    p {
        font-size: 13px !important;
        line-height: 1.5 !important;
    }

    /* Forms - Improved touch targets */
    input,
    textarea,
    select,
    button {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 48px !important; /* 44px minimum + padding */
        padding: 12px 10px !important;
        width: 100% !important;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-height: auto !important;
        padding: 0 !important;
        width: auto !important;
    }

    button {
        min-width: 44px;
        padding: 12px 16px !important;
    }

    /* Navigation */
    .navbar-toggler {
        width: 44px !important;
        height: 44px !important;
        padding: 6px 8px !important;
    }

    /* Remove horizontal overflow from negative positioning */
    .banner-con .banner_wrapper,
    .banner2-con .banner_wrapper,
    .about-con .about_wrapper,
    .contact-con {
        overflow: hidden !important;
    }

    /* Hide decorative elements that cause overflow */
    .banner-righttopimage,
    .banner-halfcircleimage,
    .banner-triangleimage,
    .popular-lefttopimage,
    .popular-crossimage,
    .popular-triangleimage,
    .about-rightimage,
    .contact-righttopimage,
    .contact-crossimage,
    .contact-triangleimage,
    .testimonial-leftimage,
    .footer-rightimage {
        display: none !important;
    }

    /* Images responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Cards and content */
    .card,
    .course-box,
    .pricing-card,
    .product-box {
        margin-bottom: 12px !important;
        padding: 12px !important;
    }

    /* Remove widths that cause overflow */
    .banner-con .banner_content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 12px !important;
    }

    .banner-con .banner_wrapper .banner-image1 img {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Tables */
    table {
        font-size: 12px !important;
    }

    /* Modal adjustments */
    .modal-dialog {
        width: 100% !important;
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }

    /* Lists */
    ul, ol {
        margin-left: 12px !important;
    }

    li {
        margin-bottom: 6px !important;
    }
}

/* ========================================
   SMALL SCREENS (361px - 480px)
   ======================================== */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 14px !important;
    }

    /* Typography - Small screens */
    h1 {
        font-size: 26px !important;
        line-height: 32px !important;
    }

    h2 {
        font-size: 22px !important;
        line-height: 28px !important;
    }

    h3 {
        font-size: 18px !important;
        line-height: 24px !important;
    }

    p {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }

    /* Forms */
    input,
    textarea,
    select {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: 12px 12px !important;
    }

    .form-row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px !important;
    }

    /* Buttons */
    .btn,
    button,
    input[type="button"],
    input[type="submit"] {
        width: 100% !important;
        padding: 14px 16px !important;
        min-height: 48px !important;
        font-size: 16px !important;
    }

    .btn-sm {
        width: auto !important;
        padding: 10px 14px !important;
    }

    /* Navigation */
    .navbar-nav {
        flex-direction: column !important;
    }

    .navbar-nav li {
        margin: 4px 0 !important;
    }

    /* Banner and hero sections */
    .banner-con {
        padding: 30px 0 0 !important;
    }

    .banner-con .banner_content {
        width: 100% !important;
    }

    /* Sections */
    .section-con,
    [class*="-con"] {
        padding: 30px 0 !important;
    }

    /* Cards */
    .card {
        margin-bottom: 14px !important;
        padding: 14px !important;
    }

    /* Course boxes */
    .course-box,
    .subject-card,
    .pricing-card {
        padding: 16px !important;
        margin-bottom: 14px !important;
    }

    /* Tabs */
    .nav-tabs {
        flex-wrap: wrap !important;
        gap: 4px !important;
    }

    .nav-tabs a {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    /* Grid columns */
    .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 8px !important;
    }

    .col-sm-6,
    .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Modals */
    .modal-dialog {
        max-width: 100% !important;
        margin: 10px !important;
    }

    .modal-header {
        padding: 12px !important;
    }

    .modal-body {
        padding: 12px !important;
    }

    /* Table responsiveness */
    table {
        font-size: 12px !important;
    }

    thead {
        display: none;
    }

    tr {
        display: block !important;
        margin-bottom: 12px !important;
        border: 1px solid #ddd !important;
        padding: 12px !important;
    }

    td {
        display: block !important;
        text-align: right !important;
        padding-left: 50% !important;
        position: relative;
    }

    td:before {
        content: attr(data-label) !important;
        position: absolute !important;
        left: 0 !important;
        width: 50% !important;
        padding-right: 10px !important;
        text-align: left !important;
        font-weight: bold !important;
    }
}

/* ========================================
   MEDIUM SMALL SCREENS (481px - 575px)
   ======================================== */
@media screen and (max-width: 575px) {
    .container {
        padding: 0 15px !important;
    }

    /* Two column layouts */
    .col-6 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
    }

    .col-sm-6 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
    }

    /* Sections */
    [class*="-con"] {
        padding: 40px 0 !important;
    }

    /* Banner */
    .banner-con {
        padding: 40px 0 0 !important;
    }

    /* Course boxes */
    .course-grid {
        gap: 12px !important;
    }

    .course-box {
        padding: 14px !important;
    }

    /* Forms */
    .form-group {
        margin-bottom: 14px !important;
    }

    /* Navigation */
    .navbar-brand img {
        max-width: 140px !important;
    }

    /* Testimonials */
    .testimonial-con .testimonial-item {
        padding: 20px !important;
    }

    /* Pricing */
    .pricing-grid {
        gap: 16px !important;
    }

    .pricing-card {
        padding: 18px !important;
    }
}

/* ========================================
   TABLET SMALL (576px - 767px)
   ======================================== */
@media screen and (min-width: 576px) and (max-width: 767px) {
    .container {
        padding: 0 16px !important;
    }

    /* Two columns */
    .col-sm-6 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
    }

    /* Forms */
    .form-row > .col-md-6 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
    }

    /* Sections */
    [class*="-con"] {
        padding: 60px 0 !important;
    }

    /* Course boxes */
    .course-box {
        padding: 16px !important;
    }

    /* Cards */
    .pricing-card,
    .subject-card {
        padding: 18px !important;
    }

    /* Typography */
    h1 {
        font-size: 32px !important;
    }

    h2 {
        font-size: 26px !important;
    }
}

/* ========================================
   TABLET (768px - 991px)
   ======================================== */
@media screen and (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 750px !important;
    }

    /* Three column layout */
    .col-md-4 {
        flex: 0 0 31% !important;
        max-width: 31% !important;
    }

    /* Form rows */
    .form-row > .col-md-6 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
    }

    .form-row > .col-md-4 {
        flex: 0 0 31% !important;
        max-width: 31% !important;
    }

    /* Sections */
    [class*="-con"] {
        padding: 80px 0 !important;
    }

    /* Course grid */
    .course-grid {
        gap: 18px !important;
    }

    .course-box {
        padding: 16px !important;
    }

    /* Typography */
    h1 {
        font-size: 40px !important;
    }

    h2 {
        font-size: 32px !important;
    }
}

/* ========================================
   DESKTOP IMPROVEMENTS (992px+)
   ======================================== */
@media screen and (min-width: 992px) {
    /* Better max-width constraint for very large screens */
    @media (min-width: 1600px) {
        .container {
            max-width: 1400px !important;
        }

        [class*="-con"] .container {
            max-width: 1400px !important;
        }
    }
}

/* ========================================
   FIXES FOR ALL SCREEN SIZES
   ======================================== */

/* Fix overflow issues */
body {
    overflow-x: hidden !important;
}

html,
body {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

picture {
    display: block;
    max-width: 100%;
}

/* Fix form fields */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
textarea,
select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix button widths in specific contexts */
.form-group button {
    max-width: 100%;
}

/* Ensure accessibility for touch devices */
button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* Fix video embeds */
iframe,
video {
    max-width: 100%;
}

/* Prevent text selection issues on mobile */
input,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Better focus states for mobile */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #1e40af;
    outline-offset: 2px;
}

/* Fix backgrround images on mobile */
[style*="background-image"] {
    background-attachment: scroll !important;
    background-size: cover !important;
    background-position: center !important;
}

/* Prevent zoom on input focus iOS */
@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 {
        font-size: 16px !important;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .no-print {
        display: none !important;
    }
}

/* ========================================
   CART PAGE MOBILE FIXES
   ======================================== */

/* Shopping cart responsive layout */
.shopping-cart {
    display: flex;
    flex-direction: column;
}

.column-labels {
    display: flex;
    gap: 10px;
    padding: 12px;
    background-color: #f5f5f5;
    font-weight: bold;
    font-size: 13px;
    flex-wrap: wrap;
    border-radius: 4px;
    margin-bottom: 12px;
}

.column-labels label {
    flex: 1;
    min-width: 60px;
    padding: 4px;
    margin: 0;
}

.product {
    display: flex;
    gap: 8px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: flex-start !important;
}

.product-image {
    min-width: 60px;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.product-details {
    flex: 1;
    min-width: 150px;
    padding-left: 8px;
}

.product-details .product-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.product-price,
.product-quantity,
.product-removal,
.product-line-price {
    flex: 0 0 auto;
    min-width: 60px;
    font-size: 13px;
    padding: 4px;
}

.product-quantity input {
    width: 50px;
    padding: 6px;
    font-size: 13px;
    min-height: auto;
}

.product-removal button {
    padding: 6px 10px;
    font-size: 12px;
    background-color: #ff6b6b;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.product-removal button:hover {
    background-color: #ff5252;
}

/* Mobile: Hide non-essential columns */
@media screen and (max-width: 768px) {
    .column-labels {
        display: none;
    }

    .product {
        flex-direction: column;
        gap: 12px;
    }

    .product-image {
        width: 100%;
        height: auto;
        min-height: 150px;
        display: flex;
        align-items: center;
    }

    .product-image img {
        width: 100%;
        height: auto;
    }

    .product-details {
        width: 100%;
        border-bottom: 1px solid #eee;
        padding: 8px 0;
    }

    .product-price,
    .product-quantity,
    .product-removal,
    .product-line-price {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
    }

    .product-price::before {
        content: "Price: ";
        font-weight: bold;
        margin-right: 8px;
    }

    .product-quantity::before {
        content: "Qty: ";
        font-weight: bold;
        margin-right: 8px;
    }

    .product-line-price::before {
        content: "Total: ";
        font-weight: bold;
        margin-right: 8px;
    }

    .product-removal::before {
        display: none;
    }

    .product-quantity input {
        width: 60px;
    }
}

/* Tablet view: Show essential columns */
@media screen and (min-width: 769px) and (max-width: 991px) {
    .column-labels label.product-image {
        display: none;
    }

    .product-image {
        display: none;
    }

    .product {
        gap: 10px;
    }

    .product-details {
        flex: 2;
    }

    .product-price,
    .product-quantity,
    .product-removal,
    .product-line-price {
        flex: 1;
        min-width: auto;
    }
}
