/**
 * Cannabis Clinics Mobile Responsive CSS
 * Enhances mobile experience without changing brand colors
 * Brand Colors: #1b2a43 (dark blue), #3b82f6 (light blue), white
 */

/* ========================================
   MOBILE-FIRST BASE STYLES
   ======================================== */

/* Ensure proper box sizing */
* {
    box-sizing: border-box;
}

/* Smooth scrolling on mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    width: 100%;
}

/* Better touch targets (minimum 44px) */
button,
a.btn,
.btn,
input[type="submit"],
input[type="button"],
.clickable {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
}

/* Improved form inputs for mobile */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea,
select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    width: 100%;
    border-radius: 8px;
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */

/* Mobile typography scale */
@media (max-width: 576px) {
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    h5 { font-size: 1rem !important; }
    h6 { font-size: 0.9rem !important; }

    .display-1 { font-size: 3rem !important; }
    .display-2 { font-size: 2.5rem !important; }
    .display-3 { font-size: 2rem !important; }
    .display-4 { font-size: 1.75rem !important; }
}

/* ========================================
   MOBILE NAVIGATION IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Sticky mobile header */
    .navbar,
    nav,
    header {
        position: sticky;
        top: 0;
        z-index: 1030;
        background: white !important;
        box-shadow: 0 2px 4px rgba(27, 42, 67, 0.1);
    }

    /* Mobile menu button */
    .navbar-toggler {
        border: none;
        padding: 8px 12px;
        font-size: 1.5rem;
    }

    /* Full-width mobile menu */
    .navbar-collapse {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        padding: 1rem;
        overflow-y: auto;
        box-shadow: 0 4px 6px rgba(27, 42, 67, 0.1);
    }

    /* Mobile nav items */
    .navbar-nav .nav-link {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        font-size: 1.1rem;
    }
}

/* ========================================
   RESPONSIVE PRODUCT GRID
   ======================================== */

.product-grid {
    display: grid;
    gap: 1rem;
}

/* Mobile: 2 columns */
@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem;
    }

    .product-card {
        padding: 0.75rem;
    }

    .product-card img {
        height: 120px;
        object-fit: cover;
    }

    .product-card .product-title {
        font-size: 0.9rem;
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .product-card .product-price {
        font-size: 1rem;
        font-weight: bold;
    }
}

/* Tablet: 3 columns */
@media (min-width: 577px) and (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Small desktop: 4 columns */
@media (min-width: 769px) and (max-width: 992px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Large desktop: 5+ columns */
@media (min-width: 993px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ========================================
   MOBILE CART SIDEBAR
   ======================================== */

@media (max-width: 768px) {
    .cart-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        background: white;
        z-index: 1050;
        transition: right 0.3s ease;
        overflow-y: auto;
    }

    .cart-sidebar.active {
        right: 0;
    }

    .cart-header {
        position: sticky;
        top: 0;
        background: white;
        padding: 1rem;
        border-bottom: 2px solid #1b2a43;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .cart-close {
        font-size: 1.5rem;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Cart items mobile layout */
    .cart-item {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        display: flex;
        gap: 1rem;
    }

    .cart-item img {
        width: 60px;
        height: 60px;
        object-fit: cover;
        border-radius: 8px;
    }

    .cart-footer {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        border-top: 2px solid #1b2a43;
    }
}

/* ========================================
   MOBILE MODALS
   ======================================== */

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
    }

    .modal-body {
        overflow-y: auto;
        padding: 1rem;
    }
}

/* ========================================
   MOBILE TABLES
   ======================================== */

@media (max-width: 768px) {
    /* Convert tables to cards on mobile */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
    }

    .table-responsive td {
        border: none;
        position: relative;
        padding-left: 40%;
    }

    .table-responsive td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #1b2a43;
    }
}

/* ========================================
   MOBILE FLOATING ACTION BUTTON
   ======================================== */

@media (max-width: 768px) {
    .floating-cart-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: #3b82f6;
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        z-index: 1020;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    .floating-cart-btn .badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #ef4444;
        border-radius: 50%;
        min-width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
    }
}

/* ========================================
   MOBILE TABS
   ======================================== */

@media (max-width: 576px) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* ========================================
   RESPONSIVE SPACING
   ======================================== */

@media (max-width: 576px) {
    /* Reduce padding on mobile */
    .container,
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    section {
        padding: 2rem 0;
    }

    .py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

    .my-5 { margin-top: 2rem !important; margin-bottom: 2rem !important; }
    .my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
    .my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
}

/* ========================================
   MOBILE CARDS
   ======================================== */

@media (max-width: 576px) {
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-title {
        font-size: 1.1rem;
    }
}

/* ========================================
   MOBILE FORMS
   ======================================== */

@media (max-width: 576px) {
    .form-group,
    .mb-3 {
        margin-bottom: 1.25rem;
    }

    .form-label {
        font-weight: 600;
        color: #1b2a43;
        margin-bottom: 0.5rem;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.75rem;
        border-radius: 8px;
    }

    /* Full-width buttons on mobile */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        border-radius: 8px !important;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   MOBILE ALERTS & TOASTS
   ======================================== */

@media (max-width: 576px) {
    .alert {
        margin: 0.5rem;
        border-radius: 8px;
        font-size: 0.9rem;
    }

    .toast-container {
        bottom: 70px !important; /* Above floating button */
        right: 1rem !important;
        left: 1rem !important;
    }

    .toast {
        width: 100%;
    }
}

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

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .btn:hover,
    .card:hover,
    .product-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #1b2a43;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ========================================
   MOBILE LOADING STATES
   ======================================== */

@media (max-width: 576px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }

    .placeholder-glow .placeholder {
        animation-duration: 1s;
    }
}