/* ==========================================
   ITchan - Old School Gray Theme
   ========================================== */

:root {
    --bg-page: #e2e2e2;
    --bg-post: #d3d3d3;
    --bg-form: #d3d3d3;
    --bg-input: #f8f9fa;

    --text: #212529;
    --text-dim: #495057;
    --text-dark: #6c757d;

    --border: #b4b4b4;

    --link: #495057;
    --link-hover: #212529;

    --subject: #5b6eb5;

    --green: #789922;
    --red: #c92a2a;
    --orange: #e67700;

    --success-bg: #d4edda;
    --success-text: #155724;
    --success-border: #28a745;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --error-border: #dc3545;

    --font: Verdana, Geneva, sans-serif;
    --font-mono: Consolas, 'Courier New', monospace;
}

/* ==========================================
   Reset
   ========================================== */
* { box-sizing: border-box; }

body {
    font-family: var(--font);
    font-size: 14px;
    margin: 0;
    padding: 4px;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.3;
    -webkit-text-size-adjust: 100%;  /* Prevent font scaling in landscape */
}

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

h1, h2, h3 {
    color: var(--text);
    margin: 0.3em 0;
    font-weight: bold;
}
h1 { font-size: 1.5em; }
h2 { font-size: 1.25em; }
h3 { font-size: 1.1em; }

