/* ================================================================
   GREEN ERP — 应用自定义样式
   提取自 templates/base.html，2026-05-28
   ================================================================ */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --sidebar-width: 260px;
    --page-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --card-radius: 14px;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
}

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

body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i { color: var(--primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }

.sidebar-section {
    padding: 8px 16px;
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px 4px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    margin: 2px 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
}

.sidebar .nav-link.active {
    background: var(--primary);
    color: #fff;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .nav-link {
    padding: 10px 16px;
    color: var(--sidebar-text);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
}

/* Page Header */
.page-header {
    margin-bottom: 28px;
}

.page-header h4 {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 20px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 22px;
    transition: all 0.2s;
    border: 1px solid rgba(0,0,0,0.03);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 14px;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 8px 16px;
    transition: all 0.2s;
}

.btn:hover { transform: translateY(-1px); }

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

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

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

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: #e2e8f0;
}

.btn-outline-secondary:hover {
    background: #f8fafc;
    color: var(--text-primary);
    border-color: #e2e8f0;
}

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 10px 14px;
    font-size: 0.9rem;
}

/* 全局修复：下拉箭头与文字重叠问题
   Bootstrap5 的 form-select 箭头是 SVG data-URI，绝对定位在右padding区。
   当 select 设 width:auto 时，浏览器只给文字分配刚好宽度，箭头压在文字上。
   解决方案：统一增大 padding-right，再用 min-width 确保 width:auto 的 select
   有足够宽度容纳文字内容 + 箭头空间。 */
.form-select {
    padding-right: 44px !important;
}
.form-select[style*="width: auto"] {
    min-width: 130px !important;
}
.form-select-sm {
    padding-right: 38px !important;
}
.form-select-sm[style*="width: auto"] {
    min-width: 120px !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Tables */
.table {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    margin-bottom: 0;
}

.table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: none;
    padding: 14px 16px;
}

.table tbody td {
    vertical-align: middle;
    padding: 14px 16px;
    border-color: #f1f5f9;
    font-size: 0.9rem;
}

.table tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
    padding: 5px 10px;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }

/* Progress */
.progress {
    border-radius: 10px;
    height: 8px;
    background: #e2e8f0;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* Modal */
.modal-content {
    border-radius: var(--card-radius);
    border: none;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 18px 24px;
}

.modal-title { font-weight: 700; }
.modal-footer { border-top: 1px solid #f1f5f9; }

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
}

.toast-msg {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast-msg.success { border-left: 4px solid var(--success); }
.toast-msg.error { border-left: 4px solid var(--danger); }
.toast-msg.warning { border-left: 4px solid var(--warning); }
.toast-msg.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Mobile Nav Toggle */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1050;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

/* Bottom Tab Nav (Mobile) */
.bottom-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    z-index: 1050;
    padding: 8px 0;
}

.bottom-tabs .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    gap: 2px;
}

.bottom-tabs .tab-item i { font-size: 1.2rem; }
.bottom-tabs .tab-item.active,
.bottom-tabs .tab-item:hover { color: var(--primary); }

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show { transform: translateX(0); }
    .mobile-nav-toggle { display: flex; }
    .main-content {
        margin-left: 0;
        padding: 70px 16px 80px;
    }
    .bottom-tabs { display: flex; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar-overlay.show { display: block; }
}

@media (min-width: 1200px) {
    .main-content { padding: 32px 40px; }
}
