/**
 * 组件样式
 * 可复用的 UI 组件样式
 */

/* ===== 表单组件 ===== */
.form-group {
    position: relative;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

.form-control:disabled {
    background: var(--bg-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-control.is-invalid {
    border-color: var(--accent-color);
}

.form-control.is-valid {
    border-color: var(--primary-color);
}

.form-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

.form-error {
    font-size: 12px;
    color: var(--accent-color);
    margin-top: 5px;
}

/* ===== 复选框和单选 ===== */
.checkbox-label,
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"],
.radio-label input[type="checkbox"],
.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* ===== 加载状态 ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(46, 204, 113, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading-spinner .loading {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ===== 骨架屏 ===== */
.skeleton {
    background: linear-gradient(90deg, 
        var(--bg-light) 25%, 
        #e0e0e0 50%, 
        var(--bg-light) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--border-radius);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    padding: 20px;
    background: white;
    border-radius: var(--border-radius-lg);
}

/* ===== 徽章 ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
}

.badge-primary {
    background: rgba(46, 204, 113, 0.1);
    color: var(--primary-color);
}

.badge-success {
    background: rgba(46, 204, 113, 0.1);
    color: var(--primary-color);
}

.badge-warning {
    background: rgba(243, 156, 18, 0.1);
    color: #f39c12;
}

.badge-danger {
    background: rgba(231, 76, 60, 0.1);
    color: var(--accent-color);
}

.badge-info {
    background: rgba(52, 152, 219, 0.1);
    color: var(--secondary-color);
}

/* ===== 进度条 ===== */
.progress {
    width: 100%;
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar.success {
    background: var(--primary-color);
}

.progress-bar.warning {
    background: #f39c12;
}

.progress-bar.danger {
    background: var(--accent-color);
}

/* ===== 警告框 ===== */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-icon {
    font-size: 20px;
}

.alert-content {
    flex: 1;
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    border-left: 4px solid var(--primary-color);
    color: #27ae60;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border-left: 4px solid #f39c12;
    color: #d68910;
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--accent-color);
    color: #c0392b;
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    border-left: 4px solid var(--secondary-color);
    color: #2980b9;
}

/* ===== 下拉菜单 ===== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 160px;
    padding: 8px 0;
    margin-top: 8px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    margin: 8px 0;
    background: var(--border-color);
}

/* ===== 标签页 ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    color: var(--text-light);
    font-weight: 500;
}

.tab-item:hover {
    color: var(--text-color);
}

.tab-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== 卡片组件 ===== */
.card {
    background: white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    margin-bottom: 10px;
}

.card-text {
    color: var(--text-light);
    line-height: 1.6;
}

/* ===== 头像 ===== */
.avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: var(--shadow);
}

.avatar-sm {
    width: 30px;
    height: 30px;
}

.avatar-lg {
    width: 60px;
    height: 60px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
}

.avatar-group {
    display: flex;
}

.avatar-group .avatar {
    margin-left: -10px;
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

/* ===== 分割线 ===== */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border-color);
    margin: 0 20px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.empty-state-text {
    color: var(--text-light);
    margin-bottom: 20px;
}

/* ===== 工具提示 ===== */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 8px 12px;
    background: var(--text-color);
    color: white;
    font-size: 12px;
    border-radius: var(--border-radius);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}

/* ===== 滚动条美化 ===== */
.custom-scrollbar {
    overflow: auto;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ===== 高亮文本 ===== */
.highlight {
    background: rgba(243, 156, 18, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    color: #d68910;
    font-weight: 500;
}

/* ===== 文本截断 ===== */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== 间距工具类 ===== */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mt-4 { margin-top: 32px !important; }
.mt-5 { margin-top: 40px !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mb-4 { margin-bottom: 32px !important; }
.mb-5 { margin-bottom: 40px !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 8px !important; }
.pt-2 { padding-top: 16px !important; }
.pt-3 { padding-top: 24px !important; }
.pt-4 { padding-top: 32px !important; }
.pt-5 { padding-top: 40px !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 8px !important; }
.pb-2 { padding-bottom: 16px !important; }
.pb-3 { padding-bottom: 24px !important; }
.pb-4 { padding-bottom: 32px !important; }
.pb-5 { padding-bottom: 40px !important; }

/* ===== 文本对齐 ===== */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

/* ===== 字体大小 ===== */
.text-sm { font-size: 12px !important; }
.text-base { font-size: 14px !important; }
.text-lg { font-size: 16px !important; }
.text-xl { font-size: 18px !important; }
.text-2xl { font-size: 24px !important; }

/* ===== 字体颜色 ===== */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: #27ae60 !important; }
.text-warning { color: #f39c12 !important; }
.text-danger { color: var(--accent-color) !important; }
.text-muted { color: var(--text-light) !important; }

/* ===== 背景颜色 ===== */
.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: #27ae60 !important; }
.bg-warning { background-color: #f39c12 !important; }
.bg-danger { background-color: var(--accent-color) !important; }
.bg-light { background-color: var(--bg-light) !important; }
.bg-white { background-color: white !important; }

/* ===== 显示控制 ===== */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

/* ===== 弹性布局 ===== */
.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.justify-start { justify-content: flex-start !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.align-start { align-items: flex-start !important; }
.align-end { align-items: flex-end !important; }
.align-center { align-items: center !important; }
.flex-1 { flex: 1 !important; }

/* ===== 宽度工具 ===== */
.w-100 { width: 100% !important; }
.w-50 { width: 50% !important; }
.w-auto { width: auto !important; }

/* ===== 高度工具 ===== */
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }

/* ===== 定位工具 ===== */
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }

/* ===== z-index ===== */
.z-1 { z-index: 1 !important; }
.z-10 { z-index: 10 !important; }
.z-100 { z-index: 100 !important; }
.z-1000 { z-index: 1000 !important; }

/* ===== 圆角 ===== */
.rounded { border-radius: var(--border-radius) !important; }
.rounded-lg { border-radius: var(--border-radius-lg) !important; }
.rounded-full { border-radius: 50% !important; }
.rounded-none { border-radius: 0 !important; }

/* ===== 阴影 ===== */
.shadow { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-none { box-shadow: none !important; }

/* ===== 溢出控制 ===== */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-scroll { overflow: scroll !important; }

/* ===== 可见性 ===== */
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }

/* ===== 光标 ===== */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }
.cursor-not-allowed { cursor: not-allowed !important; }

/* ===== 用户选择 ===== */
.select-none { user-select: none !important; }
.select-text { user-select: text !important; }

/* ===== 过渡动画 ===== */
.transition { transition: var(--transition) !important; }
.transition-none { transition: none !important; }
