/**
 * Storefront Responsive Utilities
 * Mobile-first responsive design for public website
 */

/* ===== RESPONSIVE NAVBAR ===== */
@media (max-width: 991.98px) {
    .sf-navbar {
        padding: 0.5rem 1rem !important;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .nav-link {
        font-size: 0.95rem;
        padding: 0.5rem 0 !important;
    }

    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
    }

    .navbar-toggler:focus {
        box-shadow: none;
        outline: 2px solid var(--sf-primary);
    }
}

/* ===== RESPONSIVE HERO/BANNER ===== */
@media (max-width: 767.98px) {
    .hero-banner {
        padding: 2rem 1rem !important;
        min-height: auto !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
    }

    .hero-subtitle {
        font-size: 1rem !important;
    }

    .banner-content {
        text-align: center;
    }
}

/* ===== RESPONSIVE BREADCRUMBS ===== */
@media (max-width: 575.98px) {
    .breadcrumbs {
        font-size: 0.875rem;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .breadcrumb-item {
        display: none;
    }

    .breadcrumb-item:last-child {
        display: inline;
    }
}

/* ===== RESPONSIVE PRODUCT GRID ===== */
@media (max-width: 991.98px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 575.98px) {
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .product-card {
        margin-bottom: 0 !important;
    }
}

/* ===== PRODUCT DETAIL PAGE ===== */
@media (max-width: 767.98px) {
    .product-detail {
        flex-direction: column;
    }

    .product-gallery {
        width: 100% !important;
        margin-bottom: 2rem;
    }

    .product-info {
        width: 100% !important;
    }

    .product-image-main {
        height: 300px;
    }

    .product-thumbnails {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== RESPONSIVE SEARCH/FILTER ===== */
@media (max-width: 767.98px) {
    .search-filter-form {
        flex-direction: column;
        gap: 0.75rem !important;
    }

    .search-filter-form .col-md-9,
    .search-filter-form .col-md-3,
    .search-filter-form input,
    .search-filter-form button {
        width: 100% !important;
    }

    .search-filter-form .btn {
        padding: 0.5rem 1rem !important;
    }

    .sidebar-categories {
        position: static !important;
        width: 100% !important;
        top: auto !important;
        margin-bottom: 2rem;
    }

    .sf-card.sticky-top {
        position: relative !important;
        top: 0 !important;
    }
}

/* ===== CART PAGE ===== */
@media (max-width: 991.98px) {
    .cart-layout {
        flex-direction: column;
    }

    .cart-items {
        width: 100% !important;
        margin-bottom: 2rem;
    }

    .cart-summary {
        width: 100% !important;
    }
}

@media (max-width: 767.98px) {
    .table-responsive {
        font-size: 0.875rem;
    }

    .cart-table th,
    .cart-table td {
        padding: 0.5rem !important;
    }

    /* Cart table to card on mobile */
    .cart-table-mobile {
        display: none;
    }

    .cart-card-mobile {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .cart-item-card {
        background: var(--sf-card);
        border: 1px solid var(--sf-border);
        border-radius: var(--sf-radius);
        padding: 1rem;
        box-shadow: var(--sf-shadow);
    }

    .cart-item-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
    }

    .cart-item-row label {
        font-weight: 600;
        color: var(--sf-muted);
        font-size: 0.875rem;
    }

    .cart-item-value {
        font-weight: 500;
    }

    .quantity-input {
        max-width: 80px !important;
    }

    .cart-item-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .cart-item-actions .btn {
        flex: 1;
        padding: 0.375rem 0.5rem !important;
        font-size: 0.8rem;
    }
}

/* ===== CHECKOUT PAGE ===== */
@media (max-width: 991.98px) {
    .checkout-layout {
        flex-direction: column;
    }

    .checkout-form {
        width: 100% !important;
        margin-bottom: 2rem;
    }

    .checkout-summary {
        width: 100% !important;
        position: static !important;
    }

    .checkout-summary.sticky-top {
        position: relative !important;
        top: 0 !important;
    }
}

@media (max-width: 767.98px) {
    .checkout-section {
        margin-bottom: 1.5rem;
    }

    .checkout-section-title {
        font-size: 1.125rem;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid var(--sf-primary);
    }

    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    .form-row > [class*="col"] {
        width: 100%;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .order-summary-line {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--sf-border);
    }

    .order-summary-total {
        font-size: 1.25rem;
        font-weight: 700;
        padding: 1rem 0;
    }

    .btn-checkout {
        width: 100% !important;
        padding: 0.75rem !important;
        font-size: 1rem !important;
    }
}

/* ===== FOOTER ===== */
@media (max-width: 767.98px) {
    .footer-columns {
        flex-direction: column;
        gap: 2rem !important;
    }

    .footer-column {
        width: 100% !important;
    }

    .footer-title {
        font-size: 1rem;
    }

    .footer-link {
        font-size: 0.875rem;
    }
}

/* ===== RESPONSIVE CARDS ===== */
@media (max-width: 767.98px) {
    .sf-card {
        border-radius: calc(var(--sf-radius) - 4px);
        margin-bottom: 1rem;
    }

    .sf-card p {
        margin-bottom: 0.75rem;
    }
}

/* ===== RESPONSIVE BUTTONS ===== */
@media (max-width: 575.98px) {
    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.95rem;
    }

    .btn-full-mobile {
        width: 100%;
        display: block;
    }

    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }
}

/* ===== RESPONSIVE FORMS ===== */
@media (max-width: 767.98px) {
    .form-group {
        margin-bottom: 1rem;
    }

    .form-label {
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    .form-control,
    .form-select {
        padding: 0.6rem 0.75rem;
    }

    .form-text {
        font-size: 0.8rem;
    }

    .form-check {
        margin-bottom: 0.75rem;
    }

    /* Ensure inputs don't cause zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

    /* Custom select arrow on mobile */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.75rem center;
        background-size: 12px;
        padding-right: 2rem;
    }
}

/* ===== RESPONSIVE PRICING/PRODUCT DETAILS ===== */
@media (max-width: 575.98px) {
    .price-display {
        font-size: 1.75rem;
    }

    .price-original {
        font-size: 1rem;
    }

    .price-discount {
        font-size: 0.95rem;
    }
}

/* ===== RESPONSIVE CONTACT FORM ===== */
@media (max-width: 767.98px) {
    .contact-form {
        padding: 1.5rem 1rem !important;
    }

    .contact-info {
        flex-direction: column;
        gap: 1.5rem !important;
    }

    .contact-info-item {
        width: 100% !important;
    }
}

/* ===== RESPONSIVE BADGES ===== */
@media (max-width: 575.98px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    .badge-lg {
        font-size: 0.875rem;
        padding: 0.35rem 0.6rem;
    }
}

/* ===== RESPONSIVE ALERTS ===== */
@media (max-width: 575.98px) {
    .alert {
        padding: 0.75rem;
        margin-bottom: 1rem;
        font-size: 0.875rem;
    }

    .alert-heading {
        font-size: 1rem;
    }
}

/* ===== RESPONSIVE MODALS ===== */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: none !important;
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 80px;
    }
}

