/* CSS Performance Optimizations */

/* Mobile-first overflow prevention */
* {
    max-width: 100%;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
    max-width: calc(100vw - 2rem);
}

.offline-indicator.online {
    background: linear-gradient(135deg, #51cf66, #40c057);
}

.offline-indicator .offline-icon {
    font-size: 1rem;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-100%); }
    to { transform: translateX(-50%) translateY(0); }
}

/* Force hardware acceleration for animations */
.trip-card,
.planning-item,
.modal,
.form-container {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Use transform instead of changing width/height for animations */
.trip-card {
    transform: translateZ(0); /* Force GPU acceleration */
    transition: transform 0.2s ease-out;
}

.trip-card:hover {
    transform: translateY(-2px) translateZ(0);
}

/* Optimize modal animations */
.modal {
    transform: translateZ(0);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.modal.show {
    transform: scale(1) translateZ(0);
}

.modal:not(.show) {
    transform: scale(0.95) translateZ(0);
}

/* Reduce layout thrashing */
.trip-card,
.planning-item {
    contain: layout style;
}

/* Optimize scrolling performance */
.scrollable-content {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* Use contain for independent sections */
.trip-card {
    contain: layout;
}

/* Optimize large lists */
.trips-grid {
    contain: layout;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Prevent unnecessary repaints */
.static-content {
    contain: strict;
}

/* Optimize checkbox animations */
input[type="checkbox"] {
    transform: translateZ(0);
}

/* Use efficient transitions */
.smooth-transition {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Optimize button hover effects */
.btn,
.trip-card .btn {
    transform: translateZ(0);
    transition: transform 0.2s ease-out, background-color 0.2s ease-out;
}

.btn:hover {
    transform: translateY(-1px) translateZ(0);
}

/* Prevent text selection where not needed */
.trip-card,
.planning-item,
.btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Optimize opacity changes */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Use efficient grid layout */
.grid-container {
    display: grid;
    grid-auto-rows: min-content;
}

/* Optimize form elements */
.form-group {
    contain: layout style;
}

/* Reduce paint complexity */
.complex-background {
    will-change: auto; /* Reset after initial load */
}

/* Optimize scroll performance */
.scroll-container {
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

/* Efficient visibility changes */
.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    /* Prevent horizontal overflow on all elements */
    * {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* Optimize mobile containers */
    .app-container,
    .view,
    .main-content,
    .management-sections {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* Reduce animation complexity on mobile */
    .trip-card:hover {
        transform: none;
    }
    
    /* Optimize modal size */
    .modal {
        max-width: calc(100vw - 2rem) !important;
        margin: 1rem !important;
    }
    
    /* Touch-optimized buttons */
    .btn, .nav-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Optimize grid for mobile */
    .trips-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100% !important;
        max-width: calc(100vw - 2rem) !important;
    }
    
    /* Prevent zoom on inputs */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Optimize scrolling on mobile */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
}