/* CosteoGastro Pro - Responsive and UX Enhancements */

/* Mobile-first approach */
@media (max-width: 640px) {
    /* Header adjustments */
    header .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header .hidden {
        display: none !important;
    }
    
    /* Main content */
    .container {
        padding: 0.75rem;
    }
    
    /* Hero section */
    .text-4xl {
        font-size: 2rem;
        line-height: 2.25rem;
    }
    
    .text-xl {
        font-size: 1.125rem;
        line-height: 1.5rem;
    }
    
    /* Cards */
    .shadow-custom {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    }
    
    /* Ingredient rows */
    .ingredient-row .grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .ingredient-row .md\\:col-span-2 {
        grid-column: span 1;
    }
    
    .ingredient-row button {
        width: 100%;
        border-radius: 0.375rem;
    }
    
    /* Buttons */
    .w-full {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Results grid */
    .grid.lg\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Technical sheet */
    .grid.md\\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    /* Tables */
    .overflow-x-auto {
        font-size: 0.75rem;
    }
    
    .overflow-x-auto table {
        min-width: 400px;
    }
    
    /* Notifications */
    .fixed {
        left: 0.75rem;
        right: 0.75rem;
        top: 4rem;
        width: auto;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        padding: 1rem 2rem;
    }
    
    .ingredient-row .grid {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
        align-items: end;
    }
    
    .ingredient-row .md\\:col-span-2 {
        grid-column: span 2;
    }
}

/* Desktop enhancements */
@media (min-width: 1025px) {
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }
    
    /* Enhanced hover effects */
    .ingredient-row {
        transition: all 0.2s ease-in-out;
    }
    
    .ingredient-row:hover {
        transform: translateY(-1px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    }
    
    /* Use same grid as tablet for desktop */
    .ingredient-row .grid {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
        align-items: end;
    }
    
    .ingredient-row .md\\:col-span-2 {
        grid-column: span 2;
    }
    
    /* Sticky result column on desktop */
    .lg\\:grid-cols-2 > div:last-child {
        position: sticky;
        top: 2rem;
        height: fit-content;
    }
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ef4444;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    z-index: 1;
}

/* Animations */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Improved focus states */
input:focus,
select:focus,
button:focus {
    outline: none;
    ring-width: 2px;
    ring-color: #ef4444;
    ring-opacity: 0.5;
    border-color: #ef4444;
}

/* Enhanced accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-gray-50 {
        background-color: white;
    }
    
    .border-gray-200,
    .border-gray-300 {
        border-color: black;
        border-width: 2px;
    }
    
    .text-gray-600,
    .text-gray-700 {
        color: black;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .bg-white {
        background-color: #374151;
    }
    
    .bg-gray-50 {
        background-color: #4b5563;
    }
    
    .text-gray-900 {
        color: #f9fafb;
    }
    
    .text-gray-600,
    .text-gray-700 {
        color: #d1d5db;
    }
    
    .border-gray-200,
    .border-gray-300 {
        border-color: #6b7280;
    }
    
    input,
    select {
        background-color: #4b5563;
        color: #f9fafb;
        border-color: #6b7280;
    }
    
    input::placeholder {
        color: #9ca3af;
    }
}

/* Print styles */
@media print {
    header,
    footer,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .shadow-custom {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .bg-accent {
        background-color: white !important;
        color: black !important;
    }
    
    .text-accent {
        color: black !important;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Error states */
.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Success states */
.success {
    border-color: #10b981 !important;
    background-color: #f0fdf4 !important;
}

/* Warning states */
.warning {
    border-color: #f59e0b !important;
    background-color: #fffbeb !important;
}

/* Improved form validation */
input:invalid {
    border-color: #ef4444;
}

input:valid {
    border-color: #10b981;
}

/* Enhanced button states */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:active {
    transform: translateY(1px);
}