/* =============================================
   TANJIRUL STORE - Responsive Stylesheet
   ============================================= */

/* =============================================
   Extra Large Devices (Desktops)
   ============================================= */
@media (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .product-grid-6 .product-card .product-info {
        padding: var(--spacing-sm);
    }
    
    .product-grid-6 .product-title {
        font-size: var(--font-size-sm);
    }
}

/* =============================================
   Large Devices (Laptops)
   ============================================= */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-content {
        padding-right: var(--spacing-lg);
    }
    
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .product-grid-5 .product-card,
    .product-grid-6 .product-card {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    .sidebar {
        margin-bottom: var(--spacing-xl);
    }
    
    .dashboard-sidebar {
        margin-bottom: var(--spacing-lg);
    }
}

/* =============================================
   Medium Devices (Tablets Landscape)
   ============================================= */
@media (max-width: 991px) {
    .container {
        max-width: 720px;
    }
    
    /* Navigation */
    .navbar-expand-lg .navbar-toggler {
        display: block;
        border: none;
        background: transparent;
        padding: 0.5rem;
        z-index: 1060;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.75rem;
        font-size: 1.25rem;
        line-height: 1;
        background-color: transparent;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 0.25rem;
        position: relative;
        cursor: pointer;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
    
    .navbar-toggler .toggler-icon {
        display: block;
        height: 2px;
        width: 25px;
        background-color: #333;
        margin: 5px 0;
        position: relative;
        transition: all 0.3s ease;
    }
    
    .navbar-toggler[aria-expanded="true"] .toggler-icon:first-child {
        transform: rotate(45deg);
        top: 7px;
    }
    
    .navbar-toggler[aria-expanded="true"] .toggler-icon:nth-child(2) {
        opacity: 0;
    }
    
    .navbar-toggler[aria-expanded="true"] .toggler-icon:last-child {
        transform: rotate(-45deg);
        bottom: 7px;
    }
    
    .navbar-expand-lg .navbar-collapse {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #fff;
        z-index: 1050;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .navbar-expand-lg .navbar-collapse.show {
        display: block;
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .nav-item.dropdown .dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--light-gray);
        margin-top: var(--spacing-xs);
    }
    
    /* Header */
    .header-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-md);
    }
    
    .search-box {
        max-width: 100%;
        margin: var(--spacing-md) 0;
    }
    
    .header-icons {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-left: auto;
    }
    
    /* Hero Section */
    .hero-section {
        padding: var(--spacing-xl) 0;
        text-align: center;
    }
    
    .hero-content {
        padding-right: 0;
        margin-bottom: var(--spacing-xl);
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-buttons {
        justify-content: center;
    }
    
    .hero-image {
        display: none;
    }
    
    /* Categories */
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .category-card {
        padding: var(--spacing-md);
    }
    
    .category-icon {
        width: 60px;
        height: 60px;
        font-size: var(--font-size-xl);
    }
    
    /* Products */
    .product-grid-4 .product-card,
    .product-grid-5 .product-card,
    .product-grid-6 .product-card {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
    
    /* Sidebar */
    .shop-sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 300px;
        height: 100%;
        min-height: 100vh;
        background-color: var(--white);
        z-index: 1050;
        padding: var(--spacing-lg);
        box-shadow: var(--shadow-xl);
        transition: var(--transition-base);
    }
    
    .shop-sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .filter-toggle-btn {
        display: inline-flex;
    }
    
    /* Dashboard */
    .dashboard-layout {
        flex-direction: column;
    }
    
    /* Mobile sidebar - hidden by default, slides in when active */
    .dashboard-sidebar {
        position: fixed !important;
        top: 0;
        left: -260px !important;
        width: 260px;
        height: 100%;
        min-height: 100vh;
        background-color: #fff;
        z-index: 1050;
        padding: var(--spacing-lg);
        box-shadow: var(--shadow-xl);
        transition: left 0.3s ease-in-out;
        display: flex !important;
    }
    
    .dashboard-sidebar.show,
    .dashboard-sidebar.active {
        left: 0 !important;
    }
    
    /* Sidebar overlay for mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Bootstrap Offcanvas - Ensure proper z-index */
    .offcanvas {
        z-index: 1055 !important;
    }
    
    .offcanvas-backdrop {
        z-index: 1050 !important;
    }
    
    .offcanvas.show {
        transform: none;
    }
    
    /* Main content should not have margin on mobile when sidebar is active */
    .dashboard-main,
    .dashboard-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 15px;
    }
    
    /* Hide the sticky sidebar on mobile */
    .dashboard-wrapper .dashboard-sidebar,
    .dashboard-layout .dashboard-sidebar {
        position: fixed !important;
    }
    
    /* Ensure main content is not covered by sidebar */
    .dashboard-wrapper {
        position: relative;
        padding-left: 0;
    }
    
    /* When offcanvas is shown, prevent body scroll */
    body.offcanvas-open {
        overflow: hidden !important;
    }
    
