/* ===== 主题色变量（可通过 :root 覆盖实现换肤） ===== */
:root {
    --primary: #00695c;
    --secondary: #00897b;
    --accent: #26a69a;
    --light: #80cbc4;
    --bg: #e0f2f1;
    --light-border: #b2dfdb;
    --input-border: #d4e8e5;
    --primary-rgb: 0,105,92;
}

/* ===== 铸造厂数字化管理平台 - 浅青主题 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
    background: var(--bg);
    color: #1a2a3a;
    min-height: 100vh;
    display: flex;
}

/* ===== 左侧边栏 ===== */
.sidebar {
    width: 200px;
    min-width: 200px;
    height: 100vh;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 16px rgba(var(--primary-rgb),0.25);
    padding: 16px 0 12px;
}
.sidebar-item {
    padding: 6px 16px;
    text-align: center;
}
.sidebar-icon {
    font-size: 36px;
    padding-top: 10px;
    padding-bottom: 2px;
    line-height: 1;
}
.sidebar-company {
    font-size: 17px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    padding-bottom: 0;
}
.sidebar-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    letter-spacing: 3px;
    padding-top: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 6px;
}
.sidebar-user {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
}
.user-badge {
    background: rgba(255,255,255,0.18);
    padding: 3px 12px;
    border-radius: 14px;
    font-size: 13px;
}
.role-badge {
    background: #ffd54f;
    color: #3e2723;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: block;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 9px 16px;
    font-size: 14px;
    transition: all 0.2s;
    border-radius: 6px;
    white-space: nowrap;
    text-align: center;
}
.nav-item:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.nav-item.active {
    background: rgba(255,255,255,0.22);
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #ffd54f;
}
.sidebar-logout {
    padding: 10px 16px 0;
    border-top: 1px solid rgba(255,255,255,0.12);
    margin-top: 6px;
}
.logout-btn {
    display: block;
    text-align: center;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid rgba(255,255,255,0.2);
}
.logout-btn:hover { background: rgba(255,0,0,0.2); color: #ffcdd2; border-color: rgba(255,100,100,0.5); }

/* ===== 移动端顶栏（默认隐藏） ===== */
.mobile-topbar {
    display: none;
}

/* ===== 遮罩层（默认隐藏） ===== */
.sidebar-overlay {
    display: none;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
    overflow-y: auto;
    max-height: 100vh;
}

/* ===== 登录页 ===== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary), var(--accent), var(--light));
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 45px 40px 40px;
    width: 450px;
    box-shadow: 0 20px 60px rgba(0,77,64,0.3);
}
.login-box h1 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 26px;
    color: var(--primary);
    white-space: nowrap;
}
.login-box .subtitle {
    text-align: center;
    color: #90a4ae;
    margin-bottom: 30px;
    font-size: 14px;
}
.login-box label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #546e7a;
    font-size: 14px;
}
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--bg);
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 18px;
    transition: border 0.25s, box-shadow 0.25s;
    background: #fafffe;
}
.login-box input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.15);
}
.login-box .btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    letter-spacing: 2px;
}
.login-box .btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb),0.35);
}
.login-box .btn-login:active {
    transform: translateY(0);
}
.login-box .error-msg {
    background: #fce4ec;
    color: #c62828;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    text-align: center;
    border: 1px solid #f8bbd0;
}

/* ===== 通用卡片 ===== */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(var(--primary-rgb),0.08);
    padding: 22px 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(var(--primary-rgb),0.06);
}
.card-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--secondary);
    color: var(--primary);
}
.card-title:before {
    content: "▍";
    margin-right: 6px;
    color: var(--accent);
}

