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

html { font-size: 14px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f6fa;
    color: #2d3436;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: #4a6cf7; text-decoration: none; }
a:hover { color: #3451b2; }

/* ========== Top Navigation Bar ========== */
.topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 1.5rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 2.5rem;
    flex-shrink: 0;
}

.brand-icon {
    font-size: 1.3rem;
}

.brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.3px;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.topbar-nav a {
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.topbar-nav a:hover {
    color: #1e293b;
    background: #f1f5f9;
}

.topbar-nav a.active {
    color: #4a6cf7;
    background: #eef2ff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-left: 1.5rem;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.85rem;
    color: #64748b;
}

.logout-btn {
    font-size: 0.8rem;
    color: #94a3b8;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: all 0.15s;
}

.logout-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* ========== Main Content Area ========== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ========== Page Header ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e293b;
}

/* ========== Flash Messages ========== */
.flash-messages {
    margin-bottom: 1.2rem;
}

.flash-message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
    border: 1px solid;
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* ========== Cards ========== */
.card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

/* Make Pico's article element look like cards */
article {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

article header {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

article header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
}

/* ========== Grid ========== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* ========== Stat Cards (Dashboard) ========== */
.stat-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue  { background: #eef2ff; }
.stat-icon.green { background: #f0fdf4; }
.stat-icon.amber { background: #fffbeb; }
.stat-icon.rose  { background: #fff1f2; }

.stat-info h4 {
    font-size: 0.78rem;
    font-weight: 500;
    color: #94a3b8;
    margin: 0 0 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-info .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* ========== Tables ========== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

thead th {
    background: #f8fafc;
    padding: 0.8rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #e2e8f0;
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
    color: #334155;
}

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

tbody tr:hover {
    background: #f8fafc;
}

td code {
    background: #f1f5f9;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #6366f1;
    font-family: "SF Mono", "Fira Code", monospace;
}

/* ========== Buttons ========== */
button, [role="button"], a[role="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

button:not(.outline):not(.ghost), a[role="button"]:not(.outline):not(.ghost) {
    background: #4a6cf7;
    color: #fff;
    border-color: #4a6cf7;
}

button:not(.outline):not(.ghost):hover, a[role="button"]:not(.outline):not(.ghost):hover {
    background: #3b5de7;
    border-color: #3b5de7;
}

button.outline, a[role="button"].outline {
    background: #fff;
    color: #334155;
    border-color: #d1d5db;
}

button.outline:hover, a[role="button"].outline:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

button.ghost {
    background: transparent;
    color: #64748b;
    border-color: transparent;
    padding: 0.4rem 0.6rem;
}

button.ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}

button.small, .outline.small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 5px;
}

button.contrast, .outline.contrast {
    color: #dc2626;
    border-color: #fca5a5;
}

button.contrast:hover, .outline.contrast:hover {
    background: #fef2f2;
    border-color: #f87171;
}

/* ========== Forms ========== */
label {
    display: block;
    font-weight: 500;
    font-size: 0.88rem;
    color: #374151;
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.88rem;
    color: #1e293b;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #4a6cf7;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.12);
}

input::placeholder, textarea::placeholder {
    color: #94a3b8;
}

fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

legend {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
    padding: 0 0.5rem;
}

/* ========== Article Grid (Article List) ========== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.article-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: all 0.2s ease;
    padding: 0;
}

.article-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.article-cover {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.article-card header {
    padding: 0.8rem 1rem 0.4rem;
    border: none;
    margin: 0;
}

.article-card header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card p {
    padding: 0 1rem;
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card footer {
    padding: 0.6rem 1rem 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    margin-top: 0.5rem;
}

/* ========== Article Detail Content ========== */
.article-content {
    line-height: 1.85;
    font-size: 0.95rem;
    color: #334155;
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}

.article-content h1, .article-content h2, .article-content h3 {
    color: #1e293b;
    margin: 1.5rem 0 0.75rem;
}

.article-content h1 { font-size: 1.5rem; }
.article-content h2 { font-size: 1.25rem; }
.article-content h3 { font-size: 1.1rem; }

.article-content p {
    margin-bottom: 1rem;
}

.article-content blockquote {
    border-left: 3px solid #4a6cf7;
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
    color: #64748b;
}

.article-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.85rem;
}

.article-content code {
    background: #f1f5f9;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.article-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.article-content table {
    margin: 1rem 0;
}

/* ========== Progress Section ========== */
.progress-section {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    margin-top: 1.25rem;
}

.progress-bar-wrap {
    background: #e2e8f0;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: 0.8rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6cf7, #7c3aed);
    border-radius: 999px;
    transition: width 0.5s ease;
}

progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    appearance: none;
    -webkit-appearance: none;
}

progress::-webkit-progress-bar {
    background: #e2e8f0;
    border-radius: 999px;
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, #4a6cf7, #7c3aed);
    border-radius: 999px;
}

progress::-moz-progress-bar {
    background: linear-gradient(90deg, #4a6cf7, #7c3aed);
    border-radius: 999px;
}

/* ========== Login Page ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    max-width: 380px;
    width: 100%;
    background: #fff;
    border-radius: 14px;
    padding: 2.5rem;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

.login-card h2 {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.8rem;
}

/* ========== Status Badges ========== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ========== Draft Items ========== */
.draft-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-bottom: 0.6rem;
    transition: box-shadow 0.2s;
}

.draft-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.draft-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.draft-info { flex: 1; min-width: 0; }

.draft-info h4 {
    margin: 0 0 0.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-info p {
    margin: 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

.draft-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ========== Settings Form ========== */
.settings-section {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.settings-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
}

/* ========== Misc ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.text-muted { color: #94a3b8; }
.text-sm    { font-size: 0.8rem; }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .topbar-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .topbar-brand { margin-right: auto; }
    .topbar-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding: 0.25rem 0;
    }
    .topbar-nav a {
        padding: 0.4rem 0.6rem;
        font-size: 0.82rem;
    }
    .main-content { padding: 1rem; }
    .grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .article-grid { grid-template-columns: 1fr; }
}
