/* Mobile-First Responsive Design */
/* Base styles for mobile (320px+) */
@media screen and (max-width: 768px) {
    /* Global mobile adjustments */
    body {
        padding: 0;
        margin: 0;
        font-size: 14px;
        line-height: 1.4;
    }

    .container {
        max-width: 100%;
        padding: 10px;
        margin: 0;
    }

    /* Header improvements */
    .header {
        padding: 10px 0;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .header-content {
        padding: 0 15px;
        flex-direction: column;
        gap: 10px;
    }

    .header-title {
        font-size: 18px;
        text-align: center;
    }

    .nav-links {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        padding: 6px 10px;
        font-size: 12px;
        margin: 0;
    }

    /* Shop page mobile optimizations */
    .shop-header {
        padding: 15px;
        text-align: center;
    }

    .shop-title {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .shop-subtitle {
        font-size: 13px;
    }

    /* Categories */
    .categories-section {
        margin-bottom: 15px;
    }

    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 10px;
        padding: 0 15px;
    }

    .category-item {
        padding: 8px;
        min-height: auto;
    }

    .category-icon {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .category-name {
        font-size: 11px;
    }

    /* Product list */
    .products-section {
        padding: 0;
    }

    .section-title {
        font-size: 16px;
        padding: 10px 15px;
        margin: 0;
    }

    .products-list {
        padding: 0;
    }

    .product-item {
        padding: 12px 15px;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid #eee;
    }

    .product-image {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }

    .product-name {
        font-size: 14px;
        margin-bottom: 3px;
    }

    .product-description {
        font-size: 11px;
        margin-bottom: 3px;
        line-height: 1.3;
    }

    .product-price {
        font-size: 14px;
    }

    .product-stock {
        font-size: 10px;
    }

    .add-to-cart-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: auto;
        white-space: nowrap;
    }

    /* Cart improvements */
    .cart-summary {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 2px solid #667eea;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        padding: 12px 15px;
        z-index: 90;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .cart-summary.has-items {
        transform: translateY(0);
    }

    .cart-summary-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        max-width: 100%;
    }

    .cart-info {
        flex: 1;
    }

    .cart-total {
        font-size: 16px;
        font-weight: bold;
        color: #667eea;
        margin-bottom: 2px;
    }

    .cart-items {
        font-size: 11px;
        color: #666;
    }

    .checkout-btn {
        padding: 8px 15px;
        font-size: 13px;
        border-radius: 20px;
        white-space: nowrap;
    }

    /* Add bottom padding to body when cart is visible */
    body.cart-visible {
        padding-bottom: 80px;
    }

    /* Checkout page mobile */
    .section {
        margin-bottom: 15px;
        border-radius: 8px;
        padding: 15px;
    }

    .section-title {
        font-size: 15px;
        margin-bottom: 12px;
    }

    .form-input {
        padding: 10px 12px;
        font-size: 14px;
    }

    .tip-options {
        flex-direction: column;
        gap: 10px;
    }

    .tip-presets {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tip-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .order-summary-item {
        padding: 8px 0;
    }

    .order-summary-item img {
        width: 40px;
        height: 40px;
    }

    .total-section {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #667eea;
        margin: 0 -15px -15px;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .submit-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        margin-top: 10px;
    }

    /* Order status mobile */
    .status-timeline {
        padding: 15px;
    }

    .step {
        margin-bottom: 15px;
    }

    .step-indicator {
        width: 30px;
        height: 30px;
        font-size: 12px;
        margin-right: 10px;
    }

    .step-content h4 {
        font-size: 14px;
        margin-bottom: 3px;
    }

    .step-time {
        font-size: 11px;
    }

    /* Admin mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-icon {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .stat-number {
        font-size: 18px;
        margin-bottom: 3px;
    }

    .stat-label {
        font-size: 11px;
    }

    /* Tables mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    /* Buttons mobile */
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }

    /* Modal improvements */
    .modal-content {
        margin: 20px 10px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }

    /* Form improvements */
    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 4px;
    }

    .required {
        color: #e74c3c;
        font-size: 12px;
    }

    /* Message improvements */
    .message {
        margin: 10px;
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Loading states */
    .loading {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
        font-size: 13px;
        color: #666;
    }

    .loading::before {
        content: "";
        width: 16px;
        height: 16px;
        border: 2px solid #f3f3f3;
        border-top: 2px solid #667eea;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-right: 8px;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
}

/* Tablet adjustments (768px - 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 20px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

/* Touch improvements for all devices */
@media (hover: none) and (pointer: coarse) {
    .product-item {
        cursor: default;
    }

    .product-item:hover {
        background: white;
    }

    .product-item:active {
        background: #f8f9fa;
        transform: scale(0.98);
        transition: all 0.1s;
    }

    .btn:active {
        transform: scale(0.95);
        transition: all 0.1s;
    }

    .category-item:active {
        transform: scale(0.95);
        transition: all 0.1s;
    }
}

/* PWA optimizations */
@media screen and (display-mode: standalone) {
    .header {
        padding-top: env(safe-area-inset-top, 10px);
    }

    body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    @media screen and (max-width: 768px) {
        .cart-summary {
            background: #1a1a1a;
            border-color: #4a5568;
            color: white;
        }

        .total-section {
            background: #1a1a1a;
            border-color: #4a5568;
            color: white;
        }
    }
}