* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 禁用各浏览器的自动暗色渲染，强制以浅色方案解释颜色 */
    color-scheme: light;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* 弹窗开启时，禁止背景滚动并固定视口位置 */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header p {
    opacity: 0.9;
    font-size: 1.1em;
}

.user-info {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
}

.nav-tabs {
    display: flex;
    background: #f7f7f7;
    padding: 10px 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
    color: #333;
}

.tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.content {
    padding: 30px;
    min-height: 400px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s;
}

.tab-content.active {
    display: block;
}

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

/* 搜索栏 */
.search-bar {
    margin-bottom: 30px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 1.1em;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
}

/* 菜品卡片 */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* 紧凑卡片样式 */
.recipe-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding: 10px;
    min-height: 84px;
}

.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

.recipe-info { padding: 0; }

.recipe-name {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipe-category {
    display: inline-block;
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 0.8em;
    color: #666;
}

.recipe-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #999;
    font-size: 0.8em;
    margin-top: auto;
}

/* 菜品详情模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 20px 20px 0 0;
}

.modal-header h2 {
    margin-bottom: 10px;
}

.modal-body {
    padding: 30px;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.detail-section {
    margin-bottom: 30px;
}

.detail-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.ingredient-list {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 10px;
}

.ingredient-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.ingredient-item:last-child {
    border-bottom: none;
}

.step-list {
    counter-reset: step-counter;
}

.step-item {
    position: relative;
    padding-left: 50px;
    margin-bottom: 20px;
    counter-increment: step-counter;
}

.ing-highlight {
    /* 专业配色：清晰的品牌强调色，无发光效果 */
    background: transparent;
    color: #0ea5e9; /* sky-500 */
    font-weight: 700;
}

.ing-amount {
    color: #0369a1; /* sky-700，层级区分 */
    font-weight: 700;
    margin-left: 2px;
}

.step-item::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* 管理员面板 */
.admin-form {
    background: #f8f8f8;
    padding: 30px;
    border-radius: 15px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.ingredient-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

/* 拖拽排序样式 */
.ingredient-input-group[draggable="true"] {
    cursor: move;
    transition: background-color 0.2s;
}

.ingredient-input-group[draggable="true"]:hover {
    background-color: #f5f5f5;
}

.ingredient-input-group[draggable="true"]:active {
    opacity: 0.6;
}

.drag-handle {
    cursor: grab;
    font-size: 18px;
    line-height: 1;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* 防止输入框干扰拖拽 */
.ingredient-input-group input {
    pointer-events: auto;
}

.ingredient-input-group input {
    flex: 1;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
    line-height: 1.2;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.btn-add {
    background: #4CAF50;
    color: white;
    padding: 8px 20px;
    margin-top: 10px;
}

.btn-remove {
    background: #f44336;
    color: white;
    padding: 5px 15px;
}

/* 登录表单 */
.login-form {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* 分享功能 */
.share-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.share-btn {
    padding: 10px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .user-info {
        position: static;
        margin-top: 20px;
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 20px;
    }

    .ingredient-input-group {
        flex-direction: column;
    }

    /* 表单在手机上更易点按 */
    .form-control {
        font-size: 16px; /* iOS 防缩放 */
        padding: 14px 16px;
    }

    /* 顶部三个导航按钮更紧凑 */
    .nav-tabs {
        padding: 8px 12px;
        gap: 6px;
    }
    .nav-tabs .tab-btn {
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 10px;
        flex: 1 1 auto; /* 在小屏自适应压缩 */
    }

    /* 主要操作按钮满宽，便于拇指点击 */
    .admin-form .btn-primary {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        border-radius: 14px;
    }

    /* 分类管理行在手机上换行 */
    #categoryManager > div:first-child {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    #categoryManager input.form-control {
        max-width: 100% !important;
    }

    /* 已添加菜品列表在手机上：名称在左，操作紧凑在右且不换行 */
    #adminRecipeList > div {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    /* 左侧：名称 + 分类 同行，不换行，名称过长省略 */
    #adminRecipeList > div > div:first-child {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        flex: 1 1 auto;
    }
    #adminRecipeList > div > div:first-child strong {
        display: inline-block;
        max-width: 62vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #adminRecipeList > div > div:first-child span {
        white-space: nowrap;
    }
    #adminRecipeList > div > div:last-child {
        display: flex;
        gap: 6px;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    #adminRecipeList .btn {
        padding: 8px 12px;
        border-radius: 10px;
        font-size: 13px;
    }

    /* 强制手机小屏至少两列卡片 */
    .recipe-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .recipe-card { min-height: 80px; }
}

/* 打印样式 */
@media print {
    .nav-tabs, .user-info, .search-bar, .btn, .share-buttons {
        display: none;
    }

    .modal {
        position: static;
        background: none;
    }

    .modal-content {
        box-shadow: none;
    }
}

.success-message {
    background: #4CAF50;
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideDown 0.5s;
}

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


