@font-face {
    font-family: 'Iosevka';
    src: url('/static/fonts/SGr-IosevkaTerm-Regular.ttc') format('collection');
    font-weight: normal;
    font-style: normal;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #010409;
    color: #e6edf3;
}

a {
    color: #58a6ff;
    text-decoration: none;
}

a:hover {
    color: #79c0ff;
    text-decoration: underline;
}

header {
    background: #264f78;
    color: #e6edf3;
    padding: 0.2rem 0.5rem;
    text-align: left;
    font-size: 0.9rem;
    font-family: monospace;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    justify-content: space-between;
}

header .boards {
    flex-grow: 1;
}

header .utc-time {
    text-align: right;
    white-space: nowrap;
}

header a {
    color: #e6edf3;
    text-decoration: none;
}

header a:hover {
    color: #e3b341;
    text-decoration: none;
}

main {
    margin: 0;
    padding: 1rem 1rem 3rem 10px;
}

/* Image expansion */
.post-media img {
    cursor: pointer;
}

.post-media.expanded-container {
    flex-shrink: 1;
    max-width: 100%;
}

.post-media.expanded-container img {
    max-width: 100%;
    max-height: calc(100vh - 6rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    max-width: calc(80ch + 250px);
}

.alert.success {
    background-color: #0d2818;
    border: 1px solid #3fb950;
    color: #e6edf3;
}

.alert.error {
    background-color: #2d1418;
    border: 1px solid #ff7b72;
    color: #e6edf3;
}

.alert code {
    background-color: #161b22;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 1.1em;
    color: #e3b341;
}

/* Make a Post toggle */
.toggle-wrapper {
    max-width: calc(80ch + 250px);
    text-align: center;
}

.make-post-toggle {
    display: inline-block;
    padding: 0px 4px;
    cursor: pointer;
    color: #e6edf3;
    background: #264f78;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 1rem;
    border-top: 1px solid #79c0ff;
    border-left: 1px solid #79c0ff;
    border-right: 1px solid #0d1117;
    border-bottom: 1px solid #0d1117;
    box-shadow: 1px 1px 0 #1C1C1C;
    text-align: center;
    user-select: none;
    font-family: monospace;
}

.make-post-toggle:hover {
    color: #ffffff;
    background: #58a6ff;
    border-top: 1px solid #79c0ff;
    border-left: 1px solid #79c0ff;
    border-right: 1px solid #0d1117;
    border-bottom: 1px solid #0d1117;
    text-decoration: none;
}

/* Floating Forms */
.floating-form {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: #161b22;
    border: 1px solid #484f58;
    border-radius: 0;
    width: 320px;
    min-width: 250px;
    max-width: 90vw;
    font-family: 'Iosevka', monospace;
    resize: both;
    overflow: auto;
    z-index: 2500;
    box-shadow: 8px 8px 0 #1C1C1C;
}

.floating-form.collapsed {
    display: none;
}

.form-header {
    background: #0d1117;
    padding: 0.5rem 1rem;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #484f58;
    user-select: none;
}

.form-header span {
    color: #e6edf3;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-close {
    background: none;
    border: none;
    color: #6e7681;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
}

.form-close:hover {
    color: #ff7b72;
}

.floating-form form {
    padding: 1rem;
    text-align: center;
}

/* Edit form (non-floating) */
.edit-form {
    background: #161b22;
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid #484f58;
    margin-bottom: 1.5rem;
    max-width: calc(80ch + 250px);
}

.edit-form h2 {
    margin-bottom: 1rem;
    color: #e6edf3;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #b1bac4;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #484f58;
    border-radius: 4px;
    font-size: 1rem;
    font-family: 'Iosevka', monospace;
    background-color: #0d1117;
    color: #e6edf3;
}

.form-row input[type="text"]:focus,
.form-row input[type="password"]:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #58a6ff;
}

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

.form-row input[type="file"] {
    padding: 0.5rem 0;
    color: #b1bac4;
}

button[type="submit"],
.delete-btn {
    display: inline-block;
    padding: 0px 4px;
    cursor: pointer;
    color: #e6edf3;
    background: #264f78;
    font-size: 0.9rem;
    font-weight: bold;
    font-family: monospace;
    border-top: 1px solid #79c0ff;
    border-left: 1px solid #79c0ff;
    border-right: 1px solid #0d1117;
    border-bottom: 1px solid #0d1117;
    box-shadow: 1px 1px 0 #1C1C1C;
    border-radius: 0;
    user-select: none;
}

button[type="submit"]:hover {
    color: #ffffff;
    background: #58a6ff;
    border-top: 1px solid #79c0ff;
    border-left: 1px solid #79c0ff;
    border-right: 1px solid #0d1117;
    border-bottom: 1px solid #0d1117;
}

.floating-form .form-row {
    text-align: left;
}

.delete-btn {
    background: #ff7b72;
    border-color: #ffa198;
}

