/* frontend/style.css (V5.7 - 均匀红框光晕版) */

/* ==========================================================================
   1. 全局样式与变量
   ========================================================================== */
:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --text-main: #333333;
    --text-sub: #666666;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --border-color: #e8e8e8;
    --border-radius: 6px;
    
    /* 重复文案颜色 */
    --duplicate-red: #ff4d4f; 
}

html { scroll-behavior: smooth; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color); 
    color: var(--text-main); 
    margin: 0; 
    line-height: 1.6; 
    font-size: 14px; 
}
* { box-sizing: border-box; }

/* ==========================================================================
   2. 布局容器
   ========================================================================== */
.login-container { display: flex; align-items: center; justify-content: center; height: 100vh; background: #fff; }
.login-box { width: 100%; max-width: 380px; padding: 40px; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); text-align: center; }
.login-box h1 { margin-top: 0; margin-bottom: 30px; font-size: 1.8em; color: var(--primary-color); }

.app-container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 25px; background: var(--card-bg); border-radius: var(--border-radius); margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.logo { font-size: 1.4em; font-weight: bold; color: var(--primary-color); }

/* ==========================================================================
   3. 通用组件
   ========================================================================== */
.card { background: var(--card-bg); border-radius: var(--border-radius); padding: 24px; margin-bottom: 24px; border: 1px solid var(--border-color); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.card-header h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-main); }

.btn { display: inline-block; border: 1px solid transparent; padding: 6px 16px; border-radius: 4px; font-size: 14px; cursor: pointer; transition: all 0.3s; outline: none; background: #fff; }
.btn:hover { opacity: 0.8; }
.btn-primary { background-color: var(--primary-color); color: #fff; }
.btn-secondary { border-color: #d9d9d9; color: var(--text-main); } .btn-secondary:hover { color: var(--primary-color); border-color: var(--primary-color); }
.btn-danger { background-color: #ff4d4f; color: #fff; }
.btn-success { background-color: #52c41a; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* 表单 */
.create-job-grid { display: grid; grid-template-columns: 1fr 150px; gap: 20px; align-items: flex-end; }
.form-group { margin-bottom: 20px; }
label { display: block; font-weight: 500; margin-bottom: 8px; }
input, textarea { width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 4px; transition: all 0.3s; outline: none; }
input:focus, textarea:focus { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(24,144,255,0.2); }
textarea { resize: vertical; }

/* 仪表盘 */
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: center; }
.dashboard-stat { padding: 24px; background: #fbfbfb; border-radius: var(--border-radius); border: 1px solid #f0f0f0; }
.dashboard-value { font-size: 30px; font-weight: bold; color: var(--primary-color); line-height: 1.2; }
.dashboard-label { font-size: 14px; color: var(--text-sub); margin-top: 8px; }

/* 导航 */
.main-nav { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.nav-btn { background: none; border: none; padding: 10px 20px; cursor: pointer; font-size: 14px; color: var(--text-main); position: relative; bottom: -1px; }
.nav-btn.active { color: var(--primary-color); font-weight: 600; border-bottom: 2px solid var(--primary-color); }
.view { display: none; } .view.active { display: block; }

/* ==========================================================================
   4. 任务列表
   ========================================================================== */
.job-item { 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    margin-bottom: 16px; 
    background: #fff;
    transition: box-shadow 0.3s;
}
.job-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.05); }

.job-item-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; cursor: pointer; }
.job-header-left { display: flex; flex-direction: column; gap: 8px; }
.job-title { font-size: 16px; font-weight: 600; color: var(--primary-color); }
.job-stats-info { font-size: 12px; color: #999; display: flex; gap: 15px; }
.job-stats-info span { display: inline-block; }

.job-header-right { display: flex; align-items: center; gap: 12px; }
.job-status-tag { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: #f5f5f5; border: 1px solid #d9d9d9; color: #666; }
.job-actions { display: flex; gap: 8px; }

.job-texts-container { display: none; padding: 24px; background: #fafafa; border-top: 1px solid var(--border-color); }
.job-item.open .job-texts-container { display: block; }

/* ==========================================================================
   5. 文案卡片 (V5.7 修正版)
   ========================================================================== */
.texts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.text-card-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); 
    gap: 20px; 
}

.text-card { 
    background: #fff; 
    /* 默认灰色细边框 */
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    padding: 16px; 
    position: relative; 
    transition: all 0.3s;
}

/* ★★★ 重复文案：均匀分布的红色边框 + 红色柔光 ★★★ */
.text-card.duplicate {
    /* 1. 边框变红，均匀的 */
    border: 1px solid #ffccc7; 
    
    /* 2. 四周添加红色柔光阴影，也是均匀的 */
    box-shadow: 0 0 12px rgba(255, 77, 79, 0.15);
    
    /* 3. 去掉之前的伪元素和 mask 代码，解决报错 */
    z-index: 1;
}

/* 重复标签：紧贴左上角 */
.badge-duplicate {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--duplicate-red);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--border-radius) 0 6px 0;
    font-weight: bold;
    z-index: 10;
    /* 标签本身的小阴影 */
    box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.text-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; margin-top: 5px; }
.text-card-title { font-weight: 600; color: var(--text-main); font-size: 14px; margin-left: 5px; }

/* ★★★ 文案内容：固定 450px 高度，隐藏滚动条 ★★★ */
.text-card-content { 
    background: #fff;
    border: 1px solid #f5f5f5; 
    border-radius: 4px;
    padding: 12px;
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 12px;

    /* 高度固定 350px */
    height: 250px;
    overflow-y: auto;
    
    /* 隐藏滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.text-card-content::-webkit-scrollbar { display: none; }

.text-card-footer { display: flex; justify-content: space-between; font-size: 12px; color: #999; }
.assigned-devices-wrapper { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #f0f0f0; }
.assigned-devices-wrapper strong { display: block; font-size: 12px; color: #333; margin-bottom: 6px; font-weight: 600; }
.assigned-devices-list { display: flex; flex-wrap: wrap; gap: 6px; }
.assigned-devices-list code { 
    background: #f5f5f5; color: #666; padding: 2px 8px; border-radius: 2px; font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.assigned-devices-list code:hover { background: var(--primary-color); color: #fff; }

/* ==========================================================================
   6. 表格与其他
   ========================================================================== */
.table-wrapper { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background-color: #fafafa; font-weight: 600; color: var(--text-main); padding: 12px; border-bottom: 1px solid var(--border-color); }
td { padding: 12px; border-bottom: 1px solid var(--border-color); color: #666; }
tbody tr.highlight { animation: highlight-row 2s ease-out; }
@keyframes highlight-row { 0% { background-color: #fffbe6; } 100% { background-color: transparent; } }
.device-id { font-family: monospace; background: #f0f2f5; padding: 2px 6px; border-radius: 4px; color: #333; }

/* 弹窗与加载 */
.modal-overlay { position: fixed; inset: 0; background-color: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: #fff; width: 500px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.modal-header { padding: 16px 24px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; text-align: right; }
.close-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: #999; }
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.spinner { width: 32px; height: 32px; border: 3px solid #e8e8e8; border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 10px 20px; border-radius: 4px; color: #fff; background: rgba(0,0,0,0.8); animation: slideIn 0.3s, fadeOut 0.3s 3s forwards; }
.toast.success { background: #52c41a; } .toast.error { background: #ff4d4f; } .toast.warning { background: #faad14; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }
.hidden { display: none !important; }