/*
 * ============================================
 * AI 需求收集系统 - 组件样式
 * ============================================
 * 
 * 按钮、输入框、卡片、标签页等可复用组件
 * 遵循 0045_视觉风格指南.md 规范
 */

/* ============================================
   按钮组件
   ============================================ */

/* 按钮基础样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    /* 10px 20px */
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    user-select: none;
}

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

/* 主要按钮 - 渐变背景 */
.btn-primary {
    color: #FFFFFF;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 82, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-card), 0 4px 12px rgba(0, 82, 255, 0.35);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* 次要按钮 - 透明背景 + 边框 */
.btn-secondary {
    color: var(--foreground);
    background: transparent;
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--muted);
    border-color: var(--muted-foreground);
}

/* 幽灵按钮 - 纯文字 */
.btn-ghost {
    color: var(--muted-foreground);
    background: transparent;
    border: none;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--foreground);
    background: var(--muted);
}

/* 危险按钮 */
.btn-danger {
    color: #FFFFFF;
    background: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

/* 按钮尺寸 */
.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: var(--text-xs);
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: var(--text-base);
}

.btn-full {
    width: 100%;
}

/* 图标按钮 */
.btn-icon {
    padding: 0.625rem;
    border-radius: var(--radius-md);
}

.btn-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ============================================
   输入框组件
   ============================================ */

/* 输入框基础样式 */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--text-sm);
    color: var(--foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.input::placeholder {
    color: var(--muted-foreground);
}

.input:hover:not(:disabled) {
    border-color: var(--muted-foreground);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input:disabled {
    background: var(--muted);
    cursor: not-allowed;
}

/* 输入框错误状态 */
.input-error {
    border-color: var(--error);
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* 输入框成功状态 */
.input-success {
    border-color: var(--success);
}

.input-success:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* 带图标的输入框容器 */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input {
    padding-left: 2.75rem;
}

.input-group .input-icon {
    position: absolute;
    left: 0.875rem;
    color: var(--muted-foreground);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-group:focus-within .input-icon {
    color: var(--accent);
}

.input-group .input-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* 右侧图标 */
.input-group-right .input {
    padding-left: 1rem;
    padding-right: 2.75rem;
}

.input-group-right .input-icon {
    left: auto;
    right: 0.875rem;
}

/* 文本域 */
.textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.875rem 1rem;
    font-size: var(--text-sm);
    color: var(--foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: all var(--transition-fast);
}

.textarea::placeholder {
    color: var(--muted-foreground);
}

.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* 表单标签 */
.label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--foreground);
}

.label-required::after {
    content: " *";
    color: var(--error);
}

/* 表单组 */
.form-group {
    margin-bottom: var(--spacing-lg);
}

/* 表单提示文字 */
.form-hint {
    margin-top: var(--spacing-xs);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.form-error {
    margin-top: var(--spacing-xs);
    font-size: var(--text-xs);
    color: var(--error);
}

/* ============================================
   卡片组件
   ============================================ */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-normal);
}

/* 卡片悬停效果 */
.card-hoverable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
}

/* 卡片内部区域 */
.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
    background: var(--muted);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 卡片标题 */
.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: var(--spacing-sm);
}

.card-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

/* ============================================
   标签页组件 (Tabs)
   ============================================ */

.tabs {
    width: 100%;
}

/* 标签页导航 */
.tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--muted);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
}

.tabs-nav-item {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--muted-foreground);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}

.tabs-nav-item:hover:not(.active) {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.5);
}

.tabs-nav-item.active {
    color: var(--accent);
    background: var(--card);
}

/* 活动标签下划线 */
.tabs-nav-item.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

/* 标签页内容 */
.tabs-content {
    background: var(--card);
}

.tabs-panel {
    padding: var(--spacing-xl);
    display: none;
}

.tabs-panel.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* ============================================
   徽章组件
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    color: var(--accent);
    background: var(--accent-light);
}

.badge-success {
    color: #059669;
    background: #D1FAE5;
}

.badge-warning {
    color: #D97706;
    background: #FEF3C7;
}

.badge-error {
    color: #DC2626;
    background: #FEE2E2;
}

.badge-muted {
    color: var(--muted-foreground);
    background: var(--muted);
}

/* ============================================
   加载状态组件
   ============================================ */

/* 加载旋转器 */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 1.5px;
}

.spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

/* 加载遮罩 */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    z-index: 10;
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, var(--muted) 25%, var(--border) 50%, var(--muted) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--spacing-sm);
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

/* ============================================
   消息提示组件
   ============================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.alert-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.alert-info {
    color: #1E40AF;
    background: #DBEAFE;
}

.alert-success {
    color: #166534;
    background: #DCFCE7;
}

.alert-warning {
    color: #A16207;
    background: #FEF9C3;
}

.alert-error {
    color: #991B1B;
    background: #FEE2E2;
}

/* ============================================
   分割线
   ============================================ */

.divider {
    height: 1px;
    background: var(--border);
    margin: var(--spacing-lg) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border);
    margin: 0 var(--spacing-md);
}

/* 带文字的分割线 */
.divider-text {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.divider-text::before,
.divider-text::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-text span {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

/* ============================================
   头像组件
   ============================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
    font-size: var(--text-sm);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: var(--text-lg);
}

/* ============================================
   工具提示 (Tooltip) - 纯 CSS
   ============================================ */

.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.75rem;
    font-size: var(--text-xs);
    color: #FFFFFF;
    background: var(--foreground);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    z-index: 100;
}

.tooltip::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--foreground);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    margin-bottom: 0;
    z-index: 100;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   表格组件
   ============================================ */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    background: var(--muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

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

/* ============================================
   空状态组件
   ============================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    color: var(--muted-foreground);
    margin-bottom: var(--spacing-lg);
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   模态框组件
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elevated);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: var(--spacing-xs);
    line-height: 1;
}

.modal-close:hover {
    color: var(--foreground);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
    background: var(--muted);
}

/* 详情区块 */
.detail-section {
    margin-bottom: var(--spacing-lg);
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-content {
    background: var(--muted);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}




.markdown-content {
    font-family: var(--font-family);
    line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-content p {
    margin-bottom: 1em;
}

.modal-xl {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-content p {
    margin-bottom: 1em;
}

.modal-xl {
    max-width: none;
    width: 80vw;
    height: 80vh;
}

/* ============================================
   Sidebar Navigation Component (Migrated from admin.css)
   ============================================ */
.sidebar {
    width: 280px;
    /* Fixed width var(--sidebar-width) usually 280px */
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: var(--spacing-lg);
}

.sidebar-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
    color: var(--foreground);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
    margin-bottom: var(--spacing-xs);
}

.sidebar-link:hover {
    background: var(--muted);
    color: var(--accent);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-link-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

/* User Info in Sidebar */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    margin-top: var(--spacing-xs);
}

/* Admin Badge & Visibility */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    background: linear-gradient(135deg, #EF4444 0%, #F97316 100%);
    color: white;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-only {
    display: block;
}

/* Responsive Sidebar */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}


.modal-xl .modal-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-subheader {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-xs) var(--spacing-lg);
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

.modal-subheader-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.view-toggle {
    display: flex;
    align-items: center;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.view-toggle-btn {
    padding: 4px 12px;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--muted-foreground);
    transition: all var(--transition-fast);
}

.view-toggle-btn.active {
    background: white;
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.code-view {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
    background: #1e293b;
    color: #e2e8f0;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    overflow: auto;
    white-space: pre-wrap;
    height: 100%;
}