/* Responsive Design */

/* Large screens (1200px and up) */
@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .content-container {
        padding: 2.5rem;
    }
}

/* Medium screens (768px to 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .search-input {
        width: 250px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-col {
        width: 100%;
    }
    
    /* Orders medium screen adjustments */
    .orders-controls {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .orders-controls .control-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .orders-filters {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .orders-filters .filter-group {
        min-width: 600px;
        display: flex;
        gap: 0.5rem;
    }
    
    .orders-stats .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small screens (576px to 767px) */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1001;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .top-header {
        padding: 1rem;
    }
    
    .header-right {
        gap: 0.5rem;
    }
    
    .search-container {
        display: none;
    }
    
    .mobile-search {
        display: block;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .page-title {
        font-size: var(--font-size-xl);
    }
    
    .content-container {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .quick-action {
        padding: 1rem;
        text-align: center;
    }
    
    .quick-action i {
        font-size: 1.5rem;
    }
    
    .activity-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .activity-time {
        align-self: flex-end;
    }
    
    /* Modal adjustments for mobile */
    .modal {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Table responsiveness */
    .table-container {
        overflow-x: auto;
    }
    
    .table {
        min-width: 800px;
    }
    
    /* Inventory specific mobile styles */
    .inventory-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .control-group {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }
    
    .control-group .btn {
        margin-right: 0.5rem;
    }
    
    .inventory-filters {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .filter-group {
        display: flex;
        gap: 0.5rem;
        min-width: 600px;
    }
    
    .filter-group .form-group {
        margin-bottom: 0;
        min-width: 120px;
    }
    
    /* Orders specific mobile styles */
    .orders-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .orders-controls .control-group {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }
    
    .orders-controls .control-group .btn {
        margin-right: 0.5rem;
        flex-shrink: 0;
    }
    
    .orders-controls .view-controls {
        order: -1;
        margin-bottom: 1rem;
    }
    
    .orders-filters {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .orders-filters .filter-group {
        min-width: 700px;
        display: flex;
        gap: 0.5rem;
    }
    
    .orders-filters .filter-group .form-group {
        margin-bottom: 0;
        min-width: 120px;
        flex-shrink: 0;
    }
    
    .orders-stats .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Warehouse specific mobile styles */
    .warehouse-layout-container {
        flex-direction: column;
    }
    
    .layout-sidebar {
        width: 100%;
        order: 2;
        margin-top: 1rem;
    }
    
    .layout-main {
        width: 100%;
        order: 1;
    }
    
    .warehouse-map {
        height: 300px;
    }
    
    .warehouse-svg {
        width: 100%;
        height: 100%;
    }
    
    .kanban-board {
        flex-direction: column;
        gap: 1rem;
    }
    
    .kanban-column {
        min-width: auto;
        width: 100%;
    }
}

/* Extra small screens (below 576px) */
@media (max-width: 575px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius);
        margin-bottom: 0.25rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .stat-value {
        font-size: var(--font-size-2xl);
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .table-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Hide less important columns on very small screens */
    .table th:nth-child(n+6),
    .table td:nth-child(n+6) {
        display: none;
    }
    
    /* Orders table specific mobile improvements */
    .orders-content .table th:nth-child(1),
    .orders-content .table td:nth-child(1) {
        /* Hide checkbox column on mobile */
        display: none;
    }
    
    .orders-content .table th:nth-child(6),
    .orders-content .table td:nth-child(6),
    .orders-content .table th:nth-child(7),
    .orders-content .table td:nth-child(7) {
        /* Hide order date and delivery date on very small screens */
        display: none;
    }
    
    /* Convert table to card layout on very small screens */
    .orders-content .table-container {
        display: none;
    }
    
    .orders-content .orders-mobile-cards {
        display: block;
    }
    
    .inventory-card,
    .kanban-card {
        margin-bottom: 1rem;
    }
    
    /* Orders mobile cards */
    .order-card {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
    
    .order-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
    }
    
    .order-card-title {
        font-weight: 600;
        font-size: var(--font-size-lg);
        color: var(--text-primary);
        margin-bottom: 0.25rem;
    }
    
    .order-card-customer {
        font-size: var(--font-size-sm);
        color: var(--text-secondary);
    }
    
    .order-card-body {
        margin-bottom: 1rem;
    }
    
    .order-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }
    
    .order-card-row:last-child {
        margin-bottom: 0;
    }
    
    .order-card-label {
        font-size: var(--font-size-sm);
        color: var(--text-secondary);
        font-weight: 500;
    }
    
    .order-card-value {
        font-size: var(--font-size-sm);
        color: var(--text-primary);
    }
    
    .order-card-actions {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .order-card-actions .btn {
        flex: 1;
        min-width: 0;
        font-size: var(--font-size-xs);
    }
    
    /* Orders stats mobile */
    .orders-stats .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .orders-stats .stat-card {
        padding: 1rem;
    }
    
    .orders-stats .stat-value {
        font-size: var(--font-size-xl);
    }
}

/* Landscape phones */
@media (max-width: 767px) and (orientation: landscape) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    
    .sidebar .logo-text,
    .sidebar .nav-link span,
    .sidebar .user-info {
        display: none;
    }
    
    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }
    
    .top-header {
        height: 60px;
        padding: 0.75rem 1rem;
    }
    
    .page-title {
        font-size: var(--font-size-lg);
    }
    
    .page-subtitle {
        display: none;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        min-height: 36px;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.875rem;
        min-height: 44px;
    }
    
    .nav-link {
        padding: 1rem;
        min-height: 48px;
    }
    
    .table-actions .btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .zone-group {
        cursor: pointer;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .top-header,
    .modal-backdrop,
    .modal,
    .btn,
    .form-group,
    .alerts-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-container {
        padding: 0;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .table {
        font-size: 12px;
    }
    
    .warehouse-map {
        page-break-inside: avoid;
    }
    
    /* Ensure colors are visible in print */
    .badge,
    .stat-icon,
    .progress-bar {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .warehouse-svg {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: pixelated;
    }
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1f2937;
        --gray-50: #111827;
        --gray-100: #1f2937;
        --gray-200: #374151;
        --gray-300: #4b5563;
        --gray-400: #6b7280;
        --gray-500: #9ca3af;
        --gray-600: #d1d5db;
        --gray-700: #e5e7eb;
        --gray-800: #f3f4f6;
        --gray-900: #f9fafb;
    }
    
    body {
        background-color: var(--gray-50);
        color: var(--gray-700);
    }
}

/* Reduced motion preference */
@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;
    }
    
    .fade-in,
    .slide-in-right,
    .slide-in-left {
        animation: none;
    }
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Focus styles for accessibility */
.btn:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Additional warehouse layout responsive styles */
@media (max-width: 1200px) {
    .warehouse-layout-container {
        flex-direction: column;
    }
    
    .layout-sidebar {
        width: 100%;
        order: 2;
        margin-top: 1rem;
    }
    
    .sidebar-section {
        margin-bottom: 1.5rem;
    }
    
    .layout-main {
        width: 100%;
        order: 1;
    }
}

/* Inventory grid view responsive */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .inventory-grid {
        grid-template-columns: 1fr;
    }
}

/* Analytics responsive charts */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    .analytics-grid .card {
        min-width: auto;
    }
}

/* Kanban responsive */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
}

.kanban-column {
    min-width: 300px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .kanban-board {
        flex-direction: column;
        overflow-x: visible;
    }
    
    .kanban-column {
        min-width: auto;
        width: 100%;
    }
}

/* Mobile navigation improvements */
@media (max-width: 767px) {
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        color: var(--gray-600);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--border-radius);
        transition: var(--transition);
    }
    
    .mobile-menu-btn:hover {
        background-color: var(--gray-100);
    }
    
    .mobile-search {
        display: none;
        background-color: var(--white);
        border: 1px solid var(--gray-200);
        border-radius: var(--border-radius);
        padding: 0.75rem;
        margin: 1rem;
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-search.active {
        display: block;
    }
    
    .mobile-search .search-input {
        width: 100%;
        background-color: var(--gray-100);
        border: none;
        padding: 0.75rem 1rem;
    }
}

/* Accessibility improvements for high contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid var(--gray-400);
    }
    
    .badge {
        border: 1px solid currentColor;
    }
}