/**
 * EO-CMS Theme Styles
 * Light / Dark / Eye-care modes
 * Responsive design
 */

/* ===== Root Variables ===== */
:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-hover: #5a67d8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --link-color: #667eea;
    --link-hover: #5a67d8;
    --success: #48bb78;
    --error: #f56565;
    --warning: #ed8936;
    --font-body: "DejaVu Sans", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-heading: "DejaVu Sans", "Noto Sans", -apple-system, sans-serif;
    --font-mono: "DejaVu Sans Mono", "Consolas", monospace;
    --header-height: 60px;
    --max-content-width: 1200px;
    --border-radius: 8px;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --accent-primary: #7c9aff;
    --accent-secondary: #a78bfa;
    --accent-hover: #9f7aea;
    --border-color: #4a5568;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
    --link-color: #7c9aff;
    --link-hover: #a78bfa;
    --success: #68d391;
    --error: #fc8181;
    --warning: #f6ad55;
}

/* Eye-care theme (warm, low contrast) */
[data-theme="eye-care"] {
    --bg-primary: #f5f0e8;
    --bg-secondary: #ebe5d8;
    --bg-tertiary: #e0d8c8;
    --text-primary: #3d3425;
    --text-secondary: #5c4f3a;
    --text-muted: #8b7d6b;
    --accent-primary: #8b7355;
    --accent-secondary: #a08060;
    --accent-hover: #6b5a45;
    --border-color: #d4c8b0;
    --shadow-sm: 0 1px 3px rgba(61,52,37,0.1);
    --shadow-md: 0 4px 6px rgba(61,52,37,0.12);
    --shadow-lg: 0 10px 25px rgba(61,52,37,0.15);
    --link-color: #7a6248;
    --link-hover: #5a4a35;
    --success: #6a8f5e;
    --error: #b56557;
    --warning: #b8924a;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Esperanto diacritics support */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.3;
    font-weight: 600;
    margin-bottom: 0.8em;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1em; }

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

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

img { max-width: 100%; height: auto; }

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

.header-inner {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.site-logo:hover { text-decoration: none; }

.logo-icon { font-size: 1.5rem; }

/* ===== Navigation ===== */
.main-nav {
    flex: 1;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 6px;
    align-items: center;
}

.nav-list a {
    display: block;
    padding: 8px 14px;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-list a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s;
}

.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ===== Header Tools ===== */
.header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Language selector */
.lang-selector {
    position: relative;
}

.lang-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

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

.lang-btn .lang-auto {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    display: none;
    z-index: 1000;
    overflow: hidden;
    padding: 6px 0;
}

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

.lang-dropdown-header {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.lang-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 12px;
}

.lang-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.15s;
    text-decoration: none;
}

.lang-dropdown a:hover, .lang-dropdown a.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.lang-dropdown a.active {
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
    padding-left: 13px;
}

.lang-dropdown a small {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

.lang-dropdown a.lang-reset {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.lang-dropdown a.lang-reset:hover {
    color: var(--accent-primary);
}

/* Theme switcher */
.theme-switcher {
    position: relative;
}

.theme-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    line-height: 1;
}

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

.theme-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

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

.theme-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.theme-dropdown button:hover, .theme-dropdown button.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Text size controls */
.text-size-controls {
    display: flex;
    gap: 2px;
}

.text-size-controls button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s;
    line-height: 1.2;
}

.text-size-controls button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ===== Main Layout ===== */
.site-main {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 30px 20px;
    min-height: calc(100vh - var(--header-height) - 200px);
}

/* ===== Content Styles ===== */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    align-items: start;
}

.main-content {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

/* Article / Page content */
.eo-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 30px;
    border: 1px solid var(--border-color);
}

.eo-content h1 {
    margin-bottom: 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 2px solid var(--accent-primary);
}

.eo-content h2 {
    margin-top: 1.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-color);
}

