/* ========================================
   GLOBAL MOBILE RESPONSIVE STYLES
   Applied to all pages across the website
   ======================================== */

/* Base Mobile Optimization */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

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

body {
    overflow-x: hidden;
    width: 100%;
    -webkit-text-size-adjust: 100%;
}

/* Images & Media */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Container Responsiveness */
.container, .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Tables */
table {
    width: 100%;
    overflow-x: auto;
    display: block;
}

/* Forms */
input, textarea, select, button {
    max-width: 100%;
    font-size: 16px; /* Prevents iOS zoom */
}

/* ========================================
   TABLET & MOBILE BREAKPOINTS
   ======================================== */

/* Large Tablets & Small Desktops (992px - 1199px) */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    h1 { font-size: 2.25rem; }
    h2 { font-size: 1.875rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
}

/* Tablets (768px - 991px) */
@media (max-width: 991px) {
    .container {
        max-width: 720px;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.375rem; }
    
    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }
    
    /* Grid adjustments */
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }
    
    .col, [class*="col-"] {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Large Phones (576px - 767px) */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.125rem !important; }
    h5 { font-size: 1rem !important; }
    
    p, li, span {
        font-size: 0.95rem !important;
    }
    
    /* Buttons */
    .btn, button {
        padding: 10px 20px !important;
        font-size: 0.9rem !important;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    /* Spacing */
    .mb-4, .my-4 { margin-bottom: 1.5rem !important; }
    .mt-4, .my-4 { margin-top: 1.5rem !important; }
    .p-4 { padding: 1.5rem !important; }
    
    /* Grid - Stack columns */
    [class*="col-"] {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Small Phones (up to 575px) */
@media (max-width: 575px) {
    .container {
        max-width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.35rem !important; }
    h3 { font-size: 1.2rem !important; }
    h4 { font-size: 1.05rem !important; }
    
    p, li, span {
        font-size: 0.9rem !important;
        line-height: 1.5;
    }
    
    /* Buttons */
    .btn, button {
        padding: 8px 15px !important;
        font-size: 0.85rem !important;
    }
    
    /* Cards */
    .card-body {
        padding: 12px !important;
    }
    
    /* Modal */
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-content {
        border-radius: 10px;
    }
}

/* ========================================
   SPECIFIC COMPONENT RESPONSIVENESS
   ======================================== */

/* Navigation */
@media (max-width: 991px) {
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .nav-item {
        text-align: center;
        margin: 5px 0;
    }
    
    .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin: 0;
        border: none;
        box-shadow: none;
    }
}

/* Hero Sections */
@media (max-width: 768px) {
    .hero, .banner, [class*="hero"] {
        padding: 40px 15px !important;
        min-height: auto !important;
    }
    
    .hero h1, .banner h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }
    
    .hero p, .banner p {
        font-size: 1rem !important;
    }
}

/* Product Cards & Grids */
@media (max-width: 991px) {
    .product-grid,
    [style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}

@media (max-width: 575px) {
    .product-grid,
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .product-card {
        margin-bottom: 15px;
    }
}

/* Forms */
@media (max-width: 768px) {
    form {
        padding: 15px !important;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        width: 100% !important;
        padding: 10px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    label {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
}

/* Tables */
@media (max-width: 768px) {
    table {
        font-size: 0.85rem;
    }
    
    table thead {
        display: none;
    }
    
    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }
    
    table tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
    }
    
    table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
        padding-top: 8px;
        padding-bottom: 8px;
    }
    
    table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: bold;
        text-align: left;
    }
}

/* Cart & Checkout */
@media (max-width: 768px) {
    .cart-item,
    .cart-summary,
    .checkout-form {
        padding: 15px !important;
    }
    
    .cart-item {
        grid-template-columns: 80px 1fr !important;
        gap: 12px !important;
    }
    
    .item-actions {
        grid-column: 1 / -1;
        text-align: center;
        margin-top: 10px;
    }
    
    .cart-summary {
        position: static !important;
        margin-top: 20px;
    }
    
    .quantity-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .quantity-btn {
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }
}

