/* ========================================
   Perry's Blog - Modern Design CSS
   ======================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --secondary: #764ba2;
    --accent: #f093fb;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --text: #e0e0e0;
    --text-muted: #888;
    --border: #2a2a3e;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    min-height: 100vh;
}

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

/* Navbar */
.navbar {
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.nav-menu { display: flex; list-style: none; gap: 32px; }

.nav-menu a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
}

.nav-menu a:hover, .nav-menu a.active {
    color: #fff;
    border-bottom-color: var(--primary);
}

.admin-link { color: #ed8936 !important; }

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 60px 0;
}

/* Post Cards Grid */
.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.post-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border);
}

.post-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border-color: var(--primary);
}

.post-card .cover {
    height: 180px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    position: relative;
    overflow: hidden;
}

.post-card .cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(0,0,0,0.2) 100%);
}

.post-card .content { padding: 24px; }

.post-card .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.post-card h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
}

.post-card h2 a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}

.post-card h2 a:hover { color: var(--primary); }

.post-card .excerpt {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: gap 0.2s;
}

.read-more:hover { gap: 10px; }

/* Single Post Page */
.post-header { margin-bottom: 40px; }

.post-header h1 {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fff 0%, #a8b2d1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.post-cover {
    width: 100%;
    height: 450px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 40px;
    border: 1px solid var(--border);
}

.post-body {
    font-size: 17px;
    line-height: 1.9;
    color: #ccc;
}

.post-body h2 {
    font-size: 24px;
    color: #fff;
    margin: 40px 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.post-body h3 {
    font-size: 20px;
    color: #fff;
    margin: 30px 0 15px;
}

.post-body p { margin-bottom: 20px; }

.post-body ul, .post-body ol {
    margin: 20px 0;
    padding-left: 24px;
}

.post-body li { margin-bottom: 8px; }

/* Comments */
.comments-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.comments-section h3 {
    font-size: 20px;
    color: #fff;
    margin-bottom: 24px;
}

.comment {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.comment .author {
    font-weight: 600;
    color: var(--primary);
}

.comment .date {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 12px;
}

.comment .content {
    margin-top: 12px;
    color: #bbb;
    line-height: 1.7;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group textarea { min-height: 200px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    box-shadow: none;
}

/* Flash Messages */
.flash-messages { margin: 24px 0; }

.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 14px;
}

.alert-success { background: rgba(72, 199, 142, 0.15); color: #48c78e; border: 1px solid rgba(72, 199, 142, 0.3); }
.alert-danger { background: rgba(237, 137, 54, 0.15); color: #ed8936; border: 1px solid rgba(237, 137, 54, 0.3); }
.alert-info { background: rgba(102, 126, 234, 0.15); color: var(--primary); border: 1px solid rgba(102, 126, 234, 0.3); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 60px;
}

.pagination a, .pagination span {
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.2s;
}

.pagination a:hover { background: var(--primary); color: #fff; }
.pagination .active { background: var(--primary); color: #fff; }

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

/* Admin Layout */
.admin-layout { display: flex; gap: 30px; }

.admin-sidebar {
    width: 240px;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    height: fit-content;
    border: 1px solid var(--border);
}

.admin-sidebar ul { list-style: none; }

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.admin-sidebar a:hover { background: var(--border); color: #fff; }
.admin-sidebar a.active { background: var(--primary); color: #fff; }

.admin-content {
    flex: 1;
    background: var(--bg-card);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.admin-content h1 {
    font-size: 24px;
    color: #fff;
    margin-bottom: 24px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
}

.stat-card .number { font-size: 36px; font-weight: 800; color: #fff; }
.stat-card .label { font-size: 13px; color: rgba(255,255,255,0.8); margin-top: 4px; }

/* Table */
table { width: 100%; border-collapse: collapse; }

th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--border); }

th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

tr:hover td { background: rgba(255,255,255,0.02); }

/* Responsive - Mobile First */
@media (max-width: 768px) {
    /* Mobile Navigation */
    .navbar .container {
        height: 56px;
        padding: 0 16px;
    }
    
    .nav-menu {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: rgba(15, 15, 26, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 16px;
        gap: 0;
        border-bottom: 1px solid var(--border);
        z-index: 99;
    }
    
    .nav-menu.active { display: flex; }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid var(--border);
    }
    
    .nav-menu li:last-child { border-bottom: none; }
    
    .nav-menu a {
        display: block;
        padding: 14px 0 !important;
        font-size: 16px !important;
        border-bottom: none !important;
    }
    
    /* Mobile Menu Toggle */
    .mobile-menu-btn {
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
    }
    
    .mobile-menu-btn span {
        display: block;
        width: 24px;
        height: 2px;
        background: #fff;
        transition: all 0.3s;
    }
    
    /* Content */
    .container { padding: 0 16px; }
    
    .main-content { padding: 24px 0; }
    
    /* Post List */
    .post-list { 
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .post-card .cover { height: 160px; }
    .post-card .content { padding: 16px; }
    .post-card h2 { font-size: 16px; }
    .post-card .excerpt { font-size: 13px; }
    
    /* Single Post */
    .post-header h1 { font-size: 24px !important; line-height: 1.4; }
    .post-cover { height: 200px; margin-bottom: 24px; }
    .post-body { font-size: 15px; line-height: 1.8; }
    .post-body h2 { font-size: 20px; }
    .post-body h3 { font-size: 17px; }
    
    /* Comments */
    .comment { padding: 16px; }
    
    /* Forms */
    .form-group input,
    .form-group textarea,
    .form-group select { padding: 12px; font-size: 16px; } /* Prevents iOS zoom */
    .form-group textarea { min-height: 150px; }
    .btn { 
        width: 100%; 
        justify-content: center;
        padding: 14px 20px;
    }
    
    /* Admin */
    .admin-layout { flex-direction: column; gap: 16px; }
    .admin-sidebar { 
        width: 100%; 
        padding: 16px;
    }
    .admin-sidebar ul { display: flex; flex-wrap: wrap; gap: 8px; }
    .admin-sidebar a { padding: 10px 14px !important; }
    .admin-content { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .number { font-size: 28px; }
    
    /* Table */
    table { font-size: 13px; }
    th, td { padding: 10px 8px; }
    
    /* Pagination */
    .pagination { flex-wrap: wrap; gap: 6px; }
    .pagination a, .pagination span { padding: 8px 12px; font-size: 13px; }
    
    /* Footer */
    .footer { padding: 24px 0; font-size: 12px; }
}

@media (max-width: 480px) {
    .post-header h1 { font-size: 22px !important; }
    .post-cover { height: 180px; border-radius: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
