/* ═══════════════════════════════════════════════════
   智能供应链管理系统 - 样式表
   ═══════════════════════════════════════════════════ */

:root {
    --primary: #1890ff;
    --primary-dark: #096dd9;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --bg: #f0f2f5;
    --sidebar-bg: #fff;
    --sidebar-hover: #f0f5ff;
    --sidebar-section: #fafafa;
    --sidebar-width: 240px;
    --text: #333;
    --text-light: #666;
    --border: #e8e8e8;
    --radius: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ═══ 登录页 ═══ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
}

/* ═══ 布局 ═══ */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    border-right: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.sidebar-brand h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-nav {
    padding: 8px 0;
}

.nav-section {
    padding: 10px 20px;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    background: #f5f6f8;
    border-top: 1px solid #eee;
    margin-top: 4px;
}
.nav-section::after {
    /* 折叠箭头已移除 */
}

/* 侧边栏已改为固定展开，折叠动画样式已移除 */

.nav-item {
    display: block;
    padding: 10px 24px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    border-radius: 0 6px 6px 0;
    margin: 2px 8px 2px 0;
}

.nav-item:hover {
    color: var(--primary);
    background: var(--sidebar-hover);
    border-left-color: var(--primary);
}

.nav-item.active {
    color: #fff;
    background: var(--primary);
    border-left-color: var(--primary);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: #fff;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-light);
    font-size: 13px;
}

/* 系统切换 */
.sys-switcher { position: relative; }
.sys-switcher-current {
    padding: 4px 12px; border-radius: 4px; border: 1px solid var(--border);
    background: #f0f5ff; color: var(--primary); cursor: pointer;
    font-size: 13px; font-weight: 500;
}
.sys-switcher-dropdown {
    display: none; position: absolute; top: 100%; right: 0;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1); min-width: 180px; z-index: 200;
    padding: 4px 0; margin-top: 4px;
}
.sys-switcher:hover .sys-switcher-dropdown { display: block; }
.sys-switcher-dropdown a {
    display: block; padding: 8px 16px; text-decoration: none; color: var(--text);
    font-size: 13px; transition: background 0.15s;
}
.sys-switcher-dropdown a:hover { background: #f0f5ff; color: var(--primary); }
.sys-switcher-dropdown a.active { background: #e6f7ff; color: var(--primary); font-weight: 600; }

.user-name {
    color: var(--text);
    font-weight: 500;
}

.content {
    padding: 24px;
}

/* ═══ 卡片 ═══ */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-title {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.card-value.alert-value {
    color: var(--danger);
}

.section {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.section h2 {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ═══ 表单 ═══ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}

select.form-control {
    appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
    padding-right: 32px;
}

/* ═══ 按钮 ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    background: #fff;
    color: var(--text);
}

.btn:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover { background: #ff7875; border-color: #ff7875; }

.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-outline:hover { background: #fff2f0; border-color: var(--danger); color: var(--danger); }

/* ═══ 表格 ═══ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.data-table thead {
    background: #fafafa;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #f5f5f5;
}

/* ═══ 工具栏 ═══ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

/* ═══ 提示 ═══ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: var(--danger);
}

.alert-success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: var(--success);
}

/* ═══ 标签 ═══ */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.tag-success { background: #f6ffed; color: var(--success); border: 1px solid #b7eb8f; }
.tag-warning { background: #fffbe6; color: var(--warning); border: 1px solid #ffe58f; }
.tag-danger  { background: #fff2f0; color: var(--danger); border: 1px solid #ffccc7; }
.tag-info    { background: #e6f7ff; color: var(--primary); border: 1px solid #91d5ff; }
.tag-default { background: #fafafa; color: var(--text-light); border: 1px solid var(--border); }

/* ═══ 响应式 ═══ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .dashboard-cards {
        grid-template-columns: 1fr 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .content { padding: 16px; }
}

@media (max-width: 480px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }

    .login-card { padding: 24px; }
}

/* ═══ 模态框 ═══ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; margin: 0; }
.modal-close {
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ═══ 页面说明提示（问号按钮） ═══ */
.help-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}

.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1890ff;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    user-select: none;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.help-btn:hover {
    background: #096dd9;
    transform: scale(1.15);
}

.help-tip {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    padding: 16px 20px;
    min-width: 320px;
    max-width: 480px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-light);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    white-space: normal;
    text-align: left;
}

.help-tip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: #fff;
    border-left: 1px solid #d9d9d9;
    border-top: 1px solid #d9d9d9;
}

.help-tip.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.help-tip strong {
    color: var(--text);
}

@media (max-width: 768px) {
    .help-tip {
        left: 0;
        right: auto;
        transform: translateY(-4px);
        min-width: 260px;
        max-width: calc(100vw - 32px);
    }
    .help-tip.show {
        transform: translateY(0);
    }
    .help-tip::before {
        left: 14px;
    }
}
