/* Cooking Calculator Specific Styles */

/* Item & Unit Dropdown Styles */
.item-dropdown-wrapper,
.unit-dropdown-wrapper {
    position: relative;
}

.item-dropdown-button,
.unit-dropdown-button {
    transition: all 0.2s ease;
}

.item-dropdown-button:hover,
.unit-dropdown-button:hover {
    border-color: #6b7280;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.item-dropdown-button:focus,
.unit-dropdown-button:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.item-dropdown-panel,
.unit-dropdown-panel {
    z-index: 50;
    animation: fadeIn 0.2s ease-out;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.item-dropdown-panel.hidden,
.unit-dropdown-panel.hidden {
    display: none;
}

.dropdown-arrow.rotate {
    transform: rotate(180deg);
}

/* Search Input */
.item-search-input {
    transition: all 0.2s ease;
}

.item-search-input:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* List Items */
.item-list-item,
.unit-list-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid #374151;
}

.item-list-item:last-child,
.unit-list-item:last-child {
    border-bottom: none;
}

.item-list-item:hover,
.unit-list-item:hover {
    background-color: var(--hover-bg);
}

.item-list-item.highlighted,
.unit-list-item.highlighted {
    background-color: #3b82f6;
    color: #ffffff;
}

.item-list-item.selected,
.unit-list-item.selected {
    background-color: #1e40af;
    color: #ffffff;
    font-weight: 600;
}

/* Unit Type Headers */
.unit-type-header {
    padding: 0.75rem 1rem;
    font-size: 1.125rem; /* Increased from 0.875rem to 1.125rem (18px) */
    font-weight: 600; /* Semi-bold for better prominence */
    color: #e5e7eb; /* Light gray instead of muted - much more readable */
    background-color: #374151; /* Darker background for contrast */
    border-bottom: 2px solid #4b5563; /* Thicker border for separation */
    text-transform: uppercase; /* Make it stand out as a category */
    letter-spacing: 0.05em; /* Slight letter spacing for readability */
    position: sticky; /* Keep headers visible when scrolling */
    top: 0;
    z-index: 10;
}

/* Results Section */
#result-display {
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent; /* Remove iOS tap highlight */
    touch-action: manipulation; /* Improve touch responsiveness */
}

#result-display:hover {
    background-color: rgb(55 65 81); /* gray-700 - same as unit converter */
}

#result-display.copied {
    background-color: rgb(34 197 94 / 0.2) !important; /* green with opacity - important to override hover */
    border-color: rgb(34 197 94 / 0.6) !important; /* green border */
    animation: copy-feedback 2s ease-in-out;
}

#result-display.copied:hover {
    background-color: rgb(34 197 94 / 0.2) !important; /* Keep green background on hover during copied state */
}

/* Mobile-specific fixes */
@media (hover: none) and (pointer: coarse) {
    #result-display:hover {
        background-color: rgb(31 41 55); /* Keep original background on mobile */
    }
    
    #result-display:active {
        background-color: rgb(55 65 81); /* Show feedback only on active touch */
        transition: background-color 0.1s ease;
    }
}

#conversion-result {
    font-family: 'Courier New', monospace;
}

#copy-hint {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#result-display:hover #copy-hint {
    opacity: 1;
}

/* Action Buttons */
.btn-primary,
.btn-secondary {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

/* Popular Conversions */
#popular-conversions .bg-gray-800 {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#popular-conversions .bg-gray-800::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    transition: left 0.5s ease;
}

#popular-conversions .bg-gray-800:hover::before {
    left: 100%;
}

#popular-conversions .bg-gray-800:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.15);
}

/* Swap Button Animation */
#swap-units {
    transition: all 0.3s ease;
    position: relative;
}

#swap-units:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.3);
}

#swap-units:active {
    transform: scale(0.95);
}

/* Loading States */
.loading-shimmer {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes copy-feedback {
    0% { background-color: rgb(34 197 94 / 0.2); }
    20% { background-color: rgb(34 197 94 / 0.3); }
    40% { background-color: rgb(34 197 94 / 0.2); }
    100% { background-color: rgb(31 41 55); }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .item-dropdown-panel,
    .unit-dropdown-panel {
        /* Positioning will be handled by JavaScript for better UX */
        z-index: 9999;
        /* Remove animation on mobile to prevent positioning delays */
        animation: none !important;
        transition: none !important;
    }
    
    .item-list,
    .unit-list {
        max-height: 50vh !important;
    }
    
    #popular-conversions {
        grid-template-columns: 1fr;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 16px;
        font-size: 16px;
    }
}

/* Focus Indicators for Accessibility */
.item-dropdown-button:focus-visible,
.unit-dropdown-button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.item-list-item:focus,
.unit-list-item:focus {
    background-color: #3b82f6;
    color: #ffffff;
    outline: none;
}

/* Error States */
.dropdown-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Success States */
.calculation-success {
    animation: pulse-success 0.6s ease-out;
}

@keyframes pulse-success {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .item-dropdown-button,
    .unit-dropdown-button {
        border-width: 2px;
    }
    
    .item-list-item:hover,
    .unit-list-item:hover {
        background-color: #ffffff;
        color: #000000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.result-pane {
    min-height: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--result-bg);
    border-radius: 0.5rem;
    margin: 1rem 0;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
    position: relative;
}

.result-pane:hover {
    background-color: var(--result-hover-bg);
}

.result-pane:active {
    background-color: var(--result-active-bg);
}

/* Result pane styling */
.result-pane {
    min-height: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--result-bg);
    border-radius: 0.5rem;
    margin: 1rem 0;
    padding: 1rem;
    user-select: text;
}

/* Button hover effects */
.btn {
    transition: opacity 0.2s ease;
}

.btn:hover {
    opacity: 0.9;
}

/* Center copy text */
.copy-hint-text {
    text-align: center;
    padding-top: 10px;
}

/* Remove hover persistence on mobile */
@media (hover: none) {
    .btn:active {
        opacity: 0.9;
    }
    .btn:not(:active) {
        opacity: 1;
    }
}

/* Flash animation for copy success */
@keyframes flash-border {
    0% {
        border-color: var(--border-color);
    }
    5% {
        border-color: #22c55e;  /* green-500 */
    }
    95% {
        border-color: #22c55e;  /* green-500 */
    }
    100% {
        border-color: var(--border-color);
    }
}

.flash-success {
    animation: flash-border 2s ease-out forwards;
}

/* Dropdown item styling */
.item-list-item,
.unit-list-item {
    cursor: pointer;
}

.item-list-item:hover,
.unit-list-item:hover {
    background-color: var(--hover-bg);
}

.item-list-item > div,
.unit-list-item > div {
    width: 100%;
}

/* Improve mobile scrolling */
.item-list,
.unit-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

.item-list-item,
.unit-list-item {
    touch-action: pan-y;
}

/* Prevent text selection while scrolling */
.item-list,
.unit-list,
.item-list-item,
.unit-list-item {
    -webkit-user-select: none;
    user-select: none;
} 