/* Material Theme Styles - Dark Theme */

:root {
    --md-primary-color: #BB86FC; /* Lightened primary for dark theme */
    --md-primary-light: #E0BFFF;
    --md-primary-dark: #3700B3; /* Keep original dark primary for contrast */
    --md-accent-color: #03DAC6;

    --md-background-color: #121212; /* Dark background */
    --md-surface-color: #1E1E1E;   /* Dark surface */
    --md-error-color: #CF6679;     /* Lighter error for dark theme */

    --md-on-primary-color: #000000; /* Text on primary (dark) */
    --md-on-surface-color: #FFFFFF; /* Text on surface (light) */
    --md-on-background-color: #FFFFFF; /* Text on background (light) */

    --md-text-color: rgba(255, 255, 255, 0.87); /* Primary text */
    --md-text-secondary-color: rgba(255, 255, 255, 0.60); /* Secondary text */
    --md-text-disabled-color: rgba(255, 255, 255, 0.38); /* Disabled text */
    --md-divider-color: rgba(255, 255, 255, 0.12); /* Dividers */

    /* Dark theme shadows - typically less pronounced or inverted */
    --md-elevation-1: 0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12);
    --md-elevation-2: 0px 3px 3px -2px rgba(0,0,0,0.2), 0px 3px 4px 0px rgba(0,0,0,0.14), 0px 1px 8px 0px rgba(0,0,0,0.12);
    --md-elevation-4: 0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12);
    --md-elevation-8: 0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12);
}

body {
    margin: 0;
    background-color: var(--md-background-color);
    color: var(--md-text-color);
    font-family: 'Vazirmatn', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.material-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.material-layout .container {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    padding: 1rem;
}

/* Header */
.material-layout .main-header {
    background-color: var(--md-surface-color);
    box-shadow: var(--md-elevation-4);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.material-layout .main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.material-layout .site-logo {
    text-decoration: none;
    color: var(--md-on-surface-color);
    font-size: 1.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.material-layout .site-logo img {
    height: 40px;
    margin-left: 10px;
    border-radius: 4px;
}

.material-layout .site-logo h1 { /* Added for alignment */
    font-size: 1.8rem;
    margin: 0;
    line-height: 1; /* Adjust line-height to match */
}

.material-layout .main-nav { /* Added for alignment */
    display: flex;
    align-items: center;
}

.material-layout .main-nav a {
    color: var(--md-text-secondary-color);
    text-decoration: none;
    margin-left: 1rem;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.material-layout .main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.08); /* Lighter hover for dark theme */
    color: var(--md-on-surface-color);
}

/* Main Content */
.material-layout .main-content {
    flex-grow: 1;
}

/* Footer */
.material-layout .main-footer {
    background-color: var(--md-surface-color);
    color: var(--md-text-secondary-color);
    padding: 1.5rem 0;
    margin-top: 2rem;
    text-align: center;
    box-shadow: var(--md-elevation-8);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--md-on-background-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

strong {
    font-weight: bold;
    color: var(--md-on-background-color);
}

em {
    font-style: italic;
    color: var(--md-text-secondary-color);
}

a {
    color: var(--md-primary-light); /* Lighter primary for dark theme links */
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--md-accent-color);
    text-decoration: none; /* Removed underline on hover */
}

/* Lists */
ul, ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

ul li, ol li {
    margin-bottom: 0.5rem;
}

/* Blockquote */
blockquote {
    border-left: 4px solid var(--md-primary-light); /* Lighter primary for dark theme */
    background-color: rgba(var(--md-primary-light), 0.05); /* Darker background */
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    color: var(--md-text-color);
    border-radius: 4px;
}

/* Code Blocks */
code {
    background-color: rgba(255, 255, 255, 0.05); /* Darker background */
    color: var(--md-accent-color);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

pre {
    background-color: #2B2B2B; /* Dark grey for code blocks */
    color: #E0E0E0; /* Lighter text for code blocks */
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    box-shadow: var(--md-elevation-1);
}

pre code {
    background: none;
    color: #E0E0E0; /* Lighter text for code blocks */
    padding: 0;
    white-space: pre;
    display: block;
    font-size: 1em;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    background-color: var(--md-surface-color);
    box-shadow: var(--md-elevation-1);
    border-radius: 4px;
    overflow: hidden; /* Ensures rounded corners apply to content */
}

th, td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--md-divider-color);
    text-align: left;
}

th {
    background-color: rgba(255, 255, 255, 0.04); /* Darker background */
    color: var(--md-on-surface-color);
    font-weight: bold;
}

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

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 4px;
    box-shadow: var(--md-elevation-2);
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    background-color: var(--md-surface-color);
    border: 1px solid var(--md-divider-color);
    color: var(--md-text-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.05); /* Darker shadow */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--md-primary-light); /* Lighter primary for dark theme */
    box-shadow: 0 0 0 2px rgba(var(--md-primary-light), 0.3);
}

