/* Custom styles for Milk Recording System */

/* Override minimal custom styles only when necessary */
:root {
    --custom-accent: #0d6efd;
    --custom-success: #198754;
    --custom-warning: #ffc107;
    --custom-danger: #dc3545;
}

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

/* Card hover effects - disabled on mobile for performance */
.card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Statistics cards */
.card.bg-primary,
.card.bg-info,
.card.bg-success,
.card.bg-warning {
    border: none;
}

.card.bg-primary .card-body,
.card.bg-info .card-body,
.card.bg-success .card-body,
.card.bg-warning .card-body {
    padding: 1.5rem;
}

/* Table enhancements */
.table th {
    border-top: none;
    font-weight: 600;
}

.table-hover tbody tr:hover {
    background-color: var(--bs-gray-100);
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: var(--bs-gray-800);
}

/* Form enhancements */
.form-control:focus,
.form-select:focus {
    border-color: var(--custom-accent);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

/* Button enhancements - optimized for mobile */
.btn {
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        transform: translateY(-1px);
    }
}

/* Ultra-fast Android scrolling optimizations */
@media (max-width: 768px) {
    /* Aggressive Android scroll performance */
    * {
        -webkit-overflow-scrolling: auto !important;
        overscroll-behavior: none !important;
        scroll-behavior: auto !important;
    }
    
    html {
        overflow-x: hidden;
        overflow-y: auto;
        height: 100%;
        touch-action: pan-y;
    }
    
    body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        touch-action: pan-y;
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    /* Eliminate ALL transitions and animations */
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
        transform: none !important;
        will-change: auto !important;
    }
    
    /* Container optimization */
    .container, .container-fluid {
        touch-action: pan-y;
        overflow: visible;
        transform: translateZ(0);
    }
    
    /* Form elements - prevent zoom and optimize touch */
    .btn, .form-control, .form-select, input, select, textarea {
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Table scrolling - simplified approach */
    .table-responsive {
        overflow: auto;
        -webkit-overflow-scrolling: auto;
        touch-action: auto;
        max-width: 100%;
    }
    
    /* Reduce layout reflows */
    .card {
        margin-bottom: 1rem;
        will-change: auto;
    }
    
    /* Optimize table rendering on mobile */
    .table {
        font-size: 0.9rem;
    }
    
    /* Reduce icon sizes for faster rendering */
    .fas, .far {
        font-size: inherit;
    }
    
    /* Additional mobile table optimizations */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Badge styles */
.badge {
    font-size: 0.75em;
}

/* Navbar brand */
.navbar-brand {
    font-weight: 600;
}

/* Footer */
footer {
    margin-top: auto;
}

/* Animation for flash messages */
.alert {
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Sortable table headers */
th[data-sort] {
    user-select: none;
}

th[data-sort]:hover {
    background-color: var(--bs-gray-200);
}

[data-bs-theme="dark"] th[data-sort]:hover {
    background-color: var(--bs-gray-700);
}

/* Empty state styling */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state i {
    opacity: 0.5;
}

/* Input group improvements */
.input-group-text {
    background-color: var(--bs-gray-200);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .input-group-text {
    background-color: var(--bs-gray-700);
}

/* Fix Android Scrolling Issues */
html {
    /* Fix Android scrolling issues */
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    touch-action: pan-y;
}

body {
    /* Enable smooth scrolling */
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    /* Prevent rubber band scrolling */
    overscroll-behavior: contain;
    touch-action: pan-y;
}

/* Fix for Android Chrome scrolling */
* {
    -webkit-tap-highlight-color: transparent;
}

/* PWA/Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    /* Disable hover effects on mobile to prevent scroll interference */
    .card:hover {
        transform: none !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .btn:hover {
        transform: none !important;
    }
    
    /* Touch-friendly buttons */
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve form inputs on mobile */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Optimize table scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        touch-action: pan-x pan-y;
    }
    
    /* Fix navbar on mobile */
    .navbar {
        position: relative;
        z-index: 1030;
    }
    
    /* Prevent zoom on inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Make tables more mobile-friendly */
    .table td, .table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }
}

/* PWA Specific Styles */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .navbar {
        position: sticky;
        top: 0;
        z-index: 1020;
    }
}

/* Install button styles */
#install-btn {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-radius: 25px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: 0.5rem;
    z-index: 9999;
    display: none;
}

/* Loading states for PWA */
.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #007bff;
    border-radius: 50%;
    border-top: 2px solid transparent;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    footer,
    #install-btn {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}
