/*
 * The Hidden Stars - Text-Centric Design
 * A clean, readable design optimized for neuroscience and astrocyte content
 */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.7;
    color: #2d3748;
    background-color: #fefefe;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-areas: 
        "main sidebar"
        "footer footer";
    gap: 2rem;
    min-height: 100vh;
}





/* Admin Bar */
.admin-bar {
    background: #1a202c;
    color: white;
    padding: 0.75rem 2rem;
}

.admin-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.admin-link {
    color: #cbd5e0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.admin-link:hover {
    color: white;
}

.logout-btn {
    background: none;
    border: none;
    color: #cbd5e0;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.logout-btn:hover {
    color: white;
}

/* Admin Layout */
.admin-layout {
    background: #f8fafc;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
}

.back-to-site-btn {
    background: #2c5aa0;
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-to-site-btn:hover {
    background: #1e3a5f;
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    margin: 0;
    font-family: Georgia, serif;
}

.admin-main-content {
    flex: 1;
}

.admin-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.admin-footer-content {
    color: #6b7280;
}

.admin-copyright {
    font-size: 0.875rem;
    margin: 0;
}

/* Main Content */
.main-content {
    padding: 0rem;
    background: white;
    border-radius: 8px;
    /*box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);*/
    margin-right: 1rem;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    padding: 2rem 1rem;
}

.widget {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.widget-title {
    font-size: 1.125rem;
    font-weight: bold;
    color: #1a202c;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.widget-content {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Blog Title Widget */
.blog-title-widget {
    background: #f8fafc;
    border: 2px solid #2c5aa0;
    text-align: center;
    overflow: hidden;
}

.blog-title-widget img{
    max-width: 100%;
    height: auto;
    margin: -2rem 0;
}

.blog-title-widget .site-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a202c;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.blog-title-widget .site-title-link {
    text-decoration: none;
    color: #2c5aa0;
    transition: color 0.2s ease;
}

.blog-title-widget .site-title-link:hover {
    color: #1e3a5f;
}

.blog-title-widget .site-tagline {
    font-size: 12px;
    color: #718096;
    font-weight: 400;
    font-style: italic;
    margin: 0;
}

/* Search Widget */
.search-widget .sidebar-search-form {
    display: flex;
    gap: 0.5rem;
}

.sidebar-search-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.875rem;
    background-color: #f8fafc;
    transition: border-color 0.2s ease;
    width: 100px;
}

.sidebar-search-input:focus {
    outline: none;
    border-color: #2c5aa0;
    background-color: white;
}

.sidebar-search-button {
    padding: 0.75rem 1rem;
    background-color: #2c5aa0;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.sidebar-search-button:hover {
    background-color: #1e3a5f;
}

.recent-posts-list {
    list-style: none;
}

.recent-post-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f7fafc;
}

.recent-post-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.recent-post-link {
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.recent-post-link:hover {
    color: #1e3a5f;
}

.recent-post-date {
    font-size: 0.8rem;
    color: #718096;
}

.categories-list {
    list-style: none;
}

.categories-list li {
    margin-bottom: 0.5rem;
}

.category-link {
    color: #4a5568;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.category-link:hover {
    color: #2c5aa0;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.newsletter-input {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.newsletter-input:focus {
    outline: none;
    border-color: #2c5aa0;
}

.newsletter-button {
    padding: 0.75rem;
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.newsletter-button:hover {
    background: #1e3a5f;
}

.newsletter-message {
    font-size: 0.875rem;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

.newsletter-message.success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.newsletter-message.error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: #1a202c;
    font-weight: bold;
    line-height: 1.3;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.125rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: 1.5rem;
    color: #4a5568;
}

a {
    color: #2c5aa0;
    text-decoration: underline;
    transition: color 0.2s ease;
}

a:hover {
    color: #1e3a5f;
}

blockquote {
    border-left: 4px solid #2c5aa0;
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background: #f7fafc;
    font-style: italic;
    color: #4a5568;
}

blockquote p {
    margin-bottom: 0;
}

code {
    background: #f7fafc;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #e53e3e;
}

pre {
    background: #1a202c;
    color: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2rem 0;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.875rem;
}

/* Lists */
ul, ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
}

li {
    margin: 0.5rem 0;
    color: #4a5568;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: -1.5rem 0;
}

figure {
    margin: 2rem 0;
}

figcaption {
    font-size: 0.875rem;
    color: #718096;
    text-align: center;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Footer */
.site-footer {
    grid-area: footer;
    background: #1a202c;
    color: #cbd5e0;
    padding: 3rem 2rem 2rem;
    border-radius: 8px 8px 0 0;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section {
    min-width: 0;
}

.footer-title {
    color: white;
    font-size: 1.125rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.footer-text {
    line-height: 1.6;
    margin-bottom: 0;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-link {
    color: #cbd5e0;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid #2d3748;
    padding-top: 2rem;
    text-align: center;
}

.copyright {
    color: #a0aec0;
    font-size: 0.875rem;
    margin: 0;
}

/* Alerts and Messages */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    border: 1px solid;
}

.alert-success {
    background: #f0fff4;
    color: #276749;
    border-color: #9ae6b4;
}

.alert-error {
    background: #fed7d7;
    color: #c53030;
    border-color: #feb2b2;
}

.alert-info {
    background: #ebf8ff;
    color: #2a69ac;
    border-color: #90cdf4;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
    border-color: #fbd38d;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.btn-primary {
    background: #2c5aa0;
    color: white;
}

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

.btn-secondary {
    background: white;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2d3748;
    font-weight: 500;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

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

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    font-weight: 600;
    color: #2d3748;
}

tr:hover {
    background: #f7fafc;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination-link,
.pagination-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0.5rem;
    text-decoration: none;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.pagination-link:hover,
.pagination-number:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.pagination-current {
    background: #2c5aa0;
    color: white;
    border-color: #2c5aa0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "sidebar"
            "footer";
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .site-header {
        padding: 1rem;
    }
    
    .nav-main {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .main-content {
        margin-right: 0;
        padding: 0rem;
    }
    
    .sidebar {
        padding: 1rem;
    }
    
    .site-footer {
        padding: 2rem 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .site-title {
        font-size: 1.75rem;
    }
    
    h1 {
        font-size: 1.875rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .search-form {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-input,
    .search-button {
        border-radius: 4px;
    }
    
    .admin-bar {
        margin: -1rem -1rem 1rem -1rem;
        padding: 0.75rem 1rem;
    }
    
    .admin-links {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 1.5rem;
    }
    
    h1 {
        font-size: 1.625rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .widget {
        padding: 1rem;
    }
    
    .pagination {
        flex-wrap: wrap;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .site-footer,
    .admin-bar,
    .newsletter-widget {
        display: none;
    }
    
    .container {
        grid-template-columns: 1fr;
        grid-template-areas: "main";
        max-width: none;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
        box-shadow: none;
        border-radius: 0;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: white;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
    
    pre {
        background: #f5f5f5;
        color: #000;
        border: 1px solid #ddd;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: white;
        color: black;
    }
    
    .main-content,
    .widget {
        background: white;
        border: 2px solid black;
    }
    
    .site-footer {
        background: black;
        color: white;
    }
    
    a {
        color: #0000ff;
    }
    
    a:hover {
        color: #ff0000;
    }
    
    .btn-primary {
        background: black;
        color: white;
        border: 2px solid black;
    }
    
    .btn-secondary {
        background: white;
        color: black;
        border: 2px solid black;
    }
}

/* Additional Component Styles */

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f7fafc;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background: #f7fafc;
}

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

/* Reading Progress */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(44, 90, 160, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-fill {
    height: 100%;
    background: #2c5aa0;
    width: 0%;
    transition: width 0.1s ease;
}

/* Character Counter */
.character-counter {
    font-size: 0.75rem;
    color: #718096;
    text-align: right;
    margin-top: 0.25rem;
}

/* Table of Contents */
.table-of-contents {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    border-left: 4px solid #2c5aa0;
}

.table-of-contents h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    color: #1a202c;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0.5rem 0;
}

.toc-h2 {
    margin-left: 0;
}

.toc-h3 {
    margin-left: 1rem;
}

.toc-h4 {
    margin-left: 2rem;
}

.toc-link {
    color: #2c5aa0;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.toc-link:hover {
    color: #1e3a5f;
    text-decoration: underline;
}

/* Code Block Wrapper */
.code-block-wrapper {
    position: relative;
    margin: 2rem 0;
}

.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.copy-code-btn.copied {
    background: #10b981;
}

.code-language-label {
    position: absolute;
    top: 0;
    left: 0;
    background: #2c5aa0;
    color: white;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 4px 0 4px 0;
    font-weight: 500;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 100;
}

.back-to-top:hover {
    background: #1e3a5f;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    margin: 30px;
}

.image-modal-close {
    position: absolute;
    top: -2rem;
    right: -2rem;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    transition: background 0.2s ease;
}

.image-modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.image-modal-caption {
    color: white;
    margin-top: 1rem;
    text-align: center;
    font-style: italic;
}

/* Admin Bar Enhancements */
.admin-bar {
    background: linear-gradient(135deg, #1a202c, #2d3748);
}

.admin-links {
    flex-wrap: wrap;
}

.admin-link {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Enhanced Alerts */
.alert {
    border-left: 4px solid;
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 4px;
    background: currentColor;
    opacity: 0.3;
}

.alert-success::before {
    background: #10b981;
}

.alert-error::before {
    background: #ef4444;
}

.alert-info::before {
    background: #3b82f6;
}

.alert-warning::before {
    background: #f59e0b;
}

/* Lazy Loading Images */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.loaded {
    opacity: 1;
}

/* Focus Indicators */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #2c5aa0;
    outline-offset: 2px;
}

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #2c5aa0;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 0 0 4px 4px;
}

.skip-link:focus {
    top: 6px;
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #2c5aa0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .image-modal {
        padding: 1rem;
    }
    
    .image-modal-close {
        top: -1rem;
        right: -1rem;
        font-size: 1.5rem;
        width: 35px;
        height: 35px;
    }
    
    .code-language-label {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .copy-code-btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading::after {
        animation: none;
    }
}