button,
input[type="submit"] {
    background-color: var(--md-primary-color);
    color: var(--md-on-primary-color);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    text-transform: uppercase;
    box-shadow: var(--md-elevation-2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

button:hover,
input[type="submit"]:hover {
    background-color: var(--md-primary-light); /* Lighter primary on hover */
    box-shadow: var(--md-elevation-4);
}

button:active,
input[type="submit"]:active {
    box-shadow: var(--md-elevation-8);
}

/* Horizontal Rule */
hr {
    border: none;
    border-top: 1px solid var(--md-divider-color);
    margin: 2.5rem 0;
}

/* Keyboard Input */
kbd {
    background-color: rgba(255, 255, 255, 0.05); /* Darker background */
    border: 1px solid var(--md-divider-color);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 0.1em 0.4em;
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--md-text-color);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

/* Selection */
::selection {
    background-color: var(--md-primary-light);
    color: var(--md-on-primary-color);
}
::-moz-selection {
    background-color: var(--md-primary-light);
    color: var(--md-on-primary-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--md-background-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #555; /* Dark scrollbar thumb */
    border-radius: 10px;
    border: 2px solid var(--md-background-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--md-primary-light);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.error { color: var(--md-error-color); }
.warning { color: #FFC107; /* Amber */ }
.info { color: #2196F3; /* Blue */ }

/* Post Item (Card-like structure) */
.posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.post-item {
    background-color: var(--md-surface-color);
    border-radius: 8px;
    box-shadow: var(--md-elevation-2);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow: hidden; /* For image border-radius */
}

.post-item:hover {
    box-shadow: var(--md-elevation-8);
    transform: translateY(-5px);
}

.post-item-content { /* New wrapper for content below image */
    padding: 1.5rem;
}

.post-item img {
    width: 100%;
    height: 200px; /* Fixed height for consistency */
    object-fit: cover; /* Cover the area */
    border-radius: 8px 8px 0 0; /* Top corners rounded */
    margin: 0; /* Remove default image margin */
    display: block;
}

.post-item h2 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.post-item h2 a {
    color: var(--md-on-surface-color);
    text-decoration: none;
}

.post-item h2 a:hover {
    color: var(--md-primary-light); /* Lighter primary for dark theme */
    text-decoration: none; /* Removed underline on hover */
}

.post-item p {
    color: var(--md-text-secondary-color);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.post-item .post-meta {
    font-size: 0.85rem;
    color: var(--md-text-disabled-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.post-item .post-meta .views-count { /* Added this block */
    margin-left: auto;
    display: inline-flex; /* Use inline-flex to keep it in line with other meta items */
    align-items: center;
    gap: 5px; /* Space between icon and number */
}

.post-item .post-meta svg {
    width: 18px;
    height: 18px;
    color: var(--md-text-disabled-color);
}

/* Single Post/Page */
.single-post, .single-page {
    background-color: var(--md-surface-color);
    border-radius: 8px;
    box-shadow: var(--md-elevation-4);
    padding: 2rem;
}

.single-post .post-header h1, .single-page .page-header h1 {
    font-size: 2.5rem;
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.single-post .post-meta {
    font-size: 0.9rem;
    color: var(--md-text-secondary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.single-post .post-meta .views-count { /* Add this new block */
    display: inline-flex;
    align-items: center;
    gap: 5px; /* Space between icon and number */
}

.single-post .post-meta svg {
    width: 20px;
    height: 20px;
    color: var(--md-text-secondary-color);
}

.post-featured-image img, .page-featured-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--md-elevation-8);
}

.post-content, .page-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--md-text-color);
}

.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
    border-bottom: 1px solid var(--md-divider-color);
    padding-bottom: 0.5em;
    margin-top: 2.5rem;
    margin-bottom: 1.2rem;
}

.post-footer .post-tags {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--md-divider-color);
    color: var(--md-text-secondary-color);
    font-size: 0.9rem;
}

.post-footer .post-tags span {
    margin-left: 0.5rem;
    font-weight: bold;
}

.post-footer .post-tags a {
    display: inline-block;
    background-color: rgba(var(--md-primary-light), 0.1); /* Darker background */
    color: var(--md-primary-light); /* Lighter primary */
    padding: 0.3rem 0.8rem;
    border-radius: 16px;
    margin-left: 0.5rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.post-footer .post-tags a:hover {
    background-color: var(--md-primary-light); /* Lighter primary */
    color: var(--md-on-primary-color);
}

/* Pagination */
.pagination {
    margin-top: 2rem;
    text-align: center;
}

.pagination ul {
    display: inline-flex;
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: var(--md-surface-color);
    border-radius: 8px;
    box-shadow: var(--md-elevation-1);
    align-items: center; /* Added for vertical alignment */
}

.pagination li {
    margin: 0;
    padding: 0;
}

.pagination li a,
.pagination li span {
    display: block;
    padding: 0.7rem 1rem;
    text-decoration: none;
    color: var(--md-text-secondary-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.pagination li a:hover {
    background-color: rgba(var(--md-primary-light), 0.05); /* Darker hover */
    color: var(--md-primary-light); /* Lighter primary */
}

.pagination li.active span {
    background-color: var(--md-primary-color);
    color: var(--md-on-primary-color);
    border-radius: 4px;
    font-weight: bold;
}

/* Sidebar (for home-layout) */
.home-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .home-layout {
        grid-template-columns: 2fr 1fr; /* Main content 2/3, sidebar 1/3 */
    }
}

.sidebar-column {
    background-color: var(--md-surface-color);
    border-radius: 8px;
    box-shadow: var(--md-elevation-2);
    padding: 1.5rem;
    max-width: 320px; /* Limit sidebar width */
    justify-self: end; /* Align to the right in grid */
    align-self: start; /* Prevent stretching to the bottom */
}

.sidebar-column .widget-title {
    font-size: 1.3rem;
    color: var(--md-on-surface-color);
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--md-divider-color);
    padding-bottom: 0.5rem;
}

.sidebar-column .posts-list .post-item {
    background-color: transparent;
    box-shadow: none;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--md-divider-color);
    margin-bottom: 0.5rem;
}

.sidebar-column .posts-list .post-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-column .posts-list .post-item:hover {
    transform: none;
    background-color: rgba(255, 255, 255, 0.03); /* Darker hover */
}

.sidebar-column .posts-list .post-item h3 {
    font-size: 1.1rem;
    margin: 0;
}

.sidebar-column .posts-list .post-item h3 a {
    color: var(--md-on-surface-color);
}

.sidebar-column .posts-list .post-item .post-meta {
    font-size: 0.8rem;
    color: var(--md-text-disabled-color);
    margin-top: 0.3rem;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 3rem;
    background-color: var(--md-surface-color);
    border-radius: 8px;
    box-shadow: var(--md-elevation-4);
    margin-top: 3rem;
}

.error-page h1 {
    color: var(--md-error-color);
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-page p {
    font-size: 1.2rem;
    color: var(--md-text-secondary-color);
    margin-bottom: 2rem;
}

.error-page a {
    background-color: var(--md-primary-color);
    color: var(--md-on-primary-color);
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    text-transform: uppercase;
    box-shadow: var(--md-elevation-2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.error-page a:hover {
    background-color: var(--md-primary-light); /* Lighter primary on hover */
    box-shadow: var(--md-elevation-4);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .material-layout .main-header .container {
        flex-direction: column;
        text-align: center;
    }

    .material-layout .main-nav {
        margin-top: 1rem;
    }

    .material-layout .main-nav a {
        margin: 0 0.5rem;
    }

    .material-layout .site-logo {
        font-size: 1.5rem;
    }

    .material-layout .site-logo img {
        height: 30px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .single-post, .single-page {
        padding: 1.5rem;
    }

    .single-post .post-header h1, .single-page .page-header h1 {
        font-size: 2rem;
    }

    .posts-list {
        grid-template-columns: 1fr;
    }

    .hide-on-mobile {
        display: none;
    }

    .sidebar-column {
        max-width: 100%; /* Full width on mobile */
        justify-self: stretch;
    }
}
