/* marsStation - Main Stylesheet */
/* Author: Matthew A. Roberts */

/* ============ RESET & BASE ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
}

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

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

/* ============ HEADER ============ */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
}

.site-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.site-icon-btn:hover {
    background: var(--bg-hover);
}

.site-icon {
    width: 32px;
    height: 32px;
}

.header-center {
    flex: 1;
    text-align: center;
}

.banner-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.banner-image {
    max-height: 40px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.login-btn {
    padding: 0.4rem 1.2rem;
    background: var(--accent);
    color: white !important;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.user-btn:hover {
    background: var(--bg-hover);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 200;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
}

/* ============ FLASH MESSAGES ============ */
.flash {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* ============ MAIN LAYOUT ============ */
.main-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ============ SIDEBARS ============ */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

.sidebar.context-bar {
    border-right: none;
    border-left: 1px solid var(--border);
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    opacity: 0;
    border: none;
}

.sidebar.closed {
    display: none;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-title {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}

.sidebar-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-content {
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.sidebar-header {
    padding: 0.75rem 1rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

.sidebar-info {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.sidebar-btn {
    display: block;
    width: calc(100% - 2rem);
    margin: 0.25rem 1rem;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* ============ CONTENT AREA ============ */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    min-width: 0;
}

.content-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem 2rem;
    max-width: 960px;
    margin: 0 auto 1.5rem;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.content-header h2 {
    margin: 0;
}

/* ============ FOOTER ============ */
.site-footer {
    background: var(--bg-header);
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    text-align: center;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.footer-copyright {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============ CARDS & GRIDS ============ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.card h3 {
    margin-bottom: 0.5rem;
}

.card h3 a {
    color: var(--text-primary);
}

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

.card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.card-image {
    margin: -1.25rem -1.25rem 1rem;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    max-height: 200px;
}

.card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* ============ FORMS ============ */
.form {
    max-width: 640px;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-shadow);
}

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

.form-group input[type="file"] {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

fieldset legend {
    font-weight: 600;
    padding: 0 0.5rem;
    color: var(--text-muted);
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    color: white !important;
}

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

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--error-text);
    color: white !important;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-small {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
}

.text-danger {
    color: var(--error-text) !important;
}

/* ============ ALERTS ============ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-text);
}

/* ============ TABLES ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============ BLOG SPECIFIC ============ */
.entry-list {
    margin-top: 1rem;
}

.entry-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

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

.entry-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
    flex-wrap: wrap;
}

.entry-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Reactions */
.reactions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.reaction-btn:hover:not([disabled]) {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.reaction-btn.active {
    border-color: var(--accent);
    background: var(--accent-shadow);
}

.reaction-btn[disabled] {
    cursor: default;
    opacity: 0.6;
}

.reaction-emoji {
    font-size: 1.1rem;
}

.reaction-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Comments */
.comment-form {
    margin-bottom: 1.5rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.comments-list {
    margin-top: 1rem;
}

.comment {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}

.comment-body {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============ ARTICLES ============ */
.article-hero {
    margin: -1.5rem -2rem 1.5rem;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    max-height: 300px;
}

.article-hero img {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.article-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.75rem 0 1.5rem;
}

.badge {
    background: var(--accent);
    color: white;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.article-description {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.article-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ============ BREADCRUMB ============ */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

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

/* ============ RICH CONTENT ============ */
.rich-content {
    line-height: 1.8;
    font-size: 1rem;
}

.rich-content h2, .rich-content h3, .rich-content h4 {
    margin: 1.5rem 0 0.75rem;
}

.rich-content p {
    margin-bottom: 1rem;
}

.rich-content ul, .rich-content ol {
    margin: 0.75rem 0 0.75rem 2rem;
}

.rich-content li {
    margin-bottom: 0.35rem;
}

.rich-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.rich-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
}

.rich-content pre {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
}

.rich-content code {
    background: var(--bg-card);
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ============ UTILITIES ============ */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.text-link {
    font-size: 0.85rem;
}

.inline-form {
    display: inline;
}

/* ============ OPPOSITE DAY ADJUSTMENTS ============ */
.template-opposite-day {
    flex-direction: column;
}

.template-opposite-day .site-header {
    position: sticky;
    bottom: 0;
    top: auto;
    border-top: 1px solid var(--border);
    border-bottom: none;
}

.template-opposite-day .site-footer {
    border-bottom: 1px solid var(--border);
    border-top: none;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 60px;
        bottom: 0;
        z-index: 50;
        box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    }

    .activity-bar {
        left: 0;
    }

    .context-bar {
        right: 0;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .context-bar.collapsed {
        transform: translateX(100%);
    }

    .content-area {
        padding: 1rem;
    }

    .content-card {
        padding: 1rem 1.25rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .banner-text {
        font-size: 1.1rem;
    }
}
