/**
 * Enhanced Responsive Design Improvements
 * Mobile-first responsive styles
 */

/* ============================================
   Tablet & Mobile Improvements
   ============================================ */

/* Tablet (768px - 991px) */
@media (max-width: 991px) {
    .container {
        padding: 0 20px;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px !important;
    }

    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }

    /* Hero banners - stack vertically */
    .hero-banners {
        flex-direction: column;
        gap: 15px;
    }

    /* Product detail page */
    .product-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    /* Stats grid */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Large (576px - 767px) */
@media (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .product-card {
        border-radius: 8px;
    }

    .product-img-wrapper {
        height: 180px;
    }

    .product-title {
        font-size: 0.875rem;
        line-height: 1.4;
        margin-bottom: 8px;
        height: 2.6em;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .product-category {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }

    .product-rating {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }

    .product-price {
        margin-bottom: 10px;
    }

    .new-price {
        font-size: 1rem;
        font-weight: 600;
    }

    .old-price {
        font-size: 0.8rem;
    }

    .product-footer {
        flex-direction: column;
        gap: 8px;
    }

    .btn-add-cart,
    .btn-buy-now {
        width: 100%;
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    /* Section headers */
    .section-header {
        margin-bottom: 20px;
    }

    .section-title {
        font-size: 1.25rem;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
    }

    /* Checkout */
    .checkout-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tables - make scrollable */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    /* Admin dashboard */
    .admin-wrapper {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        position: relative;
    }

    .admin-content {
        width: 100%;
    }
}

/* Mobile Small (max-width: 575px) */
@media (max-width: 575px) {
    /* Typography */
    html {
        font-size: 14px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Container */
    .container {
        padding: 0 15px;
    }

    /* Products - 2 columns */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .product-card {
        padding: 0;
    }

    .product-img-wrapper {
        height: 150px;
    }

    .product-content {
        padding: 12px 10px;
    }

    .product-title {
        font-size: 0.8125rem;
        height: 2.4em;
        margin-bottom: 6px;
    }

    .product-price {
        margin-bottom: 8px;
    }

    .new-price {
        font-size: 0.9375rem;
    }

    .old-price {
        font-size: 0.75rem;
    }

    .product-footer {
        gap: 6px;
    }

    .btn-add-cart,
    .btn-buy-now {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    /* Header */
    .header-main {
        padding: 10px 0;
    }

    .logo {
        font-size: 1.125rem;
    }

    .header-actions {
        gap: 6px;
    }

    .header-action {
        padding: 6px;
        font-size: 1rem;
    }

    .header-action span {
        display: none;
    }

    .badge {
        font-size: 0.625rem;
        padding: 2px 5px;
        min-width: 16px;
        height: 16px;
    }

    /* Search bar */
    .search-bar {
        margin-top: 10px;
    }

    .search-input {
        font-size: 0.875rem;
        padding: 10px;
    }

    .search-btn {
        padding: 10px 15px;
        font-size: 0.875rem;
    }

    /* Navigation */
    .main-nav {
        max-height: 70vh;
        overflow-y: auto;
    }

    .nav-link {
        padding: 12px 15px;
        font-size: 0.9375rem;
    }

    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    /* Section spacing */
    section {
        padding: 25px 0;
    }

    .section-header {
        margin-bottom: 15px;
    }

    .section-title {
        font-size: 1.125rem;
    }

    /* Buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }

    /* Forms */
    .form-control {
        padding: 12px;
        font-size: 0.9375rem;
    }

    .form-label {
        font-size: 0.875rem;
        margin-bottom: 6px;
    }

    /* Cards */
    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 15px;
    }

    .card-header {
        padding: 15px;
    }

    /* Slider */
    .slider-container {
        min-height: 200px;
    }

    .slide-content {
        padding: 15px;
    }

    .slide-content h2 {
        font-size: 1.25rem;
        margin-bottom: 8px;
    }

    .slide-content p {
        font-size: 0.875rem;
        margin-bottom: 12px;
    }

    .slide-content .btn {
        padding: 10px 20px;
        font-size: 0.875rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-widget {
        margin-bottom: 25px;
    }

    .footer-widget h4 {
        font-size: 1.125rem;
        margin-bottom: 15px;
    }

    .footer-links {
        font-size: 0.875rem;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding-top: 20px;
    }

    /* Product detail page */
    .product-image img {
        border-radius: 8px;
    }

    .product-info h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .price-box {
        margin-bottom: 20px;
    }

    .price-current {
        font-size: 1.75rem;
    }

    .actions {
        flex-direction: column;
        gap: 12px;
    }

    .actions button,
    .actions form button {
        width: 100%;
        padding: 14px;
        font-size: 1rem;
    }

    /* Cart page */
    .cart-item {
        flex-direction: column;
        gap: 15px;
    }

    .cart-item-img {
        width: 100%;
        max-width: 150px;
        margin: 0 auto;
    }

    .cart-item-info {
        text-align: center;
    }

    .cart-item-actions {
        justify-content: center;
    }

    /* Checkout */
    .checkout-summary {
        order: -1;
        margin-bottom: 30px;
    }

    .checkout-grid {
        grid-template-columns: 1fr !important;
        gap: 25px;
    }

    /* Admin */
    .admin-sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .admin-sidebar.active {
        left: 0;
    }

    .admin-content {
        width: 100%;
        margin-left: 0;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    /* Hide some elements on mobile */
    .d-mobile-none {
        display: none !important;
    }

    /* Show some elements only on mobile */
    .d-mobile-block {
        display: block !important;
    }

    .d-mobile-flex {
        display: flex !important;
    }

    /* Feature bar - stack items */
    .feature-bar .row {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .feature-item {
        font-size: 0.875rem;
    }

    /* Hero banners - stack vertically */
    .hero-banners {
        flex-direction: column;
        gap: 10px;
    }

    .promo-banner {
        padding: 15px;
        text-align: center;
    }

    .promo-banner h4 {
        font-size: 1rem;
        margin: 8px 0 5px;
    }

    .promo-banner p {
        font-size: 0.875rem;
    }

    /* Feature bar responsive */
    .feature-bar {
        padding: 20px 0;
    }

    .feature-item {
        padding: 10px;
        font-size: 0.8125rem;
    }
}

/* ============================================
   Additional responsive fixes
   ============================================ */

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Product actions on mobile */
@media (max-width: 767px) {
    .product-actions {
        opacity: 1;
        visibility: visible;
        position: static;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        padding: 8px;
        background: rgba(255, 255, 255, 0.95);
    }

    .action-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        font-size: 0.875rem;
    }
}

/* Better table responsiveness */
@media (max-width: 767px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border-light);
        border-radius: var(--radius-md);
    }

    .data-table {
        width: 100%;
        border-collapse: collapse;
        margin: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border-light);
        margin-bottom: 15px;
        border-radius: var(--radius-md);
        padding: 15px;
    }

    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border: none;
        text-align: right;
    }

    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 15px;
    }
}

/* ============================================
   Touch-friendly improvements
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap target sizes for better touch interaction */
    .btn,
    .nav-link,
    .header-action,
    .action-btn,
    .btn-add-cart,
    .btn-buy-now {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }

    /* Better touch feedback */
    .btn:active,
    .nav-link:active,
    .header-action:active,
    .action-btn:active {
        opacity: 0.7;
        transform: scale(0.98);
    }

    /* Product card interactions */
    .product-card:active {
        transform: scale(0.98);
    }
}

/* Prevent text selection on buttons and links */
.btn,
.nav-link,
.header-action,
.mobile-menu-toggle {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================
   Landscape mobile improvements
   ============================================ */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-section {
        padding: 20px 0;
    }

    .slider-container {
        min-height: 180px;
    }

    .main-nav {
        max-height: 60vh;
    }
}

/* ============================================
   Print styles
   ============================================ */
@media print {
    .header,
    .footer,
    .btn,
    .mobile-menu-toggle,
    .header-actions,
    .product-actions {
        display: none !important;
    }

    .container {
        max-width: 100%;
    }

    .product-card {
        break-inside: avoid;
    }
}