.eo-content p {
    text-align: justify;
    text-align-last: left;
    hyphens: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.eo-content img {
    border-radius: var(--border-radius);
    margin: 1em 0;
    box-shadow: var(--shadow-sm);
}

.eo-content blockquote {
    border-left: 4px solid var(--accent-primary);
    padding: 15px 20px;
    margin: 1em 0;
    background: var(--bg-secondary);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.eo-content blockquote p:last-child { margin-bottom: 0; }

.eo-content code {
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.eo-content pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1em 0;
    border: 1px solid var(--border-color);
}

.eo-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
}

.eo-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.eo-content th, .eo-content td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.eo-content th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.eo-content tr:nth-child(even) {
    background: var(--bg-secondary);
}

.eo-content ul, .eo-content ol {
    padding-left: 1.8em;
    margin: 1em 0;
}

.eo-content li {
    margin: 0.4em 0;
}

.eo-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* ===== Meta bar ===== */
.content-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.content-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ===== Sidebar widgets ===== */
.sidebar-widget {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.sidebar-widget h4 {
    font-size: 1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-primary);
    color: var(--text-primary);
}

.sidebar-widget ul {
    list-style: none;
    padding: 0;
}

.sidebar-widget li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-widget li:last-child { border-bottom: none; }

.sidebar-widget a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-decoration: none;
    display: block;
    transition: color 0.15s;
}

.sidebar-widget a:hover {
    color: var(--accent-primary);
}

.widget-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-top: 3px;
}

/* ===== Lists (blog, forum, wiki) ===== */
.content-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.list-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    transition: all 0.2s;
}

.list-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.list-item h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.list-item h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.list-item h3 a:hover {
    color: var(--accent-primary);
}

.list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.list-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ===== Forum styles ===== */
.forum-board {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: all 0.2s;
}

.forum-board:hover {
    box-shadow: var(--shadow-md);
}

.board-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.board-info { flex: 1; }
.board-info h3 { margin-bottom: 6px; font-size: 1.1rem; }
.board-info p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.thread-list {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.thread-row {
    display: grid;
    grid-template-columns: 1fr 100px 80px;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.thread-row:last-child { border-bottom: none; }
.thread-row:hover { background: var(--bg-secondary); }

.thread-title { font-weight: 500; }
.thread-title a { color: var(--text-primary); text-decoration: none; }
.thread-title a:hover { color: var(--accent-primary); }

.thread-pinned .thread-title a::before {
    content: '📌 ';
}

.thread-stats {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.thread-last {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Wiki styles ===== */
.wiki-toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.wiki-toc h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.wiki-toc ul { list-style: none; padding: 0; }
.wiki-toc li { padding: 4px 0; }
.wiki-toc a { font-size: 0.95rem; text-decoration: none; }

/* ===== Media player ===== */
.eo-media-player {
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    max-width: 100%;
}

.eo-external-media {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.eo-external-media span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== PDF Export Button ===== */
.pdf-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.pdf-export-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    text-decoration: none;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.15s;
}

.pagination a {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.pagination span.current {
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-success {
    background: rgba(72, 187, 120, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: rgba(245, 101, 101, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

.alert-info {
    background: rgba(102, 126, 234, 0.15);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

/* ===== Footer ===== */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
    padding: 40px 20px 20px;
}

.footer-inner {
    max-width: var(--max-content-width);
    margin: 0 auto;
}

.footer-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 30px;
}

.footer-sections h4 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.footer-sections ul { list-style: none; }
.footer-sections li { padding: 6px 0; }
.footer-sections a { color: var(--text-muted); font-size: 0.9rem; text-decoration: none; }
.footer-sections a:hover { color: var(--accent-primary); }

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        order: 2;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 50px;
    }
    
    .header-inner {
        padding: 0 12px;
        gap: 10px;
    }
    
    .site-logo .logo-text {
        display: none;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .main-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-primary);
        z-index: 899;
        display: none;
        padding: 20px;
        overflow-y: auto;
    }
    
    .main-nav.open {
        display: block;
    }
    
    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    
    .nav-list a {
        padding: 12px 16px;
        font-size: 1.05rem;
    }
    
    .header-tools {
        gap: 6px;
    }
    
    .text-size-controls {
        display: none;
    }
    
    .site-main {
        padding: 16px 12px;
    }
    
    .eo-content {
        padding: 20px 16px;
    }
    
    .footer-sections {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .thread-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .thread-stats, .thread-last {
        text-align: left;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
}

@media (max-width: 480px) {
    .content-meta {
        font-size: 0.8rem;
        gap: 8px;
    }
    
    .eo-content {
        padding: 16px 12px;
    }
    
    .list-item {
        padding: 16px;
    }
}
