/* ========================================
   ShortURL - 现代化浅色调设计
   兼容主流浏览器
   ======================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f0f2f5;
    --bg-white: #ffffff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-lg: 16px;
    --radius-sm: 6px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    --transition: all 0.2s ease;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---- Container ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; font-family: var(--font);
    cursor: pointer; transition: var(--transition); line-height: 1.4;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e8eaed; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-large { padding: 14px 28px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }
.btn-icon {
    width: 32px; height: 32px; padding: 0; border: none; background: transparent;
    cursor: pointer; border-radius: var(--radius-sm); display: inline-flex;
    align-items: center; justify-content: center; font-size: 14px;
    transition: var(--transition); color: var(--text-muted);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.spinner {
    display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 0;
    position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px;
}
.navbar-brand {
    display: flex; align-items: center; gap: 8px;
    font-size: 20px; font-weight: 700; color: var(--text);
    text-decoration: none;
}
.brand-icon { font-size: 24px; }
.navbar-links { display: flex; gap: 8px; }

/* ---- Hero ---- */
.hero {
    padding: 64px 0 48px;
    text-align: center;
    background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}
.hero-title {
    font-size: 42px; font-weight: 800; letter-spacing: -0.5px;
    color: var(--text); margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-desc {
    font-size: 17px; color: var(--text-secondary); max-width: 480px;
    margin: 0 auto 36px;
}

/* ---- Create Card ---- */
.create-card {
    background: var(--bg-white); border-radius: var(--radius-lg);
    padding: 32px; box-shadow: var(--shadow-lg); max-width: 680px;
    margin: 0 auto; text-align: left;
    border: 1px solid var(--border-light);
}
.input-row { margin-bottom: 8px; }
.input-group-large {
    display: flex; gap: 8px;
}
.input-group-large input {
    flex: 1; padding: 14px 18px; border: 2px solid var(--border);
    border-radius: var(--radius); font-size: 15px; font-family: var(--font);
    outline: none; transition: var(--transition);
    background: var(--bg);
}
.input-group-large input:focus {
    border-color: var(--primary); background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.input-group-large input::placeholder { color: var(--text-muted); }

/* ---- Advanced Options ---- */
.advanced-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 0; font-size: 13px; color: var(--text-secondary);
    cursor: pointer; user-select: none;
}
.advanced-toggle:hover { color: var(--primary); }
.toggle-arrow { font-size: 10px; transition: transform 0.2s; }
.toggle-arrow.open { transform: rotate(180deg); }
.advanced-options {
    padding: 16px 0 0;
    animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.form-group input, .form-group select {
    padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
    outline: none; transition: var(--transition);
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-hint strong { color: var(--primary); }

/* ---- Result Card ---- */
.result-card {
    margin-top: 20px; padding: 20px; background: var(--success-bg);
    border-radius: var(--radius); border: 1px solid #d1fae5;
    animation: slideDown 0.3s ease;
}
.result-header { margin-bottom: 12px; }
.result-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 14px; font-weight: 600; color: var(--success);
}
.result-url-box {
    display: flex; gap: 8px; margin-bottom: 8px;
}
.result-url-input {
    flex: 1; padding: 10px 14px; background: var(--bg-white);
    border: 1px solid #d1fae5; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 500; color: var(--primary);
    outline: none; font-family: var(--font);
}
.result-original {
    font-size: 13px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Stats Row ---- */
.stats-row {
    display: flex; justify-content: center; gap: 48px;
    margin-top: 48px; padding-top: 24px;
}
.stat-item { text-align: center; }
.stat-number {
    display: block; font-size: 32px; font-weight: 800;
    color: var(--text); letter-spacing: -0.5px;
}
.stat-label {
    font-size: 14px; color: var(--text-secondary); margin-top: 2px;
}

/* ---- Features ---- */
.features { padding: 64px 0 80px; }
.features-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
.feature-card {
    background: var(--bg-white); padding: 32px 24px;
    border-radius: var(--radius-lg); border: 1px solid var(--border);
    text-align: center; transition: var(--transition);
}
.feature-card:hover {
    transform: translateY(-4px); box-shadow: var(--shadow-md);
    border-color: transparent;
}
.feature-icon { font-size: 36px; margin-bottom: 16px; }
.feature-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ---- Footer ---- */
.footer {
    padding: 24px 0; text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 13px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; background: var(--bg);
}
.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
    background: var(--bg-white); border-radius: var(--radius-lg);
    padding: 40px 36px; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}
.login-header {
    text-align: center; margin-bottom: 28px;
}
.login-header .brand-icon { font-size: 36px; display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .form-group { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.login-form input {
    padding: 12px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 15px; font-family: var(--font);
    outline: none; transition: var(--transition);
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.login-footer {
    text-align: center; margin-top: 20px; padding-top: 16px;
    border-top: 1px solid var(--border-light);
}
.login-footer a { font-size: 13px; color: var(--text-secondary); }
.login-footer a:hover { color: var(--primary); }

.alert {
    padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.settings-form { max-width: 560px; }
.settings-input { width: 100%; padding: 12px 14px; font-size: 15px; }

/* ============================================
   ADMIN LAYOUT
   ============================================ */
.admin-page {
    display: flex; min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px; background: var(--bg-white); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 8px;
    padding: 20px 20px; font-size: 18px; font-weight: 700;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-brand .brand-icon { font-size: 22px; }
.sidebar-nav {
    flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
    transition: var(--transition); text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer {
    padding: 12px 10px; border-top: 1px solid var(--border-light);
}

/* Main Content */
.main-content {
    flex: 1; margin-left: 240px; padding: 28px 32px;
    max-width: 100%;
}
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 14px; }

/* ---- Cards ---- */
.card {
    background: var(--bg-white); border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: center;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-white); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border-light); box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-card-value {
    display: block; font-size: 26px; font-weight: 700;
    letter-spacing: -0.5px; line-height: 1.2;
}
.stat-card-label {
    font-size: 13px; color: var(--text-secondary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px;
    margin-bottom: 20px;
}

/* ---- Bar Chart ---- */
.bar-chart {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 12px; height: 200px; padding: 8px 0;
}
.bar-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 6px; height: 100%;
    justify-content: flex-end;
}
.bar-fill {
    width: 100%; max-width: 48px;
    background: linear-gradient(180deg, var(--primary) 0%, #818cf8 100%);
    border-radius: 6px 6px 2px 2px; min-height: 4px;
    transition: height 0.5s ease;
}
.bar-value {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.bar-label {
    font-size: 12px; color: var(--text-muted);
}

/* ---- Top Links ---- */
.top-links-list { display: flex; flex-direction: column; gap: 10px; }
.top-link-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 0;
}
.top-link-item:not(:last-child) { border-bottom: 1px solid var(--border-light); padding-bottom: 12px; }
.rank {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--bg); display: flex; align-items: center;
    justify-content: center; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); flex-shrink: 0;
}
.top-link-item:nth-child(1) .rank { background: #fef3c7; color: #d97706; }
.top-link-item:nth-child(2) .rank { background: #f1f5f9; color: #64748b; }
.top-link-item:nth-child(3) .rank { background: #fed7aa; color: #c2410c; }
.link-info { flex: 1; min-width: 0; }
.link-code { font-size: 14px; font-weight: 600; color: var(--primary); }
.link-url { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-clicks { font-size: 14px; font-weight: 600; color: var(--text); }

/* ---- Data Table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 12px 16px; text-align: left; font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    font-size: 14px; vertical-align: middle;
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .text-ellipsis {
    max-width: 300px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ---- Link Cells ---- */
.link-code-cell {
    display: flex; align-items: center; gap: 6px;
}
.link-url-cell { max-width: 300px; }
.link-title {
    font-size: 14px; font-weight: 500; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 280px;
}
.link-url-small {
    font-size: 12px; color: var(--text-muted); display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-url-small:hover { color: var(--primary); }
.btn-copy-small { font-size: 12px; }

/* ---- Badge ---- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 500;
    background: var(--bg); color: var(--text-secondary);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--bg); color: var(--text-muted); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---- Action Buttons ---- */
.action-btns { display: flex; flex-direction: row; gap: 6px; flex-wrap: nowrap; }
.action-btns .btn { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-white); white-space: nowrap; }
.action-btns .btn:hover { background: var(--bg); }
.action-btns .btn-danger-ghost { border-color: #fecaca; color: var(--danger); }
.action-btns .btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.filter-input {
    padding: 8px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
    outline: none; min-width: 260px; transition: var(--transition);
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.filter-select {
    padding: 8px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
    outline: none; background: var(--bg-white); cursor: pointer;
    transition: var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-link {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text-secondary); text-decoration: none;
    transition: var(--transition);
}
.page-link:hover { background: var(--bg); text-decoration: none; border-color: var(--primary); color: var(--primary); }
.page-link.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 24px;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--bg-white); border-radius: var(--radius-lg);
    width: 100%; max-width: 520px; box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; border: none; background: transparent;
    cursor: pointer; font-size: 22px; color: var(--text-muted);
    border-radius: var(--radius-sm); display: flex; align-items: center;
    justify-content: center; transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body {
    padding: 24px;
}
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.modal-body .form-group input, .modal-body .form-group select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
    outline: none; transition: var(--transition);
}
.modal-body .form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: flex-end; gap: 8px;
}
.required { color: var(--danger); }
.input-disabled { background: var(--bg) !important; color: var(--text-muted) !important; cursor: not-allowed; }

/* ---- Toast ---- */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px; border-radius: var(--radius);
    background: var(--text); color: #fff; font-size: 14px;
    box-shadow: var(--shadow-lg); z-index: 2000;
    animation: slideUp 0.3s ease;
    max-width: 360px;
}
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center; color: var(--text-muted);
    padding: 32px; font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .hero-title { font-size: 28px; }
    .hero-desc { font-size: 15px; }
    .create-card { padding: 20px; }
    .input-group-large { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .features-grid { grid-template-columns: 1fr; }
    .stats-row { gap: 32px; }
    .stat-number { font-size: 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }

    /* Admin responsive */
    .sidebar {
        width: 100%; position: static; flex-direction: row;
        border-right: none; border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .sidebar-brand { padding: 12px 16px; border-bottom: none; }
    .sidebar-nav { flex-direction: row; padding: 0 8px; gap: 0; }
    .sidebar-footer { padding: 0 8px; border-top: none; }
    .admin-page { flex-direction: column; }
    .main-content { margin-left: 0; padding: 20px 16px; }
    .page-header { flex-direction: column; gap: 12px; }
    .filter-bar { flex-direction: column; }
    .filter-input { min-width: auto; width: 100%; }

    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .link-url-cell { max-width: 160px; }
    .link-title { max-width: 160px; }

    .modal { margin: 16px; }
    .form-row { grid-template-columns: 1fr; }
}
