:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --accent: #f97316;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-500: #64748b;
    --gray-700: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.10);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

main {
    flex: 1;
}

/* ========== Navbar ========== */
.navbar {
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.navbar-brand i {
    margin-right: 6px;
}

/* ========== Banner Carousel ========== */
.banner-img {
    max-height: 400px;
    object-fit: cover;
    width: 100%;
    border-radius: var(--radius);
}

.carousel-inner {
    border-radius: var(--radius);
    overflow: hidden;
}

.carousel-item a,
.carousel-item img {
    display: block;
}

/* ========== Section Headings ========== */
.section-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
}

.section-heading i {
    color: var(--primary);
}

/* ========== Resource Cards ========== */
.resource-card {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resource-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

.card-cover-img {
    height: 160px;
    object-fit: cover;
    width: 100%;
}

.resource-card .card-cover-placeholder {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, #f5f3ff 100%);
}

.card-placeholder-icon {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.7;
}

.resource-card .card-body {
    padding: 1rem;
}

.resource-card .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

.resource-card .card-title a {
    color: var(--dark);
    text-decoration: none;
}

.resource-card .card-title a:hover {
    color: var(--primary);
}

.resource-card .card-text {
    font-size: 0.82rem;
    color: var(--gray-500);
    line-height: 1.5;
}

.resource-card .badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
}

.resource-card .btn-detail {
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* ========== Detail Page ========== */
.detail-header {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.detail-header h3 {
    font-weight: 700;
    color: var(--dark);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 1rem 0;
}

.detail-meta .badge {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 20px;
}

.detail-content {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
}

.detail-content p {
    color: var(--gray-700);
    line-height: 1.8;
}

.download-btn {
    font-size: 1rem;
    padding: 10px 28px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* ========== Download Page ========== */
.download-icon {
    font-size: 4rem;
}

.download-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    text-align: center;
}

.code-display {
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--danger);
}

/* ========== Login ========== */
.login-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    max-width: 420px;
    margin: 2rem auto;
}

.login-card h4 {
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

/* ========== Admin Sidebar ========== */
.sidebar {
    border-right: 1px solid var(--gray-200);
    background: #fff;
}

.sidebar h6 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.sidebar .nav-link {
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    margin: 2px 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.sidebar .nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.sidebar .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 6px;
}

/* ========== Admin Dashboard ========== */
.stat-card {
    background: #fff;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--dark);
}

.bg-purple { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.bg-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.bg-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-rose { background: linear-gradient(135deg, #f43f5e, #e11d48); }

/* ========== Admin Tables ========== */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-card .card-header {
    background: none;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
}

.table-card .card-header h6 {
    font-weight: 700;
    margin: 0;
}

.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--gray-500);
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-bottom-width: 1px;
}

.table td {
    padding: 0.7rem 1rem;
    vertical-align: middle;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--gray-100);
}

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

/* ========== Empty State ========== */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-200);
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

/* ========== Form Styles ========== */
.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--gray-200);
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ========== Buttons ========== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 0.5rem 1.2rem;
    transition: all 0.15s;
}

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

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

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ========== Footer ========== */
footer {
    background: var(--dark);
    color: var(--gray-500);
    font-size: 0.85rem;
}

footer a {
    color: var(--gray-500);
    text-decoration: none;
    transition: color 0.15s;
}

footer a:hover {
    color: #fff;
}

/* ========== Alerts ========== */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* ========== Badges ========== */
.badge {
    border-radius: 6px;
}

/* ========== Pagination ========== */
.pagination .page-link {
    border-radius: var(--radius-sm);
}

/* ========== Error Pages ========== */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 5rem;
    font-weight: 800;
    color: var(--gray-200);
    margin-bottom: 0.5rem;
}

.error-page h3 {
    color: var(--gray-700);
    font-weight: 600;
}

/* ========== Captcha ========== */
.captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 4px;
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
}

.captcha-img {
    height: 42px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--gray-200);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.captcha-img:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .banner-img {
        max-height: 200px;
        object-fit: cover;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }

    .detail-header,
    .detail-content,
    .download-card,
    .login-card {
        padding: 1.25rem;
    }
}