/* Anonymous Pro Font */
@font-face {
    font-family: 'Anonymous Pro';
    src: url('assets/fonts/anonymouspro.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Anonymous Pro';
    src: url('assets/fonts/anonymouspro-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
}

/* Color Variables Based on .Xresources */
:root {
    --background: #2E3440;
    --foreground: #D8DEE9;
    --border: #6b7280;
    --primary: #4B8EF7;
    --secondary: #34C759;
    --accent: #FFCB61;
    --error: #EA5B6F;
    --text-primary: #D8DEE9;
    --text-secondary: #6b7280;
    --surface: #3B4252;
    --op-background: #4C566A;
    --greentext: #2BC4B4;
    --link: #74a7ff;
    --border-width: 1px;
    --radius: 0;
}

/* General Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Anonymous Pro', monospace;
}

body {
    background: var(--background);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 180px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: var(--border-width) solid var(--border);
    padding: 10px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 10px;
}

.nav-item {
    padding: 5px;
    border: var(--border-width) solid var(--border);
    margin-bottom: 5px;
}

.nav-item a {
    color: var(--link);
    text-decoration: none;
    font-size: 13px;
}

.nav-item a:hover {
    text-decoration: underline;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 10px;
    margin-left: 180px; /* Offset for sidebar */
    width: calc(100% - 180px);
}

/* Welcome Section */
.welcome {
    text-align: left;
    margin-bottom: 15px;
    padding: 10px;
    border: var(--border-width) solid var(--border);
    max-width: 95%;
}

.welcome h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.welcome .datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.welcome p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

.content {
    padding: 10px;
    max-width: 95%;
}

/* Search Bar */
.search-bar {
    margin-bottom: 15px;
    display: flex;
    gap: 0;
}

#board-search {
    padding: 8px;
    width: 100%;
    max-width: 300px;
    border: var(--border-width) solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
}

#board-search:focus {
    border-color: var(--primary);
    outline: none;
}

.search-bar button {
    padding: 8px 15px;
    border: var(--border-width) solid var(--border);
    border-left: none;
    background: var(--primary);
    color: var(--foreground);
    font-size: 13px;
    cursor: pointer;
}

/* Boards Page */
.section {
    margin-bottom: 15px;
}

.section h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.board-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.board-item {
    padding: 5px 10px;
    border: var(--border-width) solid var(--border);
}

.board-item a {
    color: var(--link);
    text-decoration: none;
    font-size: 13px;
}

.board-item a:hover {
    text-decoration: underline;
}

/* Suggestions */
.suggestions {
    background: var(--surface);
    border: var(--border-width) solid var(--border);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 5px;
    display: none;
    max-width: 95%;
}

.suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 8px;
    border-bottom: var(--border-width) solid var(--border);
    cursor: pointer;
}

.suggestion-item span {
    font-size: 13px;
    font-weight: 700;
}

.suggestion-item p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* Filter Container */
.filter-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    max-width: 95%;
}

#thread-filter,
#thread-sort,
#media-filter {
    padding: 8px;
    border: var(--border-width) solid var(--border);
    font-size: 12px;
    background: var(--surface);
    color: var(--text-primary);
}

#thread-filter {
    flex: 1;
    min-width: 150px;
}

#thread-sort,
#media-filter {
    min-width: 100px;
}

/* Threads Page */
#threads-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 95%;
}

.thread-item {
    background: var(--surface);
    border: var(--border-width) solid var(--border);
    padding: 10px;
    cursor: pointer;
}

.thread-item.pinned {
    border-color: var(--primary);
}

.thread-item .content {
    display: flex;
    gap: 10px;
}

.thread-item .image-container {
    width: 60px;
    height: 60px;
    overflow: hidden;
}

.thread-item .image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thread-item .thread-info {
    flex: 1;
}

.thread-item .thread-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 5px;
}