/* ===== 信息栏 ===== */
.product-info-bar {
    background: var(--bg);
    border: 1px solid var(--light);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
}
.product-info-bar.error {
    background: #fff3f3;
    border-color: #ffcdd2;
    color: #c62828;
}
.info-table {
    width: 100%;
    border-collapse: collapse;
}
.info-table th {
    text-align: left;
    padding: 4px 12px 4px 0;
    font-size: 13px;
    color: #78909c;
    white-space: nowrap;
    font-weight: 600;
}
.info-table td {
    padding: 4px 20px 4px 0;
    font-size: 14px;
    font-weight: 700;
    color: #1a2a3a;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 13px;
    color: #546e7a;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    background: #fafffe;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(38,166,154,0.1);
}
.form-group textarea {
    min-height: 60px;
    resize: vertical;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.form-actions {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e0f2f1;
    display: flex;
    gap: 10px;
}

/* ===== 按钮 ===== */
.btn {
    padding: 8px 22px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: var(--primary); box-shadow: 0 3px 10px rgba(0,105,92,0.25); }
.btn-success { background: var(--secondary); color: #fff; }
.btn-success:hover { background: #2e7d32; box-shadow: 0 3px 10px rgba(46,125,50,0.25); }
.btn-danger  { background: #e53935; color: #fff; }
.btn-danger:hover { background: #c62828; box-shadow: 0 3px 10px rgba(198,40,40,0.25); }
.btn-warning { background: #fb8c00; color: #fff; }
.btn-warning:hover { background: #f57c00; box-shadow: 0 3px 10px rgba(245,124,0,0.25); }
.btn-secondary { background: #90a4ae; color: #fff; }
.btn-secondary:hover { background: #78909c; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 4px; }

/* ===== 表格 ===== */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e8f5e9;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid var(--light-border);
    white-space: nowrap;
    color: var(--primary);
    font-size: 13px;
}
.data-table td {
    padding: 8px 14px;
    border-bottom: 1.5px solid #b0bec5;
}
.data-table tr:nth-child(even) td { background: #f5faf9; }
.data-table tr:hover { background: rgba(var(--primary-rgb),0.03); }
.data-table .empty td {
    text-align: center;
    color: #b0bec5;
    padding: 40px;
    font-style: italic;
}

/* ===== 搜索栏 ===== */
.search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}
.search-bar .form-group { margin-bottom: 0; }
.search-bar input,
.search-bar select {
    padding: 7px 12px;
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
.search-bar .btn { height: 36px; }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin: 18px 0;
}
.pagination a,
.pagination span {
    padding: 6px 14px;
    border: 1px solid #d4e8e5;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    color: #546e7a;
    background: #fff;
    transition: all 0.2s;
}
.pagination a:hover { background: var(--bg); border-color: #80cbc4; }
.pagination .active {
    background: var(--secondary);
    color: #fff;
    border-color: #00897b;
}

/* ===== 工序选项卡 ===== */
.step-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--light-border);
    background: rgba(var(--primary-rgb),0.03);
    border-radius: 10px 10px 0 0;
    padding: 8px 12px 0;
}
.step-tab {
    padding: 10px 24px;
    text-decoration: none;
    color: #78909c;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    border-radius: 6px 6px 0 0;
}
.step-tab:hover { color: var(--secondary); background: rgba(0,137,123,0.05); }
.step-tab.active {
    color: var(--primary);
    border-bottom-color: var(--secondary);
    background: #fff;
}

/* ===== 状态标签 ===== */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}
.status-pending { background: #fff8e1; color: #e65100; }
.status-in_progress { background: #e3f2fd; color: #1565c0; }
.status-done { background: #e8f5e9; color: #2e7d32; }

/* ===== 仪表盘统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}
.stat-card {
    background: linear-gradient(135deg, var(--bg), rgba(var(--primary-rgb),0.03));
    border-radius: 12px;
    padding: 24px 20px;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.06);
    text-align: center;
    border: 1px solid var(--light-border);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .number {
    font-size: 34px;
    font-weight: 800;
    color: var(--primary);
}
.stat-card .label {
    font-size: 14px;
    color: #78909c;
    margin-top: 4px;
    font-weight: 600;
}

/* ===== 工艺卡查看 ===== */
.process-params {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}
.process-params .param-item {
    padding: 10px 14px;
    background: rgba(var(--primary-rgb),0.03);
    border: 1px solid #d4e8e5;
    border-radius: 8px;
    transition: border 0.2s;
}
.process-params .param-item:hover { border-color: #80cbc4; }
.process-params .param-label {
    font-size: 12px;
    color: #90a4ae;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.process-params .param-value {
    font-size: 16px;
    font-weight: 700;
    color: #1a2a3a;
    margin-top: 2px;
}
.process-params input,
.process-params textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
}
.process-params input:focus,
.process-params textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb),0.1);
}

/* ===== 图片画廊 ===== */
.file-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.file-gallery .file-item {
    border: 1px solid #d4e8e5;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}
.file-gallery .file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb),0.12);
}
.file-gallery .file-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}
.file-gallery .file-item .file-desc {
    padding: 6px 10px;
    font-size: 12px;
    color: #78909c;
    text-align: center;
    background: rgba(var(--primary-rgb),0.03);
}

/* ===== 消息提示 ===== */
.msg-success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #a5d6a7;
    font-weight: 600;
}
.msg-error {
    background: #ffebee;
    color: #c62828;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #ef9a9a;
    font-weight: 600;
}

/* ===== 移动端适配 (< 1200px) ===== */
@media (max-width: 1199px) {
    body {
        flex-direction: column;
    }

    /* 显示移动端顶栏 */
    .mobile-topbar {
        display: flex;
        align-items: center;
        height: 50px;
        min-height: 50px;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        color: #fff;
        padding: 0 12px;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 200;
        box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.3);
    }
    .hamburger {
        background: none;
        border: none;
        color: #fff;
        font-size: 24px;
        cursor: pointer;
        padding: 4px 6px;
        line-height: 1;
        border-radius: 4px;
    }
    .hamburger:hover { background: rgba(255,255,255,0.15); }
    .mobile-page-title {
        flex: 1;
        font-size: 15px;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .mobile-user {
        font-size: 12px;
        opacity: 0.85;
        white-space: nowrap;
    }
    .mobile-logout {
        color: rgba(255,255,255,0.75);
        text-decoration: none;
        font-size: 12px;
        padding: 4px 8px;
        border: 1px solid rgba(255,255,255,0.3);
        border-radius: 4px;
        white-space: nowrap;
    }
    .mobile-logout:hover { background: rgba(255,0,0,0.2); color: #ffcdd2; }

    /* 侧边栏变为固定抽屉 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
        width: 240px;
        min-width: 240px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    /* 遮罩层 */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }

    /* 禁止 body 滚动（侧边栏打开时） */
    body.sidebar-open {
        overflow: hidden;
    }

    /* 主内容区自适应 */
    .main-content {
        max-height: none;
        padding: 12px;
    }

    /* 表格横向滚动 */
    .table-container {
        -webkit-overflow-scrolling: touch;
    }

    /* 表单在小屏上单列 */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* 搜索栏堆叠 */
    .search-bar {
        flex-direction: column;
    }

    /* 卡片减少内边距 */
    .card {
        padding: 14px 12px;
        margin-bottom: 12px;
    }

    /* 统计卡片单列 */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-card {
        padding: 16px 12px;
    }
    .stat-card .number {
        font-size: 26px;
    }

    /* 工序参数单列 */
    .process-params {
        grid-template-columns: 1fr;
    }

    /* 图片画廊两列 */
    .file-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* ===== 工艺卡打印样式 ===== */
@media print {
    .sidebar, .mobile-topbar, .sidebar-overlay, .search-section, .step-tabs a:not(.active) { display: none !important; }
    .main-content { margin: 0; padding: 0; max-height: none; }
    body { display: block; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}


/* ===== 文件删除按钮 ===== */
.file-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(198,40,40,0.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}
.file-delete:hover {
    background: #c62828;
    transform: scale(1.15);
}
.file-item { position: relative; }

/* 上下移按钮 */
.btn-reorder { color: var(--secondary); text-decoration: none; cursor: pointer; font-size: 13px; }
.btn-reorder:hover { text-decoration: underline; color: var(--primary); }
