/* 部门管理样式 */
.search-bar {
    background: #fff;
    padding: 18px;
    margin-bottom: 16px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-form {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.search-item .form-label {
    display: inline-block;
    margin-bottom: 0;
    font-weight: 500;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
    min-width: auto;
    margin-right: 0;
}

.search-item .form-control,
.search-item .form-select {
    width: 180px;
    flex-shrink: 0;
}

/* 输入框和下拉框包装器，用于添加清除按钮 */
.search-item .input-wrapper,
.search-item .select-wrapper {
    position: relative;
    display: inline-block;
    width: 180px;
}

/* 模态框中的input-wrapper */
#deptModal .input-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.input-wrapper .form-control {
    width: 100%;
    padding-right: 30px;
}

.select-wrapper .form-select {
    width: 100%;
    padding-right: 50px; /* 为清除按钮和下拉箭头留出空间 */
}

/* 当select为空值时，显示浅灰色占位符文本 */
.select-wrapper .form-select.placeholder-text {
    color: #999;
}

.select-wrapper .form-select.placeholder-text option:not([disabled]) {
    color: #333;
}

.clear-input {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 12px;
    z-index: 10;
    padding: 4px;
    transition: color 0.2s;
}

.clear-select {
    position: absolute;
    right: 28px; /* 放在下拉箭头左侧 */
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 12px;
    z-index: 10;
    padding: 4px;
    transition: color 0.2s;
}

.clear-input:hover,
.clear-select:hover {
    color: #333;
}

.search-buttons {
    display: flex;
    gap: 8px;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 0;
}

.toolbar .btn {
    padding: 8px 16px;
    font-size: 14px;
}

.content-list {
    background: #fff;
    padding: 0;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

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

.table thead th {
    padding: 12px 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #ebeef5;
    font-size: 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #ebeef5;
    vertical-align: middle;
    font-size: 14px;
}

.table tbody tr:last-child td {
    border-bottom: 1px solid #ebeef5;
}

.table tbody tr:hover {
    background-color: #f5f7fa;
}

.dept-row {
    transition: background-color 0.2s;
}

.dept-name-cell {
    min-width: 300px;
}

.dept-name-wrapper {
    display: flex;
    align-items: center;
    min-height: 24px;
}

.dept-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: #666;
    margin-right: 8px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.dept-toggle:hover {
    color: #333;
}

.dept-toggle i {
    font-size: 12px;
}

.dept-toggle-placeholder {
    display: inline-block;
    width: 20px;
    margin-right: 8px;
    flex-shrink: 0;
}

.dept-name-text {
    flex: 1;
    color: #333;
}

/* 操作链接样式 */
.action-link {
    display: inline-block;
    margin: 0 8px;
    color: #409eff;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.action-link:hover {
    color: #66b1ff;
    text-decoration: none;
}

.action-link i {
    margin-right: 4px;
    font-size: 12px;
}

.action-link-add {
    color: #67c23a;
}

.action-link-add:hover {
    color: #85ce61;
}

.action-link-delete {
    color: #f56c6c;
}

.action-link-delete:hover {
    color: #f78989;
}

/* 状态标签 */
.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
    line-height: 1.5;
    white-space: nowrap;
}

/* 正常状态 - 绿色背景配白色文字，高对比度 */
.badge.bg-success {
    background-color: #52c41a;
    color: #ffffff;
    border: none;
}

/* 停用状态 - 红色背景配白色文字，高对比度 */
.badge.badge-danger {
    background-color: #ff4d4f;
    color: #ffffff;
    border: none;
}

/* 模态框样式 */
.modal-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 16px 20px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.modal-body {
    padding: 24px;
}

.form-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    display: block;
}

/* 确保模态框中的表单字段对齐 */
#deptModal .row .col-md-6 {
    display: flex;
    flex-direction: column;
}

#deptModal .row .col-md-6 .form-label {
    margin-bottom: 8px;
}

#deptModal .row .col-md-6 .input-wrapper,
#deptModal .row .col-md-6 .form-control,
#deptModal .row .col-md-6 .form-select {
    width: 100%;
}

.form-control, .form-select {
    font-size: 14px;
}

/* 按钮样式优化 */
.btn-primary {
    background-color: #409eff;
    border-color: #409eff;
}

.btn-primary:hover {
    background-color: #66b1ff;
    border-color: #66b1ff;
}

.btn-info {
    background-color: #909399;
    border-color: #909399;
}

.btn-info:hover {
    background-color: #a6a9ad;
    border-color: #a6a9ad;
}

.btn-secondary {
    background-color: #909399;
    border-color: #909399;
}

.btn-secondary:hover {
    background-color: #a6a9ad;
    border-color: #a6a9ad;
}

/* 响应式 */
@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-item {
        width: 100%;
    }
    
    .search-buttons {
        margin-left: 0;
        width: 100%;
    }
    
    .search-buttons .btn {
        flex: 1;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .toolbar .btn {
        width: 100%;
    }
    
    .table {
        font-size: 13px;
    }
    
    .action-link {
        display: block;
        margin: 4px 0;
    }
}

/* 上级部门树形选择样式（复用用户管理的样式） */
.custom-dept-select {
    position: relative;
    width: 100%;
}

.dept-select-display {
    position: relative;
    width: 100%;
    height: 36px;
    padding: 6px 50px 6px 11px;
    line-height: 24px;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
    font-size: 13px;
}

.dept-select-display:hover {
    border-color: #c0c4cc;
}

.custom-dept-select.is-open .dept-select-display {
    border-color: #409eff;
}

.dept-selected-text {
    color: #606266;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dept-placeholder {
    color: #999;
    flex: 1;
}

.dept-arrow {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #909399;
    transition: transform 0.3s;
    font-style: normal;
    z-index: 1;
}

.dept-arrow.is-open {
    transform: translateY(-50%) rotate(180deg);
}

.dept-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e4e7ed;
    border-radius: 4px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.dept-tree-container {
    padding: 4px 0;
}

.dept-tree-item {
    position: relative;
}

.dept-tree-node {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 32px;
}

.dept-tree-node:hover {
    background-color: #f5f7fa;
}

.dept-tree-node.is-selected {
    background-color: #ecf5ff;
}

.dept-toggle-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    margin-right: 4px;
    font-size: 10px;
    color: #909399;
    transition: transform 0.3s;
    flex-shrink: 0;
}

.dept-toggle-icon.is-expanded {
    transform: rotate(90deg);
}

.dept-toggle-placeholder {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    flex-shrink: 0;
}

.dept-name {
    flex: 1;
    color: #606266;
    user-select: none;
    font-size: 13px;
}

.dept-name.is-selected {
    color: #409eff;
    font-weight: 500;
}

/* 清除按钮样式 */
#deptModal .input-wrapper {
    position: relative;
    width: 100%;
}

#deptModal .input-wrapper .clear-btn {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    color: #909399;
    font-size: 16px;
    z-index: 2;
    transition: color 0.2s;
}

#deptModal .input-wrapper .clear-btn:hover {
    color: #409eff;
}

#deptModal .custom-dept-select + .clear-btn {
    right: 28px;
}

/* 表单验证错误样式 */
.form-control.is-invalid {
    border-color: #f56c6c;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23f56c6c'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6 .4.4.4-.4m0 4.8-.4-.4-.4.4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #f56c6c;
}

.form-control.is-invalid:focus {
    border-color: #f56c6c;
    box-shadow: 0 0 0 0.2rem rgba(245, 108, 108, 0.25);
}