.thread-item .username {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.thread-item .thread-preview {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 3.6em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-item .thread-stats {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.thread-item .replies-preview {
    margin-top: 10px;
    padding-top: 10px;
    border-top: var(--border-width) solid var(--border);
}

.thread-item .reply-preview-item {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 5px 0;
}

.thread-item .reply-preview-item img {
    max-width: 40px;
    max-height: 40px;
    margin-top: 3px;
}

.thread-item .pin-button,
.thread-item .tag-button,
.thread-item .open-button {
    background: none;
    border: none;
    color: var(--link);
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
}

/* Chat Page (Tree View) */
#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    max-width: 95%;
}

.message {
    background: var(--surface);
    border: var(--border-width) solid var(--border);
    padding: 10px;
    margin-left: 10px;
}

.message.op {
    background: var(--op-background);
    border-color: var(--primary);
}

.message.reply {
    margin-left: 20px;
}

.message .username {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3px;
}

.message .op-tag {
    background: var(--secondary);
    color: var(--foreground);
    font-size: 8px;
    padding: 2px 4px;
    margin-left: 5px;
}

.message .timestamp {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: 5px;
}

.message .message-content {
    font-size: 13px;
}

.message .greentext {
    color: var(--greentext);
}

.message .reply-link {
    color: var(--link);
    cursor: pointer;
    text-decoration: none;
}

.message .reply-link:hover {
    text-decoration: underline;
}

.message img {
    max-width: 200px;
    margin-top: 5px;
    cursor: pointer;
}

/* Image Hover */
#ihover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#ihover.active {
    display: flex;
}

#ihover img,
#ihover video {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

/* Dialogs */
.dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.dialog.active {
    display: flex;
}

.dialog-content {
    background: var(--surface);
    border: var(--border-width) solid var(--border);
    padding: 10px;
    max-width: 350px;
    width: 90%;
}

.dialog-header {
    margin-bottom: 10px;
}

.dialog-header h2 {
    font-size: 14px;
    font-weight: 700;
}

.dialog-close {
    background: none;
    border: none;
    color: var(--link);
    font-size: 12px;
    cursor: pointer;
}

/* Reply Preview */
#reply-preview-popup {
    background: var(--surface);
    border: var(--border-width) solid var(--border);
    padding: 10px;
    max-width: 300px;
    position: fixed;
    z-index: 1001;
}

#reply-preview-popup .username {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}

#reply-preview-popup .timestamp {
    font-size: 10px;
    color: var(--text-secondary);
}

#reply-preview-popup .message-content {
    font-size: 13px;
    margin-top: 5px;
}

#reply-preview-popup img {
    max-width: 100px;
    margin-top: 5px;
}

/* Buttons */
.btn {
    padding: 5px 10px;
    border: var(--border-width) solid var(--border);
    font-size: 12px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
}

.btn.primary {
    background: var(--primary);
    color: var(--foreground);
    border-color: var(--primary);
}

.btn.secondary {
    background: none;
    color: var(--link);
}

/* Settings Dialog */
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.settings-item span {
    font-size: 13px;
}

.settings-section {
    margin-top: 10px;
}

.settings-section h3 {
    font-size: 13px;
    font-weight: 700;
}

.selector-list,
.tag-list {
    max-height: 150px;
    overflow-y: auto;
}

.favorite-board-item,
.thread-tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: var(--border-width) solid var(--border);
}

.thread-tag-item button {
    background: none;
    border: none;
    color: var(--error);
    font-size: 12px;
    cursor: pointer;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 16px;
}

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

.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background: var(--foreground);
}

input:checked + .slider {
    background: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(14px);
}

/* Image Modal */
.image-modal-content {
    padding: 0;
    max-width: 80vw;
    max-height: 80vh;
    background: transparent;
    border: none;
}

#modal-image {
    max-width: 100%;
    max-height: 80vh;
    border: var(--border-width) solid var(--border);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .nav-drawer {
        width: 100%;
        max-width: 180px;
        background: var(--surface);
        border-right: var(--border-width) solid var(--border);
        position: fixed;
        top: 0;
        left: -180px;
        height: 100%;
        transition: left 0.3s ease;
    }

    .nav-drawer.active {
        left: 0;
    }

    .board-links {
        flex-direction: column;
    }

    .thread-item .content {
        flex-direction: column;
    }

    .thread-item .image-container {
        width: 100%;
        height: 80px;
    }

    .filter-container {
        flex-direction: column;
    }

    #thread-filter,
    #thread-sort,
    #media-filter {
        width: 100%;
    }

    .dialog-content {
        width: 95%;
    }

    .welcome,
    .content,
    #threads-list,
    #chat-messages,
    .suggestions {
        max-width: 100%;
    }

    #ihover img,
    #ihover video {
        max-width: 95vw;
        max-height: 95vh;
    }
}
