/* Components - 通用组件样式 */

/* ==================== 按钮组 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 11px 28px;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(180deg, #3a8fe8 0%, var(--color-primary) 100%);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #4fa0f0 0%, var(--color-primary-hover) 100%);
    border-color: var(--color-primary-hover);
}

.btn-primary:active {
    background: linear-gradient(180deg, var(--color-primary-active) 0%, #145aa0 100%);
    border-color: var(--color-primary-active);
}

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

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

.btn-default:active {
    background: #e0eef9;
}

.btn-success {
    background: linear-gradient(180deg, #4db860 0%, var(--color-success) 100%);
    color: #fff;
    border-color: var(--color-success);
}

.btn-success:hover {
    background: linear-gradient(180deg, #5cc56f 0%, #48a55a 100%);
}

.btn-danger {
    background: linear-gradient(180deg, #e46b68 0%, var(--color-danger) 100%);
    color: #fff;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #e8827f 0%, #c94542 100%);
}

.btn-link {
    color: var(--color-primary);
    padding: 0;
    background: transparent;
}

.btn-link:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(30%);
}

.btn-group {
    display: inline-flex;
    gap: 8px;
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 18px;
}

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

.form-label.required::before {
    content: '* ';
    color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    transition: all var(--transition-fast);
    color: var(--color-text-primary);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--color-border-dark);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(29, 124, 230, 0.12);
    outline: none;
}

.form-input::placeholder {
    color: var(--color-text-disabled);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.form-hint {
    font-size: 12px;
    color: var(--color-text-weak);
    margin-top: 4px;
}

/* ==================== 菜单样式 ==================== */
.menu-group {
    padding: 14px 18px 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 11px 18px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: var(--sidebar-menu-hover);
    color: var(--sidebar-text-hover);
}

.menu-item.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-menu-active);
    border-left-color: #fff;
}

.menu-icon {
    width: 16px;
    height: 16px;
    margin-right: 12px;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}

.menu-text {
    flex: 1;
    font-size: 13px;
}

.menu-arrow {
    font-size: 10px;
    transition: transform var(--transition-fast);
    color: rgba(255, 255, 255, 0.4);
}

.menu-item.expanded .menu-arrow {
    transform: rotate(90deg);
}

.submenu {
    display: none;
    background: rgba(0, 0, 0, 0.15);
}

.submenu.show {
    display: block;
}

.submenu .menu-item {
    padding-left: 46px;
    font-size: 13px;
}

.submenu .menu-item.active {
    background: rgba(29, 124, 230, 0.8);
}

/* ==================== 表格 ==================== */
.cms-table {
    width: 100%;
    border: 1px solid var(--table-border);
    background: #fff;
    border-collapse: collapse;
}

.cms-table th,
.cms-table td {
    padding: 11px 14px;
    text-align: left;
    border: 1px solid var(--table-border);
    font-size: 13px;
}

.cms-table th {
    background: var(--table-header-bg);
    font-weight: 600;
    color: var(--table-header-text);
    white-space: nowrap;
    border-bottom-width: 2px;
}

.cms-table tbody tr:nth-child(even) {
    background: var(--table-stripe-bg);
}

.cms-table tbody tr:hover {
    background: var(--table-row-hover);
}

.cms-table tbody tr:hover td {
    border-color: #cde2f5;
}

.cms-table .cell-center {
    text-align: center;
}

.cms-table .cell-actions {
    white-space: nowrap;
}

.cms-table .cell-actions a {
    color: var(--color-primary);
    margin-right: 10px;
    font-size: 13px;
    transition: color var(--transition-fast);
}

.cms-table .cell-actions a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.cms-table .cell-actions a:last-child {
    margin-right: 0;
}

.cms-table .cell-actions a.danger {
    color: var(--color-danger);
}

.cms-table .cell-actions a.danger:hover {
    color: #c94542;
}

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 0;
    font-size: 13px;
}

.pagination-info {
    color: var(--color-text-secondary);
}

.pagination-btns {
    display: flex;
    gap: 3px;
}

.page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    z-index: 1;
}

.page-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    font-weight: 500;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==================== 卡片 ==================== */
.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.card-body {
    padding: 18px;
}

/* ==================== 状态标签 ==================== */
.status-tag {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-tag.success {
    background: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid #c5e8ca;
}

.status-tag.warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
    border: 1px solid #f5d9a8;
}

