/* ================================================================
   CNC 刀具参数管理系统 — 公共主题样式表 v1.0
   适用于：index.html / add_tool_parameter.html / tool_parameters.html / toolpath_detail.html
   ================================================================ */

/* ==================== CSS Variables ==================== */
:root {
    /* 颜色 */
    --primary:        #4f46e5;
    --primary-light:  #6366f1;
    --primary-dark:   #4338ca;
    --primary-bg:     #eef2ff;
    --primary-soft:   rgba(79, 70, 229, 0.08);

    --success:        #059669;
    --success-light:  #ecfdf5;
    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --warning:        #d97706;

    --gray-50:        #f9fafb;
    --gray-100:       #f3f4f6;
    --gray-200:       #e5e7eb;
    --gray-300:       #d1d5db;
    --gray-400:       #9ca3af;
    --gray-500:       #6b7280;
    --gray-700:       #374151;
    --gray-900:       #111827;

    /* 圆角 */
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      18px;
    --radius-full:    9999px;

    /* 阴影 */
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md:      0 6px 20px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03);
    --shadow-lg:      0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

    /* 动画 */
    --transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== Reset ==================== */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%, #f1f5f9 100%);
    color: #111827;
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== Page Header ==================== */
.page-header {
    position: relative;
    padding: 48px 24px 56px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4f46e5 70%, #6366f1 100%);
    color: white;
    text-align: center;
    overflow: hidden;
}
.page-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 50% at 50% -30%, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}
.page-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 50px;
    background: linear-gradient(180deg, transparent 0%, #f1f5f9 100%);
    pointer-events: none;
}
.page-header h1 {
    position: relative;
    margin: 0;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.page-header h1::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    margin: 12px auto 0;
    background: rgba(255,255,255,0.45);
    border-radius: 2px;
}
.page-header .subtitle {
    position: relative;
    margin: 14px auto 0;
    max-width: 600px;
    font-size: 0.98rem;
    opacity: 0.85;
    line-height: 1.7;
}

/* ==================== Main Container ==================== */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: -28px auto 40px;
    padding: 0 20px;
}

/* ==================== Card ==================== */
.card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: all var(--transition);
}
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.6) 0%, transparent 40%);
    pointer-events: none;
    z-index: 1;
}
.card:hover {
    box-shadow: var(--shadow-md);
}

/* ==================== Toolbar ==================== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding: 18px 22px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid #e5e7eb;
    box-shadow: var(--shadow-md);
}
.toolbar .search-box {
    display: inline-flex;
    border: 1.5px solid #d1d5db;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--gray-50);
    transition: all var(--transition);
}
.toolbar .search-box:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.toolbar .search-box input {
    border: none;
    padding: 11px 18px;
    min-width: 220px;
    font-size: 0.9rem;
    outline: none;
    background: transparent;
    color: #111827;
}
.toolbar .search-box input::placeholder { color: var(--gray-400); }
.toolbar .search-box button {
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 0 22px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition);
}
.toolbar .search-box button:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

/* 主按钮（紫色） */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
}

/* 轮廓按钮（紫色幽灵） */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid #c7d2fe;
}
.btn-outline:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

/* 成功按钮（绿色） */
.btn-success {
    background: linear-gradient(135deg, var(--success), #10b981);
    color: #fff;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
    background: linear-gradient(135deg, #047857, var(--success));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

/* 小预览按钮 */
.btn-sm {
    padding: 7px 16px;
    font-size: 0.82rem;
}

/* ==================== Table ==================== */
.table-wrapper {
    position: relative;
    z-index: 2;
    border-radius: var(--radius-lg);
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}
thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, #7c3aed 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 14px 16px;
    text-align: left;
    white-space: nowrap;
    z-index: 3;
}
tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--gray-50); }
tbody tr:hover { background: var(--primary-bg); }

/* ==================== Form Fields ==================== */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.field label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--gray-700);
    letter-spacing: 0.01em;
}
.field label .required {
    color: var(--danger);
    margin-left: 2px;
}
.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--gray-50);
    color: var(--gray-900);
    transition: all var(--transition);
    outline: none;
}
.field input:hover,
.field textarea:hover { border-color: var(--gray-300); background: #fff; }
.field input:focus,
.field textarea:focus {
    border-color: var(--primary-light);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--gray-400); }

/* Number spinner */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { opacity: 1; }

/* ==================== Tags / Chips ==================== */
.custom-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 280px;
}
.custom-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--gray-100);
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
}
.custom-tag .tag-key { color: var(--primary); font-weight: 600; }
.custom-tag .tag-colon { color: var(--gray-400); margin: 0 1px; }
.custom-fields-empty { color: var(--gray-300); font-size: 0.8rem; font-style: italic; }

/* ==================== Overlay / Dialog ==================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 24px;
}
.overlay.show { display: flex; }

.dialog {
    width: min(90vw, 580px);
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    animation: dialogIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes dialogIn {
    from { transform: translateY(24px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==================== Message Box ==================== */
.message-box {
    padding: 11px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
}
.message-box.info    { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }
.message-box.success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.message-box.error   { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

/* ==================== Page Footer ==================== */
.page-footer {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
    font-size: 0.8rem;
}

/* ==================== Section Divider ==================== */
.section-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}
.section-divider .line { flex: 1; height: 1px; background: var(--gray-200); }
.section-divider .label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* ==================== Mobile Responsive ==================== */
@media (max-width: 768px) {
    .page-header {
        padding: 36px 16px 48px;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }
    .page-header .subtitle {
        font-size: 0.88rem;
        max-width: 100%;
    }

    .container {
        margin-top: -24px;
        padding: 0 12px;
    }

    /* 工具栏堆叠 */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-box {
        width: 100%;
    }
    .toolbar .search-box input {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    /* 卡片紧凑 */
    .card {
        padding: 16px;
    }

    /* 表格可滚动 */
    .table-wrapper {
        overflow-x: auto;
    }
    table {
        min-width: 600px;
        font-size: 0.82rem;
    }
    thead th,
    tbody td {
        padding: 10px 12px;
    }

    /* 按钮撑满 */
    .btn {
        justify-content: center;
    }

    /* 表单单列 */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .custom-field-row {
        grid-template-columns: 1fr !important;
    }

    /* 操作区堆叠 */
    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    /* 弹窗 */
    .dialog {
        width: 95vw;
    }
}