/* Mobile and Tablet */
@media (max-width: 768px) {
    html, body {
        height: auto !important;
        min-height: -webkit-fill-available;
        overflow-y: auto !important;
        overflow-x: auto;
        position: relative !important;
    }
    
    body {
        overflow-y: auto !important;
        position: relative !important;
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    .dashboard-layout {
        flex-direction: column;
        min-height: auto;
        height: auto;
    }
    
    .dashboard-content {
        overflow: visible !important;
        height: auto !important;
        min-height: auto;
        width: 100%;
        margin-left: 0;
        padding: 15px;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
    
    .dashboard-main {
        overflow: visible !important;
        height: auto !important;
        min-height: auto;
    }
    
    .dashboard-wrapper {
        overflow-y: visible !important;
        height: auto;
        min-height: auto;
    }
    
    /* Horizontal scroll for Order History table on mobile */
    .dashboard-card .card-body .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
        width: calc(100% + 30px) !important;
    }
    
    .dashboard-card .card-body .table-responsive .table {
        min-width: 650px !important;
    }
    
    /* Force ALL containers to allow scroll */
    .dashboard-content,
    .dashboard-wrapper,
    .dashboard-main,
    body,
    html {
        overflow-x: auto !important;
        overflow-y: auto !important;
    }
    
    /* Ensure card body doesn't restrict overflow */
    .dashboard-card {
        overflow-x: visible !important;
        overflow-y: visible !important;
    }
    
    .card-body {
        overflow-x: visible !important;
        overflow-y: visible !important;
    }
    
    /* Chart and Table Spacing for Mobile */
    .chart-container {
        min-height: 280px !important;
        overflow: hidden;
    }
    
    .chart-placeholder {
        height: 200px !important;
        min-height: 200px !important;
        overflow: hidden;
    }
    
    /* Ensure table has proper margin-top after chart on mobile */
    .row:has(.chart-container) + .row:has(.table-card),
    .sales-chart-section + .recent-orders-section {
        margin-top: 20px !important;
    }
}

/* Tablet range 720px - 991px - Fix vertical scroll */
@media (min-width: 720px) and (max-width: 991px) {
    html, body {
        height: auto !important;
        min-height: 100%;
        overflow-y: auto !important;
        overflow-x: auto;
    }
    
    body {
        position: relative !important;
        overflow-y: auto !important;
        min-height: 100vh;
    }
    
    .dashboard-wrapper {
        min-height: auto;
        height: auto;
        overflow-y: visible !important;
        overflow-x: visible;
    }
    
    .dashboard-main,
    .dashboard-content {
        min-height: auto;
        height: auto;
        overflow-y: visible !important;
        overflow-x: visible;
    }
    
    /* Table horizontal scroll for this range too */
    .dashboard-card .card-body .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-card .card-body .table-responsive .table {
        min-width: 600px;
    }
    
    /* Chart and Table Spacing for Tablet */
    .chart-container {
        min-height: 320px !important;
        overflow: hidden;
    }
    
    .chart-placeholder {
        height: 240px !important;
        min-height: 240px !important;
        overflow: hidden;
    }
}

/* Very small devices (iPhone SE, older phones) - 320px to 480px */
@media (min-width: 320px) and (max-width: 480px) {
    html, body {
        height: auto !important;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto !important;
        overflow-x: auto;
    }
    
    body {
        position: relative !important;
        overflow-y: auto !important;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .dashboard-wrapper {
        min-height: auto;
        height: auto;
        min-height: 100dvh;
        overflow-y: visible !important;
        overflow-x: visible;
    }
    
    .dashboard-main,
    .dashboard-content {
        min-height: auto;
        height: auto;
        overflow-y: visible !important;
        overflow-x: visible;
    }
    
    .dashboard-header {
        position: relative !important;
    }
    
    /* Table scroll */
    .dashboard-card .card-body .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-card .card-body .table-responsive .table {
        min-width: 550px;
    }
    
    /* Chart and Table Spacing for Small Tablet */
    .chart-container {
        min-height: 300px !important;
        overflow: hidden;
    }
    
    .chart-placeholder {
        height: 220px !important;
        min-height: 220px !important;
        overflow: hidden;
    }
}

/* =============================================
   Large Screens (Desktops and Large Tablets) - 992px and above
   Fix for vertical scroll not reaching full content
   ============================================= */
@media (min-width: 992px) {
    html, body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    body {
        position: relative;
    }
    
    .dashboard-wrapper {
        display: flex;
        min-height: 100vh;
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .dashboard-main,
    .dashboard-content {
        flex: 1;
        min-height: calc(100vh - var(--header-height, 70px));
        height: auto;
        overflow-y: visible;
        overflow-x: hidden;
    }
    
    .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .dashboard-body {
        min-height: auto;
        height: auto;
        overflow-y: visible;
    }
    
    .dashboard-footer {
        position: relative;
        margin-top: auto;
    }
    
    /* Chart and Table Spacing for Desktop */
    .chart-container {
        min-height: 350px !important;
        overflow: hidden;
    }
    
    .chart-placeholder {
        height: 280px !important;
        min-height: 280px !important;
        overflow: hidden;
    }
}

/* 720px width devices - Specific fix */
@media only screen and (max-width: 720px) {
    html, body {
        height: auto !important;
        min-height: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        overflow-y: auto !important;
        overflow-x: auto;
    }
    
    body {
        position: relative !important;
        overflow-y: auto !important;
        overflow-x: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .dashboard-wrapper {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        height: auto !important;
        height: auto;
        overflow-y: visible !important;
        overflow-x: visible !important;
    }
    
    .dashboard-main,
    .dashboard-content {
        width: 100% !important;
        flex: none;
        min-height: auto;
        height: auto;
        margin-left: 0 !important;
        overflow-y: visible !important;
        overflow-x: visible !important;
    }
    
    .dashboard-header {
        position: relative !important;
        width: 100%;
        height: auto !important;
        min-height: 60px;
    }
    
    /* Card overflow fixes */
    .dashboard-card {
        overflow-y: visible !important;
        overflow-x: visible !important;
    }
    
    .card-body {
        overflow-y: visible !important;
        overflow-x: visible !important;
    }
    
    /* Table scroll */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px !important;
    }
    
    /* Make sure navbar is not fixed */
    .navbar, .navbar-area, .navbar-expand-lg {
        position: relative !important;
    }
}
    
    .dashboard-sidebar {
        left: -260px;
    }
    
    .dashboard-sidebar.show {
        left: 0;
    }
    
    .dashboard-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Footer */
    .footer-widget {
        margin-bottom: var(--spacing-lg);
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =============================================
   Small Devices (Tablets Portrait)
   ============================================= */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
    }
    
    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    
    /* Section Padding */
    .section-padding {
        padding: var(--spacing-xl) 0;
    }
    
    /* Hero */
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: var(--font-size-base);
    }
    
    /* Categories */
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    /* Products */
    .product-grid-3 .product-card,
    .product-grid-4 .product-card,
    .product-grid-5 .product-card,
    .product-grid-6 .product-card {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .product-actions {
        opacity: 1;
        transform: translateX(0);
    }
    
    /* Flash Sale */
    .flash-sale-header {
        flex-direction: column;
        text-align: center;
    }
    
    .countdown-timer {
        gap: var(--spacing-sm);
    }
    
    .countdown-item {
        min-width: 60px;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .countdown-value {
        font-size: var(--font-size-lg);
    }
    
    /* Newsletter */
    .newsletter-form {
        flex-direction: column;
    }
    
    /* Breadcrumb */
    .page-header {
        padding: var(--spacing-lg) 0;
    }
    
    .page-title {
        font-size: var(--font-size-xl);
    }
    
    /* Forms */
    .form-row {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    /* Buttons */
    .btn {
        width: 100%;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        border-radius: var(--radius-md);
    }
    
    /* Tables */
    .table-responsive {
        font-size: var(--font-size-sm);
    }
    
    .table thead th,
    .table tbody td {
        padding: var(--spacing-sm);
    }
    
    /* Cards */
    .card {
        margin-bottom: var(--spacing-md);
    }
    
    .card-header {
        padding: var(--spacing-md);
    }
    
    .card-body {
        padding: var(--spacing-md);
    }
    
    /* Cart */
    .cart-summary {
        margin-top: var(--spacing-lg);
    }
    
    /* Checkout */
    .checkout-steps {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .checkout-step {
        width: 100%;
        text-align: center;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
    
    /* Scroll to Top */
    .scroll-to-top {
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
        width: 40px;
        height: 40px;
    }
}

/* =============================================
   Extra Small Devices (Mobile)
   ============================================= */
@media (max-width: 575px) {
    .container {
        max-width: 100%;
        padding: 0 var(--spacing-sm);
    }
    
    /* Base */
    body {
        font-size: var(--font-size-sm);
    }
    
    /* Typography */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: var(--font-size-lg); }
    h5 { font-size: var(--font-size-base); }
    h6 { font-size: var(--font-size-sm); }
    
    /* Spacing */
    .section-padding {
        padding: var(--spacing-lg) 0;
    }
    
    .section-title {
        margin-bottom: var(--spacing-lg);
    }
    
    /* Header */
    .navbar-brand {
        font-size: var(--font-size-lg);
    }
    
    .navbar-brand img {
        height: 30px;
    }
    
    .header-icon {
        font-size: var(--font-size-base);
    }
    
    /* Hero */
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-buttons .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-sm);
    }
    
    /* Categories */
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .category-card {
        padding: var(--spacing-sm);
    }
    
    .category-icon {
        width: 50px;
        height: 50px;
        font-size: var(--font-size-lg);
    }
    
    .category-name {
        font-size: var(--font-size-sm);
    }
    
    /* Products */
    .product-grid-2 .product-card,
    .product-grid-3 .product-card,
    .product-grid-4 .product-card,
    .product-grid-5 .product-card,
    .product-grid-6 .product-card {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .product-info {
        padding: var(--spacing-sm);
    }
    
    .product-title {
        font-size: var(--font-size-base);
    }
    
    .product-price {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
    
    .product-buttons {
        flex-direction: column;
    }
    
    /* Flash Sale */
    .flash-sale-title h3 {
        font-size: var(--font-size-lg);
    }
    
    .countdown-item {
        min-width: 50px;
    }
    
    .countdown-value {
        font-size: var(--font-size-base);
    }
    
    .countdown-label {
        font-size: 10px;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: var(--spacing-md);
    }
    
    .form-label {
        font-size: var(--font-size-sm);
    }
    
    .form-control {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    /* Buttons */
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-sm);
    }
    
    .btn-sm {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-xs);
    }
    
    .btn-lg {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    /* Badges */
    .badge {
        padding: 2px 6px;
        font-size: 10px;
    }
    
    /* Pagination */
    .pagination {
        gap: 2px;
    }
    
    .page-link {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    /* Modal */
    .modal-dialog {
        margin: var(--spacing-sm);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--spacing-md);
    }
    
    /* Toast */
    .toast-container {
        top: var(--spacing-md);
        right: var(--spacing-md);
        left: var(--spacing-md);
    }
    
    .toast {
        min-width: auto;
    }
    
    /* Card */
    .card {
        border-radius: var(--radius-md);
    }
    
    /* Dashboard */
    .dashboard-stat-card {
        padding: var(--spacing-md);
    }
    
    .stat-value {
        font-size: var(--font-size-xl);
    }
    
    /* Table */
    .table {
        font-size: var(--font-size-xs);
    }
    
    .table thead th,
    .table tbody td {
        padding: var(--spacing-xs);
    }
    
    /* Footer */
    .footer {
        padding: var(--spacing-xl) 0 var(--spacing-md);
    }
    
    .footer-title {
        font-size: var(--font-size-base);
    }
    
    .footer-links a {
        font-size: var(--font-size-sm);
    }
    
    /* Search */
    .search-box input {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    .search-box button {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
    .navbar,
    .footer,
    .sidebar,
    .btn,
    .action-btn,
    .scroll-to-top,
    .breadcrumb,
    .pagination {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .container {
        max-width: 100%;
    }
    
    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
    
    .table {
        border: 1px solid #ddd;
    }
    
    .table thead th,
    .table tbody td {
        border: 1px solid #ddd;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* =============================================
   Landscape Orientation
   ============================================= */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        padding: var(--spacing-lg) 0;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-image img {
        max-height: 200px;
    }
    
    .modal-dialog {
        max-width: 90%;
    }
}

/* =============================================
   High Resolution / Retina
   ============================================= */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image img,
    .hero-image img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* =============================================
   Reduced Motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