/* Article & Content Pages */
@media (max-width: 768px) {
    article, .article-content, .post-content {
        padding: 15px !important;
    }
    
    .article-image, .featured-image {
        height: auto !important;
        max-height: 250px !important;
    }
    
    .article-meta, .post-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .share-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Dashboard & Profile */
@media (max-width: 768px) {
    .dashboard-grid,
    .profile-grid {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar {
        position: static !important;
        width: 100% !important;
        margin-bottom: 20px;
    }
    
    .stat-card {
        min-height: auto !important;
    }
}

/* Footer */
@media (max-width: 768px) {
    footer {
        padding: 30px 15px !important;
        text-align: center;
    }
    
    .footer-grid,
    .footer-columns {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .footer-column {
        margin-bottom: 20px;
    }
}

/* Modals & Popups */
@media (max-width: 576px) {
    .modal-dialog {
        max-width: 95%;
        margin: 10px auto;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 10px 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* Notifications & Alerts */
@media (max-width: 768px) {
    .alert, .notification {
        margin: 10px;
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .toast {
        max-width: 90% !important;
        right: 5% !important;
    }
}

/* Video & Embedded Content */
@media (max-width: 768px) {
    iframe[src*="youtube"],
    iframe[src*="vimeo"],
    .video-container {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9;
    }
}

/* Badges & Pills */
@media (max-width: 576px) {
    .badge, .pill {
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
    }
}

/* Breadcrumbs */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }
    
    .breadcrumb-item {
        margin-bottom: 5px;
    }
}

/* Pagination */
@media (max-width: 576px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* Price Display */
@media (max-width: 576px) {
    .price {
        font-size: 1.5rem !important;
    }
    
    .price-compare {
        font-size: 1rem !important;
    }
}

/* Filters & Search */
@media (max-width: 768px) {
    .filter-section,
    .search-filters {
        position: static !important;
        width: 100% !important;
        margin-bottom: 20px;
    }
    
    .filter-btn,
    .search-btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Show/Hide on Mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

/* Text Alignment */
@media (max-width: 768px) {
    .text-md-center {
        text-align: center !important;
    }
    
    .text-md-left {
        text-align: left !important;
    }
    
    .text-md-right {
        text-align: right !important;
    }
}

/* Spacing Utilities */
@media (max-width: 768px) {
    .p-md-2 { padding: 0.5rem !important; }
    .p-md-3 { padding: 1rem !important; }
    .m-md-2 { margin: 0.5rem !important; }
    .m-md-3 { margin: 1rem !important; }
}

/* Width Utilities */
@media (max-width: 768px) {
    .w-md-100 {
        width: 100% !important;
    }
    
    .w-md-auto {
        width: auto !important;
    }
}

/* Flex Utilities */
@media (max-width: 768px) {
    .flex-md-column {
        flex-direction: column !important;
    }
    
    .flex-md-wrap {
        flex-wrap: wrap !important;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Touch-friendly Links & Buttons */
a, button, .btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    a, button, .btn {
        padding: 10px 15px;
    }
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   FIX COMMON ISSUES
   ======================================== */

/* Fix Horizontal Scroll */
@media (max-width: 768px) {
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    [class*="col-"] {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Fix Overlapping Elements */
@media (max-width: 768px) {
    * {
        max-width: 100%;
    }
    
    pre, code {
        white-space: pre-wrap;
        word-wrap: break-word;
    }
}

/* Fix Fixed Elements on Mobile */
@media (max-width: 768px) {
    .fixed-top {
        position: sticky;
    }
    
    .fixed-bottom {
        position: sticky;
    }
}

/* Print Styles */
@media print {
    .no-print,
    nav,
    footer,
    .sidebar,
    .modal,
    .notification {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
}
