/* GAG Recipes - 计算器布局精细化优化 */

/* === 食材选择器重新设计 === */
.ingredients-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-3);
    max-height: 420px;
    overflow-y: auto;
    padding: var(--space-5);
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
    border-radius: var(--border-radius-xl);
    border: 2px solid var(--gray-200);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 自定义滚动条 */
.ingredients-selector::-webkit-scrollbar {
    width: 8px;
}

.ingredients-selector::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

.ingredients-selector::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.ingredients-selector::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* 食材项目重新设计 */
.ingredient-item {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    background: white;
    border-radius: var(--border-radius-lg);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ingredient-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(59, 130, 246, 0.05) 100%);
    border-radius: var(--border-radius-lg);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ingredient-item:hover {
    border-color: var(--primary-300);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.ingredient-item:hover::before {
    opacity: 1;
}

.ingredient-item.special {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: var(--accent-400);
    position: relative;
}

.ingredient-item.special::after {
    content: '⭐';
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    font-size: 14px;
    opacity: 0.7;
}

/* 复选框样式增强 */
.ingredient-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: var(--space-3);
    accent-color: var(--primary-500);
    cursor: pointer;
    position: relative;
    z-index: 2;
}

/* 标签布局优化 */
.ingredient-item label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    flex: 1;
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
    color: var(--gray-800);
    position: relative;
    z-index: 2;
    
    /* 文字清晰度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* 食材图片优化 */
.ingredient-item img {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-lg);
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.ingredient-item:hover img {
    transform: scale(1.05);
}

/* 数量输入框增强 */
.quantity-input {
    width: 70px;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius-lg);
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-left: auto;
    background: var(--gray-50);
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
    
    /* 文字清晰度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--gray-800);
}

.quantity-input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* === 表单控件间距优化 === */
.input-group {
    margin-bottom: var(--space-7);
    position: relative;
}

.input-group:last-child {
    margin-bottom: var(--space-8);
}

/* 标签样式精细化 */
.input-group label {
    display: block;
    font-weight: 700;
    color: var(--gray-900);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    
    /* 增强文字清晰度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.input-group label::after {
    content: '';
    position: absolute;
    bottom: -var(--space-2);
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--primary-500);
    border-radius: 1px;
}

/* === 表单控件统一优化 === */
.form-input,
.form-select {
    width: 100%;
    padding: var(--space-4) var(--space-5);
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius-xl);
    font-size: var(--font-size-base);
    font-weight: 600;
    background: white;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    
    /* 文字清晰度优化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--gray-900);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.15),
        0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
    background: #fafbff;
}

.form-input:hover,
.form-select:hover {
    border-color: var(--gray-400);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* === 计算按钮终极增强 === */
.calculate-btn {
    width: 100%;
    padding: var(--space-6) var(--space-8);
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 50%, var(--primary-700) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius-2xl);
    font-size: var(--font-size-xl);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    
    /* 超强3D效果 */
    box-shadow: 
        0 8px 16px -4px rgba(59, 130, 246, 0.4),
        0 4px 8px -2px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    
    /* 文字增强 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* 图标和文字布局 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    
    /* 边框光效 */
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* 按钮光泽动画 */
.calculate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4), 
        transparent
    );
    transition: left 0.6s ease;
}

/* 按钮脉冲效果 */
.calculate-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.6s ease;
}

.calculate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 12px 24px -6px rgba(59, 130, 246, 0.5),
        0 8px 16px -4px rgba(59, 130, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 50%, var(--primary-800) 100%);
}

.calculate-btn:hover::before {
    left: 100%;
}

.calculate-btn:hover::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

.calculate-btn:active {
    transform: translateY(-1px);
    box-shadow: 
        0 4px 8px -2px rgba(59, 130, 246, 0.5),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.calculate-btn img {
    width: 28px;
    height: 28px;
    filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* === 面板头部进一步优化 === */
.panel-header {
    margin-bottom: var(--space-10);
    text-align: center;
    position: relative;
    padding-bottom: var(--space-6);
}

.panel-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-500), var(--secondary-500));
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.panel-header h2 {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: var(--space-3);
    background: linear-gradient(135deg, var(--gray-900), var(--gray-700));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    
    /* 文字增强 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.panel-header p {
    color: var(--gray-600);
    font-size: var(--font-size-lg);
    font-weight: 500;
    line-height: var(--line-height-relaxed);
    
    /* 文字清晰度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* === 结果区域布局优化 === */
.results-content {
    min-height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-8);
}

.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    color: var(--gray-500);
    max-width: 400px;
}

.empty-state img {
    width: 96px;
    height: 96px;
    margin-bottom: var(--space-8);
    opacity: 0.6;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.empty-state h3 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: var(--space-6);
    
    /* 文字增强 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.empty-state p {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    margin: 0 auto;
    font-weight: 500;
    
    /* 文字清晰度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--gray-600);
}

/* === 响应式优化 === */
@media (max-width: 1200px) {
    .ingredients-selector {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .ingredients-selector {
        grid-template-columns: 1fr;
        max-height: 350px;
        padding: var(--space-4);
    }
    
    .ingredient-item {
        padding: var(--space-3);
    }
    
    .ingredient-item img {
        width: 32px;
        height: 32px;
    }
    
    .quantity-input {
        width: 60px;
        padding: var(--space-1) var(--space-2);
    }
    
    .calculate-btn {
        padding: var(--space-5) var(--space-6);
        font-size: var(--font-size-lg);
    }
    
    .panel-header h2 {
        font-size: var(--font-size-2xl);
    }
}

@media (max-width: 640px) {
    .input-group {
        margin-bottom: var(--space-6);
    }
    
    .form-input,
    .form-select {
        padding: var(--space-3) var(--space-4);
    }
    
    .empty-state {
        padding: var(--space-12) var(--space-4);
    }
    
    .empty-state img {
        width: 72px;
        height: 72px;
    }
    
    .empty-state h3 {
        font-size: var(--font-size-xl);
    }
    
    .empty-state p {
        font-size: var(--font-size-base);
    }
}

/* === 加载和交互状态 === */
.calculate-btn.loading {
    background: linear-gradient(135deg, var(--gray-400) 0%, var(--gray-500) 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calculate-btn.loading::before,
.calculate-btn.loading::after {
    display: none;
}

.calculate-btn.loading .loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: var(--space-2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === 高对比度和无障碍优化 === */
@media (prefers-contrast: high) {
    .ingredient-item {
        border: 3px solid #000000;
    }
    
    .calculate-btn {
        background: #000000;
        border: 3px solid #ffffff;
        color: #ffffff;
    }
    
    .form-input,
    .form-select {
        border: 3px solid #000000;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ingredient-item,
    .calculate-btn,
    .form-input,
    .form-select {
        transition: none;
        transform: none;
    }
    
    .calculate-btn::before,
    .calculate-btn::after {
        display: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}
