/* 全局主题 - 按钮、卡片、表单、弹窗等组件 */

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    user-select: none;
    line-height: 1.5;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 6px;
}

/* ========== 卡片 ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

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

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

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

/* ========== 表格 ========== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: var(--bg-alt);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table thead th:first-child {
    border-top-left-radius: 12px;
}

.table thead th:last-child {
    border-top-right-radius: 12px;
}

.table tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text-secondary);
}

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

.table .actions {
    display: flex;
    gap: 6px;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.pagination span.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========== 弹窗 ========== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-backdrop.show {
    opacity: 1;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.show {
    opacity: 1;
}

.modal-dialog {
    width: 100%;
    max-width: 460px;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

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

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

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 24px 20px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg);
}

/* ========== Toast 通知 ========== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 280px;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #dcfce7;
    color: #16a34a;
}

.toast-error .toast-icon {
    background: #fee2e2;
    color: #dc2626;
}

.toast-warning .toast-icon {
    background: #fef3c7;
    color: #d97706;
}

.toast-info .toast-icon {
    background: #dbeafe;
    color: #2563eb;
}

.toast-text {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.toast-close {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    background: var(--bg-alt);
}

/* ========== 加载 ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.9);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.loading-overlay.show {
    opacity: 1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== 页脚 ========== */
.footer {
    padding: 32px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-light);
    background: var(--surface);
}
