/* Modern UI Theme 1.3.4 - Custom Edition */
/* Main Accent: #598dc5 | Main BG: #1d344e */
@import url("litely.css") (prefers-color-scheme: light);
@import url("darkly.css") (prefers-color-scheme: dark);

@media (prefers-color-scheme: light) {
  :root {
    --custom-primary: #598dc5;
    --custom-secondary: #2c4a6b;
    --custom-secondary-light: #3d6694;
    --custom-info: #598dc5;
    --custom-tabs-color: #598dc5;
    --custom-tabs-text-color: #1d344e;
    --custom-bg-color: #f0f4f8;
    --custom-main-bg-color: #ffffff;
    --custom-comment-left-border: rgba(89, 141, 197, 0.2);
    --blockquote-left-border: #598dc5;
  }
}

@media (prefers-color-scheme: dark) {
  :root, div#app {
    --custom-primary: #598dc5;
    --custom-primary-light: #7ca7d5;
    --custom-primary-dark: #416b96;
    --custom-secondary-light: #2a4a6e;
    --custom-tabs-color: #243f5e;
    --custom-tabs-text-color: #dee2e6;
    --custom-bg-color: #142436;      /* Slightly darker than main for depth */
    --custom-main-bg-color: #1d344e; /* YOUR SPECIFIED BACKGROUND */
    --custom-comment-left-border: rgba(89, 141, 197, 0.4);
    --bs-warning-text-emphasis: #fff;
    --bs-warning-bg-subtle: #44423f;
    --bs-info-text-emphasis: #fff;
    --bs-body-bg: var(--custom-main-bg-color);
    --bs-code-color: #7ca7d5;
  }
}

/* --- Layout & Structural Rules --- */

.card, .container-lg .row .col-12.col-lg-6.offset-lg-3.mb-4:first-child,
.container-lg .row .post article.col-12.col-lg-6.offset-lg-3[id^=comment-].py-2:first-child,
.post .container-lg .row article.col-12.col-lg-6.offset-lg-3[id^=comment-].py-2:first-child,
#community_table, main.col-12.col-md-8.col-lg-9.mb-3 > div:not([class]):last-child,
div.col-12.col-md-8.mb-3 > div:not([class]):last-child, .post .post-listing:first-child,
main[role=main], .community .post-listings, .col-12.col-md-8:not(.mb-3), .person-details,
.col-12.col-md-8.mb-3 > .post-listing:first-child, .modlog, .home-instances, .legal,
.communities, .login, .inbox, .search, .home-signup {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--custom-main-bg-color);
  background-clip: border-box;
  border: 1px solid rgba(89, 141, 197, 0.1) !important;
  border-radius: 0.5rem;
  padding: 0.5rem;
}

.container-lg .row .col-12.col-lg-6.offset-lg-3.mb-4:first-child,
.container-lg .row .post article.col-12.col-lg-6.offset-lg-3[id^=comment-].py-2:first-child,
.post .container-lg .row article.col-12.col-lg-6.offset-lg-3[id^=comment-].py-2:first-child,
#community_table, main.col-12.col-md-8.col-lg-9.mb-3 > div:not([class]):last-child,
div.col-12.col-md-8.mb-3 > div:not([class]):last-child, .post .post-listing:first-child,
main[role=main], .community .post-listings, .col-12.col-md-8:not(.mb-3), .person-details,
.col-12.col-md-8.mb-3 > .post-listing:first-child, .modlog, .home-instances, .legal,
.communities, .login, .inbox, .search, .home-signup {
  padding: 0.5rem;
}


body { background-color: var(--custom-bg-color); }
nav { background-color: var(--custom-main-bg-color); border-bottom: 1px solid var(--custom-primary); }
main { padding-top: 10px; }
a { color: var(--custom-primary); text-decoration: none; }
a:hover { color: var(--custom-primary-light); }

blockquote {
  border-left-width: 4px;
  padding: 0.1em 8px;
  border-color: var(--blockquote-left-border);
  background: rgba(89, 141, 197, 0.05);
}

.text-primary { color: var(--custom-primary) !important; }

.primary, .badge-primary, .btn-primary, .text-bg-primary {
  background-color: var(--custom-primary) !important;
  border-color: var(--custom-primary);
  color: #fff !important;
}

/* --- Button Styling --- */

.btn-outline-secondary {
  border-color: var(--custom-primary);
  color: var(--custom-primary);
}

.btn-outline-secondary:hover {
  background-color: var(--custom-primary);
  color: #fff;
}

/* --- Navigation Tabs --- */

.btn-group.btn-group-toggle .btn-outline-secondary:not(.active) {
  color: var(--custom-tabs-text-color);
  border-color: var(--custom-tabs-color);
}

.btn-group.btn-group-toggle .btn-outline-secondary.active {
  background-color: var(--custom-tabs-color);
  border-color: var(--custom-tabs-color);
  color: #fff;
}

/* --- Comments & Threading --- */

div[id^=comment-], article[id^=comment-], ul.comments.border-top {
  border-left: 2px solid var(--custom-comment-left-border) !important;
  border-top: none !important;
  margin-left: 0.75rem !important;
}

.post-listing { padding-top: 12px; border-bottom: 1px solid rgba(89, 141, 197, 0.1); }

/* --- Form Elements --- */

.form-control {
  background-color: var(--custom-main-bg-color);
  border: 1px solid rgba(89, 141, 197, 0.3);
  color: inherit;
}

.form-control:focus {
  border-color: var(--custom-primary);
  box-shadow: 0 0 0 0.2rem rgba(89, 141, 197, 0.25);
}

/* --- Utilities --- */

.mt-0 { margin-top: 0 !important; }
.ml-2 { margin-left: 0.5rem !important; }
.p-2 { padding: 0.5rem !important; }
.card-header { background-color: transparent; border-bottom: none; }

@media (prefers-color-scheme: dark) {
  code.hljs {
    background: #142436;
    color: #dee2e6;
  }
}

/* Custom Styling for File Upload Buttons */
input[type="file"]::file-selector-button {
  background-color: var(--custom-primary);
  color: white;
  border: none;
  border-radius: 0.25rem;
  padding: 0.4rem 1rem;
  margin-right: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
  background-color: var(--custom-primary-light);
}

/* For the text next to the button (e.g., "No file chosen") */
input[type="file"] {
  color: var(--custom-tabs-text-color);
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* --- Light-on-Light Contrast Fixes --- */

/* Force general text and muted text to be readable */
.text-muted, 
.text-secondary, 
.small, 
.user-listing-details, 
.post-subtitle {
  color: #adb5bd !important; /* Light grey that works well on #1d344e */
}

/* Fix dropdown menus and list items */
.dropdown-item {
  color: var(--bs-body-color) !important;
}

.dropdown-item:hover {
  background-color: var(--custom-primary);
  color: white !important;
}

/* Fix text inside alerts or info boxes */
.alert-info, .alert-secondary {
  background-color: var(--custom-bg-color);
  border-color: var(--custom-primary);
  color: #fff !important;
}

/* Fix "User" and "Community" labels in searches/lists */
.person-listing .text-muted, 
.community-listing .text-muted {
  color: #dee2e6 !important;
}

/* Specifically target any remaining dark text in the navbar or cards */
.navbar-light .navbar-nav .nav-link,
.card-body,
footer {
  color: #dee2e6 !important;
}
