/* =====================================================================
   Lacrima 后台主题（基于 Bootstrap 5，Tabler/Boomerang 风格融合）
   设计灵感：
     - https://mb.bootcss.com/themes/boomerang/index.html
     - http://192.168.1.122:5050
   ===================================================================== */
:root {
    --lacrima-bg: #f5f7fb;
    --lacrima-card: #ffffff;
    --lacrima-border: #e6e8ee;
    --lacrima-primary: #206bc4;
    --lacrima-primary-light: #467fd1;
    --lacrima-text: #1f2937;
    --lacrima-muted: #6b7280;
    --lacrima-sidebar-bg: #1e293b;
    --lacrima-sidebar-text: #cbd5e1;
    --lacrima-sidebar-active: #206bc4;
    --lacrima-success: #16a34a;
    --lacrima-warn: #d97706;
    --lacrima-danger: #dc2626;
}

* { box-sizing: border-box; }

body.lacrima-body {
    margin: 0;
    background: var(--lacrima-bg);
    color: var(--lacrima-text);
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    min-height: 100vh;
}

/* ===== 主体布局：Sidebar + Main ===== */
.lacrima-app {
    display: flex;
    min-height: 100vh;
}
.lacrima-sidebar {
    width: 230px;
    background: var(--lacrima-sidebar-bg);
    color: var(--lacrima-sidebar-text);
    flex-shrink: 0;
    transition: width .2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.lacrima-sidebar.collapsed { width: 64px; }
.lacrima-sidebar.collapsed .lacrima-title,
.lacrima-sidebar.collapsed .lacrima-menu-link span { display: none; }
.lacrima-sidebar.collapsed .lacrima-brand { justify-content: center; padding: 14px 0; }
.lacrima-sidebar.collapsed .lacrima-menu-link { justify-content: center; padding: 12px 0; }

.lacrima-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-weight: 600;
    color: #fff;
}
.lacrima-logo {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--lacrima-primary);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.lacrima-title { color: #fff; font-size: 16px; }

.lacrima-menu {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}
.lacrima-menu-link {
    color: var(--lacrima-sidebar-text);
    text-decoration: none;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
    transition: background .15s;
    cursor: pointer;
}
.lacrima-menu-link i { width: 18px; text-align: center; }
.lacrima-menu-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.lacrima-menu-link.active {
    background: rgba(32,107,196,.15);
    color: #fff;
    border-left-color: var(--lacrima-primary);
}

.lacrima-main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ===== 顶栏 ===== */
.lacrima-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--lacrima-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    position: sticky;
    top: 0;
    z-index: 5;
}
.lacrima-toggle {
    background: transparent;
    border: 1px solid var(--lacrima-border);
    border-radius: 6px;
    width: 36px; height: 36px;
    color: var(--lacrima-muted);
    cursor: pointer;
}
.lacrima-toggle:hover { color: var(--lacrima-primary); }
.lacrima-topbar-title { font-weight: 600; flex: 1; }
.lacrima-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--lacrima-muted);
}
.lacrima-user-name {
    color: var(--lacrima-text);
    font-weight: 500;
}
.lacrima-user-roles {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}
.lacrima-user-roles .role-tag {
    background: rgba(32,107,196,.1);
    color: var(--lacrima-primary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.lacrima-main {
    flex: 1;
    padding: 24px;
}
.lacrima-footer {
    padding: 14px 24px;
    text-align: center;
    color: var(--lacrima-muted);
    font-size: 12px;
    border-top: 1px solid var(--lacrima-border);
    background: #fff;
}

/* ===== 卡片 ===== */
.lacrima-card {
    background: var(--lacrima-card);
    border: 1px solid var(--lacrima-border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
    margin-bottom: 16px;
}
.lacrima-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--lacrima-border);
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 仪表盘统计卡 */
.lacrima-stat {
    background: #fff;
    border: 1px solid var(--lacrima-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.lacrima-stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
}
.lacrima-stat-icon.bg-primary { background: var(--lacrima-primary); }
.lacrima-stat-icon.bg-success { background: var(--lacrima-success); }
.lacrima-stat-icon.bg-warning { background: var(--lacrima-warn); }
.lacrima-stat-icon.bg-danger  { background: var(--lacrima-danger); }
.lacrima-stat-icon.bg-info    { background: #0ea5e9; }
.lacrima-stat-label { color: var(--lacrima-muted); font-size: 13px; }
.lacrima-stat-value { font-size: 22px; font-weight: 700; }

/* ===== 居中表单卡片（登录/注册/忘记密码） ===== */
.lacrima-auth-wrap {
    min-height: calc(100vh - 56px - 50px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lacrima-auth-card {
    width: 100%;
    max-width: 420px;
    margin-bottom: 0;
}

/* ===== 表格 ===== */
.lacrima-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--lacrima-border);
}
.lacrima-table th, .lacrima-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--lacrima-border);
    font-size: 14px;
    text-align: left;
}
.lacrima-table thead { background: #f8fafc; color: #475569; font-weight: 600; }
.lacrima-table tbody tr:hover { background: #f9fafb; }

.lacrima-toolbar {
    margin-bottom: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--lacrima-border);
}
.lacrima-pager {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== 状态徽章 ===== */
.lacrima-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #e5e7eb;
    color: #374151;
}
.lacrima-tag.success { background: #d1fae5; color: #047857; }
.lacrima-tag.danger  { background: #fee2e2; color: #b91c1c; }
.lacrima-tag.warning { background: #fef3c7; color: #92400e; }
.lacrima-tag.info    { background: #dbeafe; color: #1d4ed8; }
.lacrima-tag.primary { background: rgba(32,107,196,.12); color: var(--lacrima-primary); }

/* ===== 提示框 ===== */
.lacrima-toast {
    position: fixed;
    top: 70px; right: 20px;
    z-index: 9999;
    min-width: 280px;
}
.lacrima-toast .alert { padding: 10px 16px; border-radius: 8px; margin-bottom: 8px; }

/* ===== 通用 ===== */
.lacrima-body .form-control,
.lacrima-body .form-select { max-width: 100%; }

.btn-lacrima {
    background: var(--lacrima-primary);
    color: #fff;
    border: 1px solid var(--lacrima-primary);
}
.btn-lacrima:hover { background: #195aa5; color: #fff; }
.btn-lacrima:disabled { opacity: .6; }

.btn-lacrima-outline {
    background: transparent;
    color: var(--lacrima-primary);
    border: 1px solid var(--lacrima-primary);
}
.btn-lacrima-outline:hover { background: var(--lacrima-primary); color: #fff; }

/* ===== 模态框（用于新增/编辑） ===== */
.lacrima-modal-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lacrima-modal-mask.show { display: flex; }
.lacrima-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.lacrima-modal-header,
.lacrima-modal-footer {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--lacrima-border);
}
.lacrima-modal-footer {
    border-top: 1px solid var(--lacrima-border);
    border-bottom: none;
    justify-content: flex-end;
    gap: 8px;
}
.lacrima-modal-body { padding: 18px; }
.lacrima-modal-close {
    background: transparent; border: 0; font-size: 18px; color: var(--lacrima-muted); cursor: pointer;
}

/* ===== 权限多选框 ===== */
.lacrima-perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}
.lacrima-perm-item {
    border: 1px solid var(--lacrima-border);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}
.lacrima-perm-module {
    font-weight: 600;
    margin-top: 10px;
    color: var(--lacrima-muted);
    font-size: 12px;
}

/* ===== 权限下拉（关联权限编码） ===== */
.lacrima-perm-select {
    position: relative;
    width: 100%;
}
.lacrima-perm-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    background: #fff;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 13px;
}
.lacrima-perm-select-trigger:focus {
    outline: none;
    border-color: var(--lacrima-primary, #2d6cdf);
    box-shadow: 0 0 0 2px rgba(45, 108, 223, .15);
}
.lacrima-perm-select-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--lacrima-text, #1f2937);
}
.lacrima-perm-select-arrow {
    font-size: 11px;
    color: var(--lacrima-muted, #64748b);
    transition: transform .15s ease;
    margin-left: 8px;
    flex-shrink: 0;
}
.lacrima-perm-select.open .lacrima-perm-select-arrow {
    transform: rotate(180deg);
}
.lacrima-perm-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid var(--lacrima-border, #e5e7eb);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
    max-height: 320px;
    overflow: hidden;
    flex-direction: column;
}
.lacrima-perm-select.open .lacrima-perm-select-dropdown {
    display: flex;
}
.lacrima-perm-select-status {
    padding: 12px;
    text-align: center;
    color: var(--lacrima-muted, #64748b);
    font-size: 13px;
}
.lacrima-perm-select-list {
    overflow-y: auto;
    max-height: 320px;
}
.lacrima-perm-select-empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--lacrima-muted, #64748b);
    font-size: 13px;
}
.lacrima-perm-select-group + .lacrima-perm-select-group {
    border-top: 1px solid var(--lacrima-border, #e5e7eb);
}
.lacrima-perm-select-group-title {
    padding: 8px 12px;
    background: #f8fafc;
    color: var(--lacrima-muted, #64748b);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--lacrima-border-light, #f1f5f9);
}
.lacrima-perm-select-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background .12s ease;
}
.lacrima-perm-select-item:hover {
    background: var(--lacrima-primary-light, #eef2ff);
}
.lacrima-perm-select-item-name {
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lacrima-perm-select-item-code {
    color: var(--lacrima-muted, #64748b);
    font-size: 11px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .lacrima-perm-select-dropdown { max-height: 240px; }
    .lacrima-perm-select-list { max-height: 240px; }
}

/* ===== 菜单树 ===== */
.lacrima-menu-tree { padding-left: 0; }
.lacrima-menu-tree .lacrima-menu-row {
    border-bottom: 1px solid var(--lacrima-border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lacrima-menu-tree .lacrima-menu-row.level-1 { padding-left: 32px; background: #fafbfc; }

/* 响应式 */
@media (max-width: 768px) {
    .lacrima-sidebar { position: fixed; transform: translateX(-100%); z-index: 1000; }
    .lacrima-sidebar.show { transform: translateX(0); }
    .lacrima-main { padding: 12px; }
}