hr {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

blockquote {
    margin: 0.3em 0 0.3em 0.3em;
    padding: 0;
}

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

del {
    text-decoration: line-through;
    color: var(--text-dark);
}

.spoiler {
    background: var(--text);
    color: transparent;
}
.spoiler:hover {
    background: none;
    color: var(--text);
}

/* Code */
pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-left: 2px solid var(--text-dim);
    padding: 4px 6px;
    margin: 2px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.3;
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

code {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0 3px;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ==========================================
   Header
   ========================================== */
.site-header {
    background: var(--bg-form);
    padding: 2px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    margin-bottom: 8px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.site-title {
    margin: 0 10px 0 0;
    font-size: 1.1em;
}
.site-title a {
    color: var(--text);
    text-decoration: none;
}
.site-title a:hover {
    text-decoration: none;
    color: var(--link-hover);
}

.auth-links {
    font-size: 12px;
}
.auth-links a {
    margin-left: 4px;
}
.auth-links span.user-info {
    color: var(--text-dim);
}

/* ==========================================
   Content
   ========================================== */
.content {
    padding: 0 4px;
}

/* Center only homepage/board list */
.index-container {
    max-width: 800px;
    margin: 0 auto;
}

.index-container h1 {
    text-align: center;
}

/* ==========================================
   Board List
   ========================================== */
.boards-list {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
    line-height: 1.8;
    font-size: 15px;
    text-align: center;
}

.boards-list li {
    margin-bottom: 3px;
}

.boards-list a {
    font-weight: bold;
}

.board-category {
    font-size: 1.1em;
    margin: 15px 0 8px 0;
    text-align: center;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.corporate-badge {
    font-size: 14px;
    margin-left: 4px;
    cursor: help;
    vertical-align: middle;
}

.boards-list .delete-form {
    margin-left: 4px;
}
/* Shared form styles for inline action buttons */
.delete-form, .blacklist-form, .pin-form {
    display: inline;
    margin: 0;
    padding: 0;
}

/* Shared action button base styles */
.action-button,
.delete-button,
.blacklist-button,
.pin-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    font-size: 12px;
    font-family: var(--font);
    color: inherit;
    text-decoration: none;
}
.action-button:hover,
.delete-button:hover,
.blacklist-button:hover,
.pin-button:hover {
    text-decoration: underline;
}

/* Board-specific delete button styling */
.boards-list .delete-button {
    color: var(--red);
    text-decoration: underline;
}

.pinned-indicator {
    color: var(--orange);
    font-weight: bold;
    margin-right: 3px;
}

/* ==========================================
   Forms
   ========================================== */
.post-form-container, .admin-panel, .auth-form {
    background: var(--bg-form);
    padding: 4px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    display: inline-block;
    vertical-align: top;
}

.form-table {
    border-collapse: collapse;
}

.form-table td {
    padding: 1px 3px;
    vertical-align: middle;
    font-size: 14px;
}

.form-table td.form-label {
    text-align: left;
    font-weight: bold;
    color: var(--text-dim);
    padding-right: 6px;
    white-space: nowrap;
}

.form-table tr:has(textarea) td.form-label {
    vertical-align: top;
    padding-top: 3px;
}

.form-table input[type="text"],
.form-table input[type="password"],
.form-table input[type="email"],
.form-table textarea {
    margin: 0;
    padding: 2px 3px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
}

.form-table textarea {
    width: 100%;
    max-width: 100%;
    resize: vertical;
    line-height: 1.3;
    min-height: 40px;
}

.form-table input:focus,
.form-table textarea:focus {
    border-color: var(--text-dim);
    outline: none;
}

.form-table button[type="submit"],
button[type="submit"] {
    padding: 2px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
}
.form-table button[type="submit"]:hover,
button[type="submit"]:hover {
    background: var(--border);
}

.form-table small {
    font-size: 12px;
    color: var(--text-dark);
}

.admin-panel {
    max-width:  1200px;
}
.admin-panel h2 {
    margin-top: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

/* ==========================================
   Posts
   ========================================== */
.post {
    background: var(--bg-post);
    margin: 2px 0;
    padding: 2px 4px 4px 4px;
    border: 1px solid var(--border);
    overflow: hidden;
    line-height: 1.3;
    display: block;
    width: fit-content;
    max-width: 100%;
}

.post.op-post {
    background: var(--bg-page);
    border: none;
    /* border-left: 2px solid var(--text-dim); */
}

.post.reply-post {
    margin-left: 15px;
}

.post-header {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 2px;
    /* white-space: nowrap; */
    /* overflow-x: auto; */
    flex-wrap: wrap;
    display: flex;
    gap: 2px;
    align-items: center;
}
.post-header input[type="checkbox"] {
    margin: 0 3px 0 0;
    vertical-align: middle;
}

.post-subject {
    color: var(--subject);
    font-weight: bold;
    margin-right: 5px;
    font-size: 14px;
}

.post-author {
    font-weight: bold;
    color: var(--text-dim);
    margin-right: 5px;
    font-size: 11px;
}

.post-author .admin-badge {
    color: var(--orange);
    font-size: 12px;
}

.post-date {
    margin-right: 5px;
    color: var(--text-dark);
}

.post-id {
    margin-right: 5px;
}
.post-id a {
    color: var(--link);
    text-decoration: none;
}
.post-id a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.post-reply,
.post-reply-popup {
    margin-right: 5px;
}
.post-reply a,
.post-reply-popup a {
    color: var(--text-dark);
    text-decoration: none;
}
.post-reply a:hover,
.post-reply-popup a:hover {
    color: var(--text-dim);
    text-decoration: underline;
}

.reply-links {
    display: inline;
}
.reply-link {
    margin-right: 3px;
}
.reply-link a {
    color: var(--link);
    text-decoration: underline;
    font-size: 11px;
}

.reply-to-info {
    color: var(--text-dark);
    margin-left: 3px;
    font-size: 12px;
    font-style: italic;
}
.reply-to-info a {
    color: var(--link);
}

/* Attachments */
.post-attachments {
    font-size: 12px;
    margin: 3px 0;
    padding-left: 15px;
    color: var(--text-dark);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.attachment-item {
    display: flex;
    flex-direction: column;
}

.attachment-item:has(.attachment-thumbnail) {
    width: min-content;
}

.attachment-link {
    display: block;
    line-height: 0;
}

.attachment-thumbnail {
    display: block;
    margin-bottom: 2px;
    height: auto;
}

.op-post .attachment-thumbnail {
    max-width: 225px;
}

.reply-post .attachment-thumbnail,
.message-preview .attachment-thumbnail {
    max-width: 150px;
}

.attachment-info {
    font-size: 11px;
    word-break: break-word;
}

.post-body {
    color: var(--text);
    line-height: 1.4;
    overflow-wrap: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 600px;
}
.post-body p {
    margin: 0;
}

.post.my-message {
    border-left: 2px dotted var(--subject);
}

/* ==========================================
   Board Page
   ========================================== */
.board-header h1 {
    text-align: center;
    font-size: 1.8em;
    margin-bottom: 4px;
}
.board-header h1 a {
    color: var(--text);
    text-decoration: none;
}
.board-header h1 a:hover {
    text-decoration: underline;
}

.reply-summary {
    font-size: 12px;
    margin-left: 15px;
    margin-top: 3px;
    color: var(--text-dark);
    font-style: italic;
}

/* ==========================================
   Thread Page
   ========================================== */
.thread-header {
    margin-bottom: 4px;
}
.thread-header .nav-links,
.nav-links {
    font-size: 12px;
}
.nav-links a {
    margin: 0 3px;
    color: var(--link);
}

#bottom {
    display: block;
    height: 1px;
}

/* ==========================================
   Messages
   ========================================== */
.success-message, .error-message {
    border: 1px solid var(--border);
    padding: 4px 6px;
    margin: 6px 0;
    font-size: 14px;
    font-weight: bold;
}

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

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

/* ==========================================
   Footer
   ========================================== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 4px 0;
    text-align: center;
    color: var(--text-dark);
    font-size: 11px;
    margin-top: 15px;
}

.footer-info p {
    margin: 1px 0;
}

/* ==========================================
   Pagination
   ========================================== */
.pagination {
    text-align: center;
    margin: 8px 0;
    font-size: 14px;
    font-weight: bold;
}

.pagination span {
    color: var(--text-dark);
    margin: 0 2px;
}

.pagination a {
    text-decoration: none;
    margin: 0 2px;
}

.pagination .page-form {
    display: inline;
}

.pagination .page-input {
    width: 2.5em;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    padding: 1px;
}

/* ==========================================
   Message Preview
   ========================================== */
.message-preview {
    position: absolute;
    max-width: 700px;
    min-width: 250px;
    background: var(--bg-post);
    border: 1px solid var(--text-dim);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    z-index: 1000;
}


.message-preview .post-body {
    max-height: 250px;
    overflow-y: auto;
}

.message-preview.error-preview {
    background: var(--error-bg);
    border-color: var(--red);
}
.message-preview.error-preview .post-header {
    color: var(--red);
}
.message-preview.error-preview .post-body {
    color: var(--red);
    font-style: italic;
}

.message-preview.loading .post-body {
    color: var(--text-dark);
    font-style: italic;
}

.message-link {
    cursor: pointer;
    color: var(--link);
}

/* ==========================================
   Popup Reply
   ========================================== */
.popup-reply-container {
    position: absolute;
    z-index: 1000;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    cursor: move;
}

.popup-reply-container textarea,
.popup-reply-container button,
.popup-reply-container input,
.popup-reply-container select,
.popup-reply-container label,
.popup-reply-container a {
    cursor: auto;
}

.popup-close-btn {
    position: absolute;
    top: 1px;
    right: 4px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--text-dark);
}
.popup-close-btn:hover {
    color: var(--red);
}

/* ==========================================
   File Preview
   ========================================== */
.file-hint {
    font-size: 11px;
    color: var(--text-dark);
    font-style: italic;
    margin: 2px 0 4px;
}

.file-preview-list {
    margin-top: 6px;
}

.file-preview-header {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-dim);
    margin-bottom: 3px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 3px 5px;
    margin-bottom: 3px;
    font-size: 12px;
}

.file-preview-thumbnail {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.file-preview-icon {
    font-size: 20px;
    width: 30px;
    text-align: center;
}

.file-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-size {
    color: var(--text-dark);
    font-size: 11px;
}

.file-preview-remove {
    background: var(--red);
    color: #fff;
    border: none;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

/* ==========================================
   Account Page
   ========================================== */
.account-info {
    background: var(--bg-form);
    padding: 8px;
    margin: 8px 0;
    border: 1px solid var(--border);
}

.account-info p {
    margin: 3px 0;
}

/* ==========================================
   Selection
   ========================================== */
::selection {
    background: var(--text-dim);
    color: var(--bg-input);
}

/* ==========================================
   Welcome Message
   ========================================== */
.welcome-message {
    background: var(--bg-form);
    border: 1px solid var(--border);
    padding: 10px 15px;
    margin-bottom: 15px;
    text-align: center;
    line-height: 1.5;
}

.welcome-message p {
    margin: 5px 0;
}

/* ==========================================
   FAQ Page
   ========================================== */
.faq-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 10px;
}

.faq-container h1 {
    text-align: center;
    margin-bottom: 20px;
}

.faq-section {
    background: var(--bg-form);
    border: 1px solid var(--border);
    padding: 12px 15px;
    margin-bottom: 15px;
}

.faq-section h2 {
    margin-top: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.faq-section h3 {
    margin-top: 12px;
    color: var(--text-dim);
}

.faq-section ul {
    margin: 8px 0;
    padding-left: 25px;
}

.faq-section li {
    margin-bottom: 4px;
}

.faq-examples-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
}

.faq-examples-table th,
.faq-examples-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.faq-examples-table th {
    background: var(--bg-post);
    font-weight: bold;
}

.faq-examples-table td:first-child {
    background: var(--success-bg);
}

.faq-examples-table td:last-child {
    background: var(--error-bg);
}

/* ==========================================
   Legal Pages (About, Terms, Privacy, Contacts)
   ========================================== */
.legal-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    line-height: 1.6;
}

.legal-container h1 {
    font-size: 2em;
    margin-bottom: 20px;
}

.legal-container h2 {
    font-size: 1.5em;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
}

.legal-container h3 {
    font-size: 1.2em;
    margin-top: 20px;
    margin-bottom: 10px;
}

.legal-container p {
    margin: 10px 0;
}

.legal-container ul,
.legal-container ol {
    margin-left: 20px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.legal-container li {
    margin: 5px 0;
}

.legal-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.legal-container table th,
.legal-container table td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.legal-container table th {
    background: var(--bg-post);
    font-weight: bold;
}

.legal-container pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 10px;
    overflow-x: auto;
    font-size: 12px;
    margin: 10px 0;
}

.legal-container code {
    background: var(--bg-input);
    padding: 2px 4px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.legal-section {
    margin-bottom: 30px;
}

.info-block {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 15px;
    margin: 15px 0;
}

.info-block ul {
    margin-left: 0;
    list-style-position: inside;
}

.legal-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 0.9em;
    color: var(--text-dim);
}

/* ==========================================
   Agreement Notice (Registration Forms)
   ========================================== */
.agreement-notice {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.agreement-notice p {
    margin: 0;
}

.agreement-notice a {
    color: var(--link);
    text-decoration: underline;
}

.agreement-notice a:hover {
    color: var(--link-hover);
}

/* ==========================================
   Footer Links
   ========================================== */
.footer-links {
    margin-top: 8px;
    font-size: 0.95em;
}

.footer-links a {
    color: var(--link);
    text-decoration: underline;
}

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

/* ==========================================
   Mobile Responsive Adjustments
   ========================================== */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        padding: 2px;
    }

    /* Increase touch target sizes */
    .form-table button[type="submit"],
    button[type="submit"] {
        padding: 8px 12px;
        font-size: 16px;  /* Prevent iOS zoom on focus */
        min-height: 44px; /* iOS recommended touch target */
    }

    .form-table input[type="text"],
    .form-table input[type="password"],
    .form-table input[type="email"],
    .form-table textarea {
        font-size: 16px;  /* Prevent iOS zoom on focus */
        padding: 8px;
        max-width: 100%;
    }

    /* Stack form vertically on mobile */
    .form-table,
    .form-table tbody,
    .form-table tr {
        display: block;
        width: 100%;
    }

    .form-table td {
        display: block;
        width: 100%;
        padding: 2px 0;
    }

    .form-table td.form-label {
        padding-bottom: 4px;
        white-space: normal;
    }

    /* Header adjustments */
    .header-content {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .site-header {
        padding: 8px;
    }

    .auth-links {
        font-size: 14px;
    }

    /* Board list readability */
    .boards-list {
        font-size: 16px;
        line-height: 2;
    }

    /* Post adjustments */
    .post {
        padding: 8px;
        margin: 4px 0;
    }

    .post.reply-post {
        margin-left: 8px;  /* Reduce indentation on mobile */
    }

    .post-header {
        font-size: 13px;
    }

    .post-subject {
        font-size: 15px;
    }

    /* Attachment thumbnails */
    .op-post .attachment-thumbnail {
        max-width: 200px;
    }
    .reply-post .attachment-thumbnail {
        max-width: 130px;
    }

    /* Pagination */
    .pagination {
        font-size: 14px;
    }

    .pagination .page-input {
        font-size: 16px;  /* Prevent iOS zoom */
        padding: 4px;
        min-height: 32px;
    }

    /* Message preview popups */
    .message-preview {
        max-width: 90vw;  /* Don't overflow screen */
    }

    /* Thread header */
    .board-header h1 {
        font-size: 1.5em;
    }

    /* Footer */
    .site-footer {
        font-size: 11px;
    }

    /* Forms */
    .post-form-container,
    .admin-panel,
    .auth-form {
        width: 100%;
    }

    /* Index container */
    .index-container {
        max-width: 100%;
    }

    /* Welcome message */
    .welcome-message {
        padding: 8px 10px;
        font-size: 14px;
    }

    /* FAQ page */
    .faq-container {
        padding: 0 5px;
    }

    .faq-section {
        padding: 10px;
    }

    .faq-examples-table {
        font-size: 12px;
    }

    .faq-examples-table th,
    .faq-examples-table td {
        padding: 6px;
    }

    /* Popup reply: fixed to bottom, full-width, centered */
    .popup-reply-container {
        position: fixed !important;
        bottom: 0;
        left: 0 !important;
        top: auto !important;
        width: 100%;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
    }
}

/* Small phones */
@media (max-width: 480px) {
    body {
        font-size: 15px;
        padding: 1px;
    }

    .post-attachments {
        padding-left: 4px;
    }

    .op-post .attachment-thumbnail,
    .reply-post .attachment-thumbnail {
        max-width: 125px;
    }

    .post-body {
        max-height: 400px;  /* Reduce height on small screens */
    }
}
