/* General Body and Container Styling */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f0f2f5; /* Light gray background */
    color: #333;
    line-height: 1.6;
}

div[style="text-align:center;"] {
    max-width: 960px;
    margin: 20px auto;
    padding: 25px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: left; /* Override inline center for better readability */
}

/* Header */
h1 {
    text-align: center;
    color: #0056b3; /* Darker blue for headings */
    margin-bottom: 10px;
    font-size: 2.5em;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 15px;
}

/* Counter */
div:has(> <%counter>) { /* Selects the div containing the counter */
    text-align: center;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 25px;
}

/* Navigation */
#navigation {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px 0;
    background-color: #e9ecef;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#navigation a {
    text-decoration: none;
    color: #007bff; /* Bright blue for links */
    font-weight: bold;
    padding: 0 15px;
    transition: color 0.3s ease;
}

#navigation a:hover {
    color: #0056b3;
}

/* Forms (Posting, Reply, Edit, Search) */
form {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.postinfo,
form table { /* Target tables within forms */
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.postinfo td,
form table td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

.postinfo tr:last-child td,
form table tr:last-child td {
    border-bottom: none;
}

.postinfo td:first-child,
form table td:first-child {
    font-weight: bold;
    width: 150px; /* Adjust as needed */
    color: #555;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
    width: calc(100% - 22px); /* Account for padding and border */
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

textarea {
    resize: vertical; /* Allow vertical resizing */
    min-height: 100px;
}

.radio { /* Specific styling for radio buttons and checkboxes to reset default styles */
    width: auto;
    margin-right: 5px;
}

.button,
input[type="submit"],
input[type="reset"] {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-right: 10px;
}

.button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

input[type="reset"] {
    background-color: #6c757d;
}

input[type="reset"]:hover {
    background-color: #5a6268;
}

/* Error Message */
div:has(> <%error_message>) { /* Selects the div containing error messages */
    color: #dc3545; /* Red for error messages */
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 15px;
    margin: 16px 0;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

/* Thread and Article Styling */
.thread_wrapper {
    margin-top: 30px;
}

.parent_article,
.child_article,
.result_article {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.child_article {
    margin-left: 40px; /* Indent replies */
    border-left: 5px solid #007bff;
    padding-left: 25px;
    background-color: #f0f6ff; /* Lighter blue background for replies */
}

.parent_article .title,
.child_article .title,
.result_article .title {
    font-size: 1.4em;
    font-weight: bold;
    color: #0056b3;
    margin-bottom: 5px;
    display: block; /* Ensure title takes full width */
}

.parent_article .date,
.child_article .date,
.result_article .date {
    color: #777;
    font-size: 0.85em;
    margin-bottom: 10px;
    border-bottom: 1px dashed #e0e0e0;
    padding-bottom: 8px;
}

.contents {
    display: flex;
    align-items: flex-start;
    gap: 15px; /* Space between icon/body and image */
    margin-top: 15px;
}

.contents div:has(> img[src*="icon"]) { /* Icon container */
    flex-shrink: 0; /* Prevent icon div from shrinking */
    padding-top: 5px; /* Align icon better with text */
}

.contents .body {
    flex-grow: 1; /* Allow body to take up remaining space */
    word-wrap: break-word; /* Break long words */
    overflow-wrap: break-word; /* Modern equivalent */
}

.userimage {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-top: 15px; /* Space above image */
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
}

.panel {
    text-align: right;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #e9ecef;
}

.panel form {
    display: inline-block;
    margin-left: 8px;
    border: none;
    padding: 0;
    background: none;
    box-shadow: none;
}

.panel .button {
    padding: 8px 15px;
    font-size: 0.9em;
    margin-right: 0; /* Remove extra margin */
}

/* Pagination (Previous/Next) */
form:has(input[name="pos"]) { /* Select forms containing pagination inputs */
    text-align: center;
    margin: 25px auto;
    border: none;
    padding: 10px;
    background: none;
    box-shadow: none;
}

form:has(input[name="pos"]) input[type="submit"] {
    background-color: #6c757d;
    padding: 10px 25px;
    border-radius: 5px;
}

form:has(input[name="pos"]) input[type="submit"]:hover {
    background-color: #5a6268;
}

/* Page Specific Overrides */
/* Preview Page */
#page_preview div[style*="width:600px"],
#page_reply div[style*="width:600px"] {
    max-width: 800px; /* Make preview wider */
    padding: 25px;
    margin: 20px auto;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: left;
}

#page_preview table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
}

#page_preview table td {
    padding: 10px;
    border: 1px solid #e9ecef;
}

#page_preview table tr:first-child td {
    border-top: none;
}

#page_preview table tr:last-child td {
    border-bottom: none;
}

#page_preview table td:first-child {
    background-color: #f8f9fa;
    font-weight: bold;
    width: 120px;
}

#page_preview table th {
    background-color: #0056b3;
    color: white;
    padding: 15px;
    border-radius: 5px 5px 0 0;
    font-size: 1.2em;
    text-align: center;
}

/* Post Completion Page */
#page_post p {
    text-align: center;
    font-size: 1.5em;
    color: #28a745; /* Green for success message */
    font-weight: bold;
    margin: 50px 0;
}

#page_post a {
    color: #007bff;
    text-decoration: none;
    font-size: 1.2em;
}

#page_post a:hover {
    text-decoration: underline;
}

/* Search Page */
#page_search form {
    max-width: 600px;
    margin: 20px auto;
}

#page_search .result_article {
    margin-bottom: 15px;
    border-left: 5px solid #ffc107; /* Yellow border for search results */
    padding-left: 20px;
    background-color: #fffde7;
}

#page_search a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
}

#page_search a:hover {
    text-decoration: underline;
}

/* Help Page */
#help {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    margin-top: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

#help h3 {
    color: #0056b3;
    font-size: 1.8em;
    margin-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

#help ul {
    list-style-type: disc;
    padding-left: 25px;
    margin-bottom: 20px;
}

#help li {
    margin-bottom: 10px;
    color: #444;
}

small {
    color: #666;
    font-size: 0.85em;
}

/* Color swatches for text color options */
small span[style*="color:"] {
    font-size: 1.2em;
    vertical-align: middle;
    margin-right: 3px;
    border: 1px solid #ccc;
    line-height: 1;
}

/* Image Verification */
div[style*="background:#E0E0E0;"] { /* CAPTCHA header */
    background-color: #007bff !important; /* Override with theme color */
    color: white;
    padding: 15px;
    font-size: 1.2em;
    border-radius: 5px 5px 0 0;
    text-align: center;
}

/* Advertisements (kept hidden for a cleaner look) */
<%ads_head>, <%ads_foot> {
    display: none;
}