/* ===== SPACING UTILITIES ===== */
@media (max-width: 767.98px) {
    .px-md-0 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .mx-md-0 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ===== DISPLAY UTILITIES ===== */
.d-none-mobile {
    display: block;
}

@media (max-width: 575.98px) {
    .d-none-mobile {
        display: none !important;
    }

    .d-block-mobile {
        display: block !important;
    }

    .d-flex-mobile {
        display: flex !important;
    }
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */
@media (max-width: 575.98px) {
    body {
        font-size: 14px;
    }

    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    h3, .h3 {
        font-size: 1.25rem;
    }

    h4, .h4,
    h5, .h5 {
        font-size: 1.1rem;
    }

    h6, .h6 {
        font-size: 1rem;
    }

    .small {
        font-size: 0.8rem;
    }
}

/* ===== GRID UTILITIES ===== */
@media (max-width: 767.98px) {
    [class*="col-"] {
        margin-bottom: 1rem;
    }
}

/* ===== UTILITY: FULL HEIGHT ON MOBILE ===== */
@media (max-width: 767.98px) {
    .mh-mobile-full {
        min-height: auto !important;
        max-height: none !important;
    }
}

/* ===== UTILITY: STICKY BOTTOM MOBILE ===== */
@media (max-width: 767.98px) {
    .sticky-bottom-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--sf-card);
        border-top: 1px solid var(--sf-border);
        padding: 1rem;
        z-index: 100;
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.08);
    }

    body.has-sticky-actions {
        padding-bottom: 90px;
    }

    .sticky-bottom-mobile .btn {
        width: 100%;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .sf-navbar,
    .search-bar,
    .btn-cart,
    .btn-account,
    .footer,
    .modal {
        display: none !important;
    }

    .product-image-main {
        max-width: 200px;
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-banner {
        padding: 1rem !important;
        min-height: auto !important;
    }

    .navbar {
        padding: 0.5rem 1rem !important;
    }
}
