/* ==========================================================================
   PWA Responsive Design - Mobile First Approach
   ========================================================================== */

/* Mobile-first base styles (default - no media query needed)
   ========================================================================== */

/* Mobile Navigation Drawer */
.mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color) 0%, #224abe 100%);
    z-index: 1000;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
}

.mobile-nav-drawer.active {
    left: 0;
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-nav-overlay.active {
    display: block;
}

/* Mobile Header */
.mobile-header-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-hamburger {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--dark-color);
    transition: background 0.3s;
}

.mobile-hamburger:hover {
    background: rgba(0, 0, 0, 0.1);
}

.mobile-hamburger i {
    font-size: 1.25rem;
}

/* Responsive Tables */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive-wrapper table {
    min-width: 600px; /* Ensure tables don't squish too much */
}

/* Touch-friendly Buttons */
.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 8px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.page-actions .btn {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
}

/* Responsive Form Controls */
.form-container {
    width: 100%;
    max-width: 400px;
    margin: 1rem auto;
    padding: 1.5rem;
}

.form-container input,
.form-container select,
.form-container button {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
}

/* Password toggle buttons */
.password-toggle {
    position: relative;
}

.password-toggle input {
    padding-right: 50px;
}

.password-toggle .toggle-icon {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Responsive Modals */
.modal {
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    margin: 5vh auto;
    padding: 1.5rem;
    border-radius: 12px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Close modal button - touch friendly */
.close-modal {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Stats Cards - Mobile Grid */
.stats-cards {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1rem;
}

.card {
    padding: 1.25rem;
    min-height: 100px;
}

.card h3 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.card span {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Inventory Tabs */
.inventory-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e3e6f0;
}

.tab-btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
    white-space: nowrap;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--dark-color);
    transition: all 0.3s;
}

.tab-btn.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Search Box */
.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px 12px 48px;
    border: 2px solid #e3e6f0;
    border-radius: 8px;
    font-size: 1rem;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Date Filter */
.date-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 1rem;
}

.date-filter input[type="date"] {
    flex: 1;
    min-width: 140px;
    min-height: 48px;
    padding: 12px;
    border: 2px solid #e3e6f0;
    border-radius: 8px;
    font-size: 1rem;
}

.date-filter span {
    padding: 0 8px;
}

/* Dropdown Menu - Touch Friendly */
.dropdown-menu {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.3s;
    min-height: 52px;
}

.dropdown-menu a:hover {
    background: #f8f9fc;
    color: var(--primary-color);
}

.dropdown-menu a i {
    width: 24px;
    text-align: center;
}

/* Content Card */
.content-card {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

/* Table Controls */
.table-controls {
    margin-bottom: 1rem;
}

/* Cart Styling */
.cart-item {
    padding: 16px;
    margin: 12px 0;
    background: #f8f9fc;
    border-radius: 12px;
    position: relative;
}

.remove-item {
    width: 44px;
    height: 44px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 8px;
}

.cart-total {
    padding: 16px;
    background: #e9ecef;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
}

/* Toast Messages */
.toast-error {
    width: 90%;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 12px;
    z-index: 10000;
    font-size: 1rem;
    font-weight: 600;
}

/* Success/Error Messages */
.success-message,
.error-message {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* ==========================================================================
   Tablet Styles (576px and up)
   ========================================================================== */
@media (min-width: 576px) {
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .page-actions .btn {
        flex: none;
        min-width: auto;
    }
    
    .modal {
        width: 90%;
        max-width: 600px;
    }
    
    .date-filter input[type="date"] {
        min-width: 160px;
    }
}

/* ==========================================================================
   Tablet Landscape / Small Desktop (768px and up)
   ========================================================================== */
@media (min-width: 768px) {
    /* Show sidebar toggle button */
    .sidebar-toggle-container {
        display: block;
    }
    
    /* Stats cards - 3 columns */
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Tables can show more columns */
    .table-responsive-wrapper table {
        min-width: 800px;
    }
    
    /* Page header */
    .page-header h1 {
        font-size: 1.75rem;
    }
    
    /* Form container */
    .form-container {
        margin: 3rem auto;
        padding: 2rem;
    }
    
    /* Cart items side by side on larger screens */
    .cart-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .remove-item {
        margin-top: 0;
        margin-left: 16px;
    }
}

/* ==========================================================================
   Desktop Styles (992px and up)
   ========================================================================== */
@media (min-width: 992px) {
    /* Stats cards - 4 columns */
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Tables full width */
    .table-responsive-wrapper table {
        min-width: 1000px;
    }
    
    /* Page header */
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }
    
    .page-header h1 {
        margin-bottom: 0;
    }
    
    .page-actions {
        margin-bottom: 0;
    }
}

/* ==========================================================================
   Large Desktop (1200px and up)
   ========================================================================== */
@media (min-width: 1200px) {
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Hide elements on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide elements on desktop */
@media (min-width: 768px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Full width on mobile */
.full-width-mobile {
    width: 100% !important;
}

/* Center content on mobile */
.center-mobile {
    text-align: center;
}

/* Stack items vertically */
.stack-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Padding utilities */
.p-mobile-1 { padding: 1rem; }
.p-mobile-2 { padding: 1.5rem; }

/* Margin utilities */
.mb-mobile-1 { margin-bottom: 1rem; }
.mb-mobile-2 { margin-bottom: 1.5rem; }

/* Chart Container */
.chart-container {
    width: 100%;
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 350px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 400px;
    min-height: 300px;
}

/* Header Responsive Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center {
    flex: 1;
    text-align: center;
    display: none; /* Hidden on mobile */
}

.header-right {
    display: flex;
    align-items: center;
}

.subscription-label {
    color: red;
    font-weight: bold;
    font-size: 0.875rem;
}

@media (min-width: 576px) {
    .header-center {
        display: block;
    }
    
    .subscription-label {
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    .header {
        padding: 1rem 2rem;
    }
}

