:root {
    /* Color Palette - Kent C. Dodds Inspired */
    --bg-body: #1f2028;       /* Gray 900 */
    --bg-surface: #2e3039;    /* Gray 800 */
    --bg-surface-hover: #3a3d4a; /* Gray 700 */
    
    --text-primary: #ffffff;
    --text-secondary: #a9adc1; /* Slate 500 */
    --text-muted: #6f7382;
    
    --accent-color: #36a3ff;   /* Team Blue */
    --accent-hover: #60b3ff;
    --accent-gradient: linear-gradient(135deg, #36a3ff 0%, #30c85e 100%); /* Blue to Greenish */
    
    --border-color: #4b4c53;   /* Gray 600 */
    
    --danger-color: #ef4444;
    
    /* Spacing & Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    
    --container-max-width: 1250px;
    
    --font-heading: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-body);
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

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

/* Layout */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.site-header {
    background-color: rgba(31, 32, 40, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-item {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: #0f172a; /* Dark text on bright button */
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

.btn-outline:hover {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
}

.btn-link {
    background: none;
    color: var(--accent-color);
    padding: 0;
}

/* Blog Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.post-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    border-color: var(--accent-color);
}

.post-image-container {
    height: 180px;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-surface-hover);
}

.post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.post-card:hover .post-image {
    transform: scale(1.05);
}

.post-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.post-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.post-tag {
    font-size: 0.7rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.post-tag:hover {
    color: var(--text-secondary);
    border-color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
}

.post-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

.post-title a {
    color: var(--text-primary);
}

.post-title a:hover {
    color: var(--accent-color);
}

.post-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Post Detail */
.post-header {
    margin: 3rem 0;
    text-align: center;
}

.post-hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.post-hero-meta {
    color: var(--text-secondary);
    font-size: 1rem;
}

.post-body {
    max-width: 850px;
    margin: 0 auto 4rem auto;
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.post-body h1, .post-body h2, .post-body h3 {
    color: var(--text-primary);
    margin-top: 2.5rem;
}

.post-body code {
    background: var(--bg-surface);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    font-weight: 300;
    color: var(--accent-color);
}

.post-body pre {
    background: var(--bg-surface);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.post-body pre code {
    background: transparent !important;
    padding: 0 !important;
    color: inherit;
}

.post-body blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin-left: 0;
    color: var(--text-primary);
    font-style: italic;
}

.post-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 2rem 0;
    border: 1px solid var(--border-color);
}

/* Auth Cards */
.auth-box {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.auth-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
}

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

.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Tables and Admin */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th {
    text-align: left;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.2);
}

.table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.table tr:hover {
    background-color: var(--bg-surface-hover);
}

.avatar-circle {
    background: var(--accent-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 999px; /* Pill shape */
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.tag-primary {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-color: rgba(56, 189, 248, 0.2);
}

.tag-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.2);
}

/* PDF Viewer */
.pdf-container {
    margin-top: 2rem;
    background: var(--bg-surface);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.pdf-embed {
    width: 100%;
    height: 800px; /* Default height */
    min-height: 80vh;
    border-radius: var(--radius-sm);
    border: none;
    background-color: #525659; /* Chrome PDF viewer iframe bg color */
}

.pdf-footer {
    text-align: center;
    padding-top: 0.75rem;
}

.download-link {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.download-link:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Comments Section */
.comments-section h3 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.comment-form {
    margin-bottom: 4rem;
    position: relative;
    max-width: 100%;
}

.comment-input-wrapper {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow: hidden; /* Contains the button */
}

.comment-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(54, 163, 255, 0.15);
}

.comment-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1.5rem;
    padding-bottom: 4rem; /* Space for the button */
    border-radius: var(--radius-md);
    min-height: 120px;
    font-family: var(--font-body);
    font-size: 1rem;
    resize: vertical;
    line-height: 1.5;
}

.comment-form textarea:focus {
    outline: none;
}

.comment-submit-btn {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.comment-submit-btn:hover {
    background: var(--accent-hover);
}

.comment-submit-btn:active {
    transform: scale(0.96);
}

.comment {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.comment:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.comment-header strong {
    color: var(--accent-color);
}

.comment-date {
    color: var(--text-muted);
}

.comment-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Replies */
.replies {
    margin-top: 1.5rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}

.replies .comment {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border-color); /* Lighter separator for replies */
}

.replies .comment:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Reply Form - Inherits from comment-form but smaller */
.reply-form {
    margin-top: 1rem;
}

.reply-form .comment-input-wrapper {
    border-color: var(--border-color);
}

.reply-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    color: var(--text-primary);
    resize: vertical;
    line-height: 1.5;
    min-height: 80px;
    padding: 1rem;
    padding-bottom: 3rem;
    font-size: 0.9rem;
}

.reply-form textarea:focus {
    outline: none;
}

.reply-form .comment-submit-btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    bottom: 0.5rem;
    right: 0.5rem;
}

.btn-reply {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.btn-reply:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Code Block Copy Button */
.post-body pre {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0; 
}

.post-body pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--bg-surface);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.copy-btn.copied {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Media Gallery View Styles */
.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.view-btn.active {
    color: var(--accent-color);
    background-color: rgba(54, 163, 255, 0.1);
}

.media-gallery {
    width: 100%;
    transition: all 0.3s ease;
}

.gallery-media {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: block;
    background: var(--bg-surface);
}

/* List View */
.media-gallery.list-view {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Grid View */
.media-gallery.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.media-gallery.grid-view .gallery-media {
    height: 250px;
    object-fit: cover;
}

/* Mosaic View (Masonry) */
.media-gallery.mosaic-view {
    column-count: 3;
    column-gap: 1.5rem;
}

.media-gallery.mosaic-view .media-item {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .media-gallery.mosaic-view {
        column-count: 2;
    }
}

@media (max-width: 600px) {
    .media-gallery.mosaic-view {
        column-count: 1;
    }
}

/* Lazy Load Animation */
.media-item {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.media-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Fallback for videos without posters */
video.gallery-media {
    background-color: var(--bg-surface-hover);
    min-height: 200px; /* Prevent collapse */
    object-fit: cover;
}

/* Ensure images don't overflow while loading */
img.gallery-media {
    min-height: 100px;
    background-color: var(--bg-surface-hover);
    transition: opacity 0.3s ease-in;
}