.status-tag.danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid #f0c5c4;
}

.status-tag.info {
    background: var(--color-info-light);
    color: var(--color-info);
    border: 1px solid #b5e4f2;
}

/* ==================== 统计卡片 ==================== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--color-border-dark);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #e8f4fc 0%, #d0e8f9 100%);
    color: var(--color-primary);
}

.stat-icon.green {
    background: linear-gradient(135deg, #edf9ef 0%, #d9f0de 100%);
    color: var(--color-success);
}

.stat-icon.orange {
    background: linear-gradient(135deg, #fef7ec 0%, #fcecd0 100%);
    color: var(--color-warning);
}

.stat-icon.red {
    background: linear-gradient(135deg, #fbefee 0%, #f7dddC 100%);
    color: var(--color-danger);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

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

.stat-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.modal-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
    color: var(--color-text-weak);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-bg-gray);
    color: var(--color-text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--color-bg-gray);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==================== Toast 消息 ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.25s ease;
    min-width: 220px;
    max-width: 360px;
}

.toast.success {
    border-left: 4px solid var(--color-success);
}

.toast.error {
    border-left: 4px solid var(--color-danger);
}

.toast.warning {
    border-left: 4px solid var(--color-warning);
}

.toast.info {
    border-left: 4px solid var(--color-info);
}

.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background: var(--color-success-light);
    color: var(--color-success);
}

.toast.error .toast-icon {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.toast.warning .toast-icon {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.toast.info .toast-icon {
    background: var(--color-info-light);
    color: var(--color-info);
}

.toast-message {
    font-size: 13px;
    color: var(--color-text-primary);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== 加载状态 ==================== */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 20px;
    font-family: monospace;
    color: var(--color-text-disabled);
    margin-bottom: 12px;
    padding: 16px;
    background: var(--color-bg-gray);
    border-radius: 50%;
    display: inline-block;
}

.empty-state-text {
    font-size: 13px;
}

/* ==================== CSS 图标 ==================== */
.menu-icon.home::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 7px solid currentColor;
}

.menu-icon.home::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 3px;
    width: 10px;
    height: 8px;
    border: 2px solid currentColor;
    border-top: none;
}

.menu-icon.tenant::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 1px;
    width: 14px;
    height: 12px;
    border: 2px solid currentColor;
    border-top: none;
}

.menu-icon.tenant::after {
    content: '';
    position: absolute;
    top: 0;
    left: 3px;
    width: 8px;
    height: 4px;
    border: 2px solid currentColor;
    border-bottom: none;
}

.menu-icon.finance::before {
    content: 'Y';
    font-size: 12px;
    font-weight: bold;
    font-style: italic;
    position: absolute;
    top: 1px;
    left: 1px;
}

.menu-icon.system::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.menu-icon.system::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
}

.menu-icon.notice::before {
    content: '';
    position: absolute;
    top: 0;
    left: 3px;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-radius: 2px 2px 0 0;
    border-bottom: none;
}

.menu-icon.notice::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 1px;
    width: 14px;
    height: 3px;
    background: currentColor;
}

.menu-icon.class::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 0;
    width: 16px;
    height: 13px;
    border: 2px solid currentColor;
}

.menu-icon.class::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 4px;
    height: 4px;
    border: 2px solid currentColor;
    border-top: none;
    border-left: none;
}

.menu-icon.member::before {
    content: '';
    position: absolute;
    top: 0;
    left: 3px;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.menu-icon.member::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 14px;
    height: 6px;
    border: 2px solid currentColor;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.menu-icon.monitor::before {
    content: '';
    position: absolute;
    top: 9px;
    left: 0;
    width: 4px;
    height: 5px;
    background: currentColor;
}

.menu-icon.monitor::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 6px;
    width: 4px;
    height: 10px;
    background: currentColor;
}

/* 统计卡片图标 */
.stat-icon i {
    font-style: normal;
    font-weight: bold;
    font-size: 16px;
}

.stat-icon .icon-tenant::before { content: 'T'; }
.stat-icon .icon-check::before { content: '+'; }
.stat-icon .icon-clock::before { content: 'C'; }
.stat-icon .icon-close::before { content: 'X'; }
.stat-icon .icon-class::before { content: 'B'; }
.stat-icon .icon-member::before { content: 'M'; }
.stat-icon .icon-sms::before { content: 'S'; }
.stat-icon .icon-task::before { content: 'D'; }