/* Mobile-First Enhancements */

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .input-group label {
        margin-right: 0;
        font-weight: 500;
    }
    
    .input-group .input-wrapper {
        flex: 1;
        width: 100%;
    }
    
    .input-group input,
    .input-group select {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px; /* Touch target size */
    }
    
    /* Better sidebar on mobile */
    aside {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .sidebar-item {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Stack layout on mobile */
    .grid.xl\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Better button spacing */
    button {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Improved modal for mobile */
    .fixed.inset-0 > div {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* Touch-friendly checkboxes and inputs */
    input[type="checkbox"], input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }
    
    /* Improved chart containers */
    .chart-container,
    .bar-chart-container {
        height: 200px;
    }
    
    /* Better summary items */
    .summary-item {
        padding: 0.75rem 0;
        font-size: 0.9rem;
    }
    
    /* Responsive tables */
    table {
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
}

/* Tablet improvements */
@media (min-width: 769px) and (max-width: 1024px) {
    .grid.xl\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    aside {
        width: 200px;
    }
}

/* High-DPI screen optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark mode specific improvements */
@media (prefers-color-scheme: dark) {
    /* Enhanced contrast for better readability */
    .summary-item {
        border-bottom-color: #4b5563;
    }
    
    input:focus,
    select:focus {
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.5);
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .sidebar-item,
    button,
    input,
    select {
        transition: none;
    }
    
    .chart-container canvas {
        animation: none;
    }
}

/* Print styles */
@media print {
    .sidebar-item,
    button:not(.print-btn),
    .chart-container {
        display: none;
    }
    
    .summary-item {
        border-bottom: 1px solid #000;
        color: #000;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* Additional Mobile Features */

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    text-align: center;
    padding: 0.5rem;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* App Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: #3b82f6;
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.install-prompt.show {
    transform: translateY(0);
}

.install-prompt button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

/* Pull to Refresh */
.pull-to-refresh {
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.pull-to-refresh.pulling {
    transform: translateY(60px);
}

/* Loading States */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Compact Mode */
.compact-mode .input-group {
    margin-bottom: 0.5rem;
}

.compact-mode .summary-item {
    padding: 0.5rem;
}

.compact-mode .sidebar-item {
    padding: 0.75rem;
    font-size: 0.875rem;
}

/* Accessibility Improvements */
@media (prefers-contrast: high) {
    input, select, button {
        border-width: 2px;
        border-color: #000;
    }
    
    button {
        font-weight: bold;
    }
    
    .summary-item {
        border-width: 2px;
    }
}
@media (prefers-contrast: high) {
    input, select, button {
        border-width: 2px;
        border-color: #000;
    }
    
    button {
        font-weight: bold;
    }
    
    .summary-item {
        border-width: 2px;
    }
}
