/* 深色主题样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #0f0f1a;
    color: #e4e4e7;
    line-height: 1.6;
}

body.dark {
    background: #0f0f1a;
    color: #e4e4e7;
}

a {
    color: #818cf8;
    text-decoration: none;
}

a:hover {
    color: #a5b4fc;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: #27272a;
    color: #d4d4d8;
    border: 1px solid #3f3f46;
}

.btn-secondary:hover {
    background: #3f3f46;
    border-color: #52525b;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.btn-block {
    width: 100%;
}

/* 登录页 */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f0f1a 50%);
}

.login-card {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    border: 1px solid #2e2e4a;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #f4f4f5;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #71717a;
    font-size: 0.875rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* 表单 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #a1a1aa;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.75rem 1rem;
    background: #0f0f1a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    color: #e4e4e7;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* 提示 */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fca5a5;
}

/* 布局 */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #1a1a2e;
    border-right: 1px solid #2e2e4a;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #2e2e4a;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f4f4f5;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid #2e2e4a;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: #a1a1aa;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: #252542;
    color: #e4e4e7;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

/* 主内容 */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 1.5rem 2rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.topbar h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #f4f4f5;
}

.topbar-actions {
    display: flex;
    gap: 0.75rem;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #1a1a2e;
    border: 1px solid #2e2e4a;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #f4f4f5;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.875rem;
    color: #71717a;
}

/* 卡片 */
.card {
    background: #1a1a2e;
    border: 1px solid #2e2e4a;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2e2e4a;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #f4f4f5;
}

.card-body {
    padding: 1.5rem;
}

/* 表格 */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid #2e2e4a;
    font-size: 0.875rem;
}

.table th {
    background: #16162a;
    color: #a1a1aa;
    font-weight: 500;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: #252542;
}

.table td.url-cell,
.table td.ua-cell,
.table td.referer-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.short-code {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 0.8125rem;
    font-weight: 500;
}

.link-title {
    font-weight: 500;
    color: #e4e4e7;
    max-width: 180px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.action-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem !important;
    color: #71717a;
}

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.page-info {
    color: #71717a;
    font-size: 0.875rem;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #2e2e4a;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2e2e4a;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f4f4f5;
}

.modal-close {
    background: none;
    border: none;
    color: #71717a;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.modal-close:hover {
    color: #e4e4e7;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #2e2e4a;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 0.875rem 1.25rem;
    background: #16a34a;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 2000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.toast.error {
    background: #dc2626;
}

/* 错误页 */
.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 1rem;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.error-msg {
    font-size: 1.125rem;
    color: #a1a1aa;
    margin-bottom: 1rem;
}

/* 信息行 */
.info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #2e2e4a;
    flex-wrap: wrap;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: #71717a;
    font-size: 0.875rem;
    min-width: 80px;
}

.link-url {
    color: #818cf8;
    word-break: break-all;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 64px;
    }
    
    .sidebar-title,
    .nav-item span:not(:first-child) {
        display: none;
    }
    
    .sidebar-header {
        justify-content: center;
        padding: 1rem;
    }
    
    .nav-item {
        justify-content: center;
        padding: 0.75rem;
    }
    
    .main-content {
        margin-left: 64px;
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .login-card {
        padding: 1.5rem;
    }
}

/* 分类筛选 */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    background: #0f0f1a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    color: #e4e4e7;
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.filter-select:focus {
    border-color: #6366f1;
}

.category-tag {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.form-select {
    padding: 0.75rem 1rem;
    background: #0f0f1a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    color: #e4e4e7;
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    width: 100%;
}

.form-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input {
    padding: 0.625rem 0.875rem;
    background: #0f0f1a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    color: #e4e4e7;
    font-size: 0.875rem;
    outline: none;
    flex: 1;
}

.form-input:focus {
    border-color: #6366f1;
}

/* 分类管理弹窗 */
.category-add-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #16162a;
    border: 1px solid #2e2e4a;
    border-radius: 8px;
    gap: 1rem;
}

.category-item-name {
    color: #e4e4e7;
    font-size: 0.875rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
