:root {
    --primary-color: #1bb954;
    --primary-admin-logo: #ffffff;
    --primary-hover: #007a2c;
    --text-main: #2a2e2e;
    --text-secondary: #5f6464;
    --bg-body: #f5f7fa;
    --bg-white: #ffffff;
    --border-color: #ebebeb;
    --border-radius: 4px;
    --header-height: 70px;
    --container-width: 1200px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
    --transition-base: all 0.3s ease;
}

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

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-base);
}

a:hover {
    color: var(--primary-color);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Layout */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

main {
    flex: 1;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 24px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    border: 1px solid transparent;
    transition: var(--transition-base);
    line-height: 1.5;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(154, 19, 9, 0.3);
}

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

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

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* Header */
header {
    background-color: var(--bg-white);
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    padding: 0; /* Container handles padding */
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.logo a {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-links a {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    padding: 8px 0;
    position: relative;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s;
}

.nav-links a:hover::after {
    width: 100%;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Hero Section (Index) */
.hero-section {
    position: relative;
    height: 500px;
    background-color: #000;
    color: var(--bg-white);
    overflow: hidden;
    margin-bottom: 60px;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.hero-title {
    font-size: 48px;
    font-weight: 300;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.hero-subtitle {
    font-size: 18px;
    font-weight: 300;
    max-width: 600px;
    margin-bottom: 32px;
    opacity: 0.9;
}

/* Section Common */
.section {
    margin-bottom: 80px;
}

.section-header {
    margin-bottom: 40px;
    text-align: center;
}

.section-title {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Cards Grid */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-md);
}

.card-img-top {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img-top {
    transform: scale(1.05);
}

.card-body {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.card-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
    flex: 1;
}

.card-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: #999;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

/* Guestbook Specific */
.guestbook-list {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.guestbook-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
}

.guestbook-item:last-child {
    border-bottom: none;
}

.guestbook-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.guestbook-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.guestbook-content {
    padding-left: 52px;
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.7;
}

/* Forms */
.form-container {
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: border-color 0.3s;
    background: #fdfdfd;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-white);
}

textarea.form-control {
    resize: vertical;
}

/* Footer */
footer {
    background-color: #1b1f23;
    color: #888;
    padding: 60px 0 30px;
    margin-top: auto;
    font-size: 14px;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
    max-width: var(--container-width);
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

.footer-brand h2 {
    color: var(--bg-white);
    margin-bottom: 20px;
    font-size: 24px;
}

.footer-col h4 {
    color: var(--bg-white);
    margin-bottom: 20px;
    font-size: 16px;
}

.footer-col a {
    display: block;
    margin-bottom: 12px;
    color: #888;
}

.footer-col a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    border-top: 1px solid #333;
    padding-top: 30px;
    text-align: center;
    color: #666;
}

/* Header Improvements */
.header-inner {
    position: relative;
    /* justify-content: space-between; already set */
}

.header-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    margin-left: 40px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 24px;
    position: relative;
    z-index: 1001;
    padding: 0;
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-main);
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle span:nth-child(1) { top: 0; }
.mobile-menu-toggle span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.mobile-menu-toggle span:nth-child(3) { bottom: 0; }

.mobile-menu-toggle.active span:nth-child(1) { top: 50%; transform: rotate(45deg); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active span:nth-child(3) { bottom: auto; top: 50%; transform: rotate(-45deg); }

/* User Menu Specifics */
.logout-link {
    font-size: 14px;
    color: #666;
    margin-right: 16px;
    transition: color 0.2s;
}

.logout-link:hover {
    color: var(--primary-color);
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.profile-link img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.login-btn {
    padding: 6px 20px;
}

/* Article Content Responsive */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.article-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

/* Page & Article Details */
.article-detail-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.article-meta {
    color: #999;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.article-content {
    line-height: 1.8;
    font-size: 16px;
    color: #444;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        height: auto;
    }

    .article-detail-card {
        padding: 20px;
    }
    
    .guestbook-list {
        padding: 20px;
    }
    
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 0 20px;
        align-items: stretch;
    }
    
    .logo {
        height: var(--header-height);
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .header-nav-container {
        display: none;
        flex-direction: column;
        margin-left: 0;
        width: 100%;
        border-top: 1px solid var(--border-color);
        padding-bottom: 20px;
        position: absolute;
        top: 100%;
        left: 0;
        background-color: var(--bg-white);
        z-index: 999;
        box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    }
    
    .header-nav-container.active {
        display: flex;
        animation: slideDownNav 0.3s ease forwards;
    }
    
    @keyframes slideDownNav {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0;
        margin: 10px 0;
    }
    
    .nav-links a {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid #f0f0f0;
        width: 100%;
        text-align: center;
    }
    
    .nav-links a:last-child {
        border-bottom: none;
    }
    
    .nav-links a::after {
        display: none;
    }
    
    .user-menu {
        flex-direction: column-reverse;
        gap: 20px;
        margin-top: 20px;
        width: 100%;
        align-items: center;
    }
    
    .profile-link {
        flex-direction: column-reverse;
        gap: 10px;
    }
    
    .profile-link img {
        width: 60px;
        height: 60px;
        border: 2px solid var(--bg-white);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .profile-link span {
        font-size: 16px;
        font-weight: 600;
    }
    
    .logout-link {
        margin-right: 0;
        padding: 8px 20px;
        border: 1px solid #eee;
        border-radius: 20px;
        width: auto;
        text-align: center;
    }
    
    /* Grid Adjustments */
    .grid-3, .grid-2 {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    /* Hero Adjustments */
    .hero-section {
        height: 400px;
    }
    
    .hero-title {
        font-size: 32px;
    }
    
    .hero-subtitle {
        font-size: 16px;
    }
    
    /* Footer Adjustments */
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 30px;
    }
    
    /* Profile Adjustments */
    .profile-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: -40px;
    }
    
    .profile-avatar-lg {
        width: 100px;
        height: 100px;
    }
    
    .profile-text {
        width: 100%;
    }
    
    /* Form Adjustments */
    .form-container {
        padding: 20px;
    }
}

/* Admin Specific */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background-color: #1b1f23;
    color: var(--bg-white);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #333;
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-admin-logo);
}

.admin-nav {
    padding: 20px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #bdc3c7;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    transition: all 0.2s;
}

.admin-nav a:hover, .admin-nav a.active {
    background-color: var(--primary-color);
    color: var(--bg-white);
    transform: translateX(4px);
}

.admin-content {
    flex: 1;
    padding: 30px;
    background-color: #f4f6f8;
    overflow-y: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table th {
    background-color: #fafbfc;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

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

/* Profile Page */
.profile-header-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

.profile-cover {
    height: 200px;
    background-color: #ddd;
    background-size: cover;
    background-position: center;
}

.profile-info {
    padding: 20px 30px 30px;
    display: flex;
    align-items: flex-end;
    gap: 24px;
    margin-top: -60px;
}

.profile-avatar-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--bg-white);
    background: var(--bg-white);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.profile-text h1 {
    font-size: 28px;
    margin-bottom: 4px;
}

.profile-text p {
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-white);
    margin: 40px auto;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 900px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.close-modal {
    font-size: 24px;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

/* Media Grid in Modal */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; max-height: 500px; overflow-y: auto; padding: 5px; }
.media-item { position: relative; cursor: pointer; border: 2px solid transparent; border-radius: 4px; overflow: hidden; transition: all 0.2s; }
.media-item:hover { border-color: #007bff; transform: translateY(-2px); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.media-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.media-item-name { font-size: 12px; color: #666; padding: 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #f8f9fa; }

/* Editor Customization */
.CodeMirror { border-radius: 4px; border: 1px solid #ced4da; }
.editor-toolbar { border-color: #ced4da; border-radius: 4px 4px 0 0; opacity: 1; }
.editor-toolbar:hover { opacity: 1; }

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background-color: var(--bg-white);
    color: var(--text-main);
    padding: 16px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    min-width: 300px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.4s ease;
    border-left: 4px solid var(--primary-color);
}

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

.toast.hide {
    opacity: 0;
    transform: translateX(50px);
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

.toast-close {
    cursor: pointer;
    font-size: 18px;
    color: #999;
    margin-left: 15px;
}

.toast-close:hover {
    color: var(--text-main);
}