.delete-btn:hover {
    background: #ffa198;
}

.replying-to {
    background: #0d1117;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid #484f58;
}

.replying-to button {
    background: #264f78;
    border: 1px solid #58a6ff;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 0.5rem;
    color: #e6edf3;
}

.replying-to button:hover {
    background: #58a6ff;
    color: #ffffff;
}

/* Thread List */
.thread-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: calc(80ch + 250px);
}

.thread-preview {
    background: #161b22;
    border-radius: 0;
    border: 1px solid #484f58;
    overflow: hidden;
    box-shadow: 8px 8px 0 #1C1C1C;
}

.omitted-notice {
    background: #0d1117;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #6e7681;
    border-top: 1px solid #21262d;
}

.recent-replies {
    border-top: 1px solid #484f58;
}

/* Posts */
.post {
    display: flex;
    padding: 1rem;
    gap: 1rem;
    border-bottom: 1px solid #484f58;
    font-family: 'Iosevka', monospace;
}

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

.post.op {
    background: #161b22;
}

.post.op .post-body {
    color: #e3b341;
}

.post.reply {
    background: #0d1117;
}

.post-media {
    flex-shrink: 0;
    position: relative;
}

.post-media img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 0;
    display: block;
    border: 1px solid #484f58;
}

.video-indicator {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: #ff7b72;
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
}

.epub-icon {
    width: 100px;
    height: 130px;
    background: #21262d;
    border: 1px solid #484f58;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #e3b341;
}

.post-content {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
}

.post-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.post-title {
    font-weight: bold;
    color: #39c5cf;
}

.post-name {
    font-weight: bold;
    color: #3fb950;
}

.post-date {
    color: #6e7681;
}

.post-id {
    color: #6e7681;
    text-decoration: none;
}

a.post-id:hover {
    color: #58a6ff;
}

.edited {
    color: #d29922;
    font-style: italic;
    font-size: 0.85em;
}

.post-actions {
    margin-left: auto;
}

.post-actions a {
    color: #58a6ff;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.collapse-btn {
    background: #0d1117;
    border: 1px solid #484f58;
    border-radius: 3px;
    padding: 0 0.4rem;
    cursor: pointer;
    font-family: monospace;
    color: #b1bac4;
}

.collapse-btn:hover {
    background: #21262d;
    color: #e6edf3;
}

.post-body {
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #e6edf3;
    max-width: 80ch;
}

.post-footer {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.post-footer a {
    margin-right: 1rem;
}

.reply-count {
    color: #6e7681;
}

/* Post wrapper for nested layout */
.post-wrapper {
    display: flex;
    flex-direction: column;
}

/* Nested replies */
.replies {
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.replies.collapsed {
    display: none;
}

/* Thread View */
.thread-view {
    background: #161b22;
    border-radius: 4px;
    border: 1px solid #484f58;
    margin-bottom: 1.5rem;
    max-width: calc(80ch + 250px);
}

.thread-view .post-wrapper {
    border-bottom: 1px solid #484f58;
}

.thread-view .post-wrapper:last-child {
    border-bottom: none;
}

.thread-view .replies > .post-wrapper {
    border-top: 1px solid #484f58;
    border-bottom: none;
}

.thread-view .replies .replies {
    background-color: #010409;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Crect x='0' y='0' width='1' height='1' fill='%23484f58'/%3E%3C/svg%3E");
    background-size: 8px 8px;
    background-attachment: fixed;
}

.thread-view .replies .replies > .post-wrapper {
    background-color: #0d1117;
}

.thread-view .post {
    border-bottom: none;
}

.thread-header {
    padding: 1rem;
    border-bottom: 1px solid #484f58;
    background-color: #161b22;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #161b22;
    border-radius: 4px;
    border: 1px solid #484f58;
    max-width: calc(80ch + 250px);
}

.pagination a {
    padding: 0.5rem 1rem;
    background: #264f78;
    color: #e6edf3;
    border-radius: 4px;
    border: 1px solid #58a6ff;
}

.pagination a:hover {
    background: #58a6ff;
    text-decoration: none;
}

.no-threads {
    text-align: center;
    padding: 2rem;
    color: #6e7681;
    background: #161b22;
    border-radius: 4px;
    border: 1px solid #484f58;
    max-width: calc(80ch + 250px);
}

/* Edit form specific */
.edit-form hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #484f58;
}

.edit-form h3 {
    margin-bottom: 1rem;
    color: #ff7b72;
}

.form-actions {
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
    .post {
        flex-direction: column;
    }

    .post-media img {
        max-width: 100%;
    }

    .post-header {
        font-size: 0.8rem;
    }

    .post-actions {
        margin-left: 0;
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Scrollbar styling for tek theme */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #010409;
}

::-webkit-scrollbar-thumb {
    background: #484f58;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #58a6ff;
}
