/* Custom styles for LoT UI */

/* Add a bit of padding to the main container */
.container {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Style the allegation cards */
.card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Softer shadow for dark theme */
    color: var(--text-color); /* Ensure default card text is readable */
}

/* App header card styling */
.app-header-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Allegation info section styling */
.allegation-info-section {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: rgba(255, 255, 255, 0.03); /* Slightly lighter header bg */
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    color: var(--text-color);
    font-weight: 600;
}

.card-body {
    color: var(--text-color); /* Ensure body text is readable */
}

.card-footer {
    background-color: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
}

/* Style the RAG results */
.rag-results .list-group-item {
    padding: 1rem;
    border-left: 3px solid #0d6efd;
}

/* Style the classification display */
.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* Style the allegation processing progress */
.allegation-progress {
    height: 0.5rem;
    margin-bottom: 1rem;
}

/* HTMX loading indicator styling */
.htmx-indicator {
    margin-right: 0.5rem;
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Add some spacing between buttons in button groups */
.btn-group .btn {
    margin-right: 0.25rem;
}

/* Make the final LoT look more document-like */
.lot-content {
    background-color: #fff;
    padding: 2rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

/* Print styles for the final LoT */
@media print {
    .no-print {
        display: none;
    }
    
    .lot-content {
        border: none;
        padding: 0;
    }
    
    body {
        font-size: 12pt;
    }
}

/* Left-align step content */
.step-content {
    text-align: left;
}

/* Left-align form elements */
.col-md-8.offset-md-2 {
    margin-left: 0;
    flex: 0 0 100%;
    max-width: 100%;
}

/* Add separation between instructions and content */
.workspace-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Facts summary accordion in classification view */
.facts-summary-collapsible {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.facts-summary-collapsible .card-header {
    padding: 0.5rem 1rem;
    cursor: pointer;
    background-color: rgba(13, 202, 240, 0.1); /* Cyan background with low opacity */
}

.facts-summary-content {
    max-height: 300px;
    overflow-y: auto;
}

/* Cyan highlight for generated document header */
.text-cyan {
    color: #0dcaf0 !important;
}

/* Dark Theme Variables */
:root {
    --background-color: #121212; /* Slightly darker background */
    --text-color: #e1e1e1;
    --primary-color: #0dcaf0; /* Cyan primary */
    --secondary-color: #1e56a0; /* Police blue */
    --card-bg-color: #1e1e1e; /* Slightly darker card */
    --border-color: #333; /* Softer border */
    --link-color: var(--primary-color);
    --link-hover-color: #47d6f5;
    --font-family-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;
    --navbar-height: 56px; /* Define navbar height */
}

body {
    font-family: var(--font-family-sans-serif);
    background-color: var(--background-color);
    color: var(--text-color);
    /* padding-top removed, handled by main-wrapper */
}

a {
    color: var(--link-color);
}

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

/* Layout Styling */
.main-wrapper {
    display: flex;
    padding-top: var(--navbar-height); /* Use variable */
    min-height: 100vh;
}

.sidebar {
    width: 260px; /* Slightly wider */
    padding: 1.5rem 1rem;
    background-color: var(--card-bg-color);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - var(--navbar-height)); /* Use variable */
    position: fixed;
    top: var(--navbar-height); /* Use variable */
    left: 0;
    overflow-y: auto;
}

.sidebar h4 {
    color: #0dcaf0; /* Updated to cyan */
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-left: 0.5rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    padding: 0.75rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 0.3rem;
    cursor: pointer; /* Indicate interactivity */
    transition: background-color 0.2s ease-in-out;
    font-weight: 500;
}

.sidebar li:hover {
    background-color: rgba(13, 202, 240, 0.1); /* Cyan with low opacity for hover */
}

.sidebar li.active {
    background-color: #0dcaf0; /* Cyan background for active */
    color: #212529; /* Dark text for contrast */
}

.main-content-area {
    flex-grow: 1;
    padding: 1.5rem; /* More padding */
    margin-left: 260px; /* Match sidebar width */
    max-width: calc(100% - 260px);
}

/* Dark Theme Adjustments for Bootstrap Components */
.navbar {
    height: var(--navbar-height);
}

.navbar-dark {
    background-color: #181818 !important; /* Slightly lighter than body */
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-weight: 600;
}

/* Refine the main content container style */
.content-box {
    background-color: var(--card-bg-color);
    padding: 2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Apply content-box style where bg-light was used */
.bg-light {
    background-color: transparent !important; /* Remove default bg */
    border: none !important;
    padding: 0 !important; /* Remove default padding */
}

.p-5 {
    padding: 1.5rem !important; /* Reduce padding slightly */
}

.rounded {
    border-radius: 0.3rem !important;
}

h1, h2, h3, h4, h5, h6, .lead {
    color: var(--text-color);
}

.form-control {
    background-color: #333;
    color: var(--text-color);
    border-color: var(--border-color);
}

.form-control:focus {
    background-color: #444;
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
}

.form-label {
    color: var(--text-color);
}

.btn-primary {
    background-color: #0dcaf0; /* Cyan */
    border-color: #0dcaf0;
    color: #212529; /* Dark text for contrast */
}

.btn-primary:hover {
    background-color: #47d6f5; /* Lighter cyan */
    border-color: #47d6f5;
    color: #212529;
}

.list-group-item {
    background-color: var(--card-bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

/* Accordion Styling Enhancements */

/* General Accordion Dark Theme */
body[data-bs-theme="dark"] .accordion-item { /* Added 'body' for specificity */
    /* --bs-accordion-bg: var(--background-color); */ /* REMOVED - Override at component level instead */
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    overflow: hidden; /* Helps with borders/radius */
}

/* Override Bootstrap variable at the component level for dark theme */
body[data-bs-theme="dark"] .accordion {
    --bs-accordion-bg: var(--background-color); /* Use main page background color */
}

/* Direct targeting of specific accordions with !important */
body[data-bs-theme="dark"] #policiesAccordion .accordion-item,
body[data-bs-theme="dark"] #lawsAccordion .accordion-item,
body[data-bs-theme="dark"] #rationalesAccordion .accordion-item {
    background-color: var(--background-color) !important; /* Force background color */
}

/* Special class for dark accordion items - maximum specificity and priority */
html body .dark-accordion-item {
    background-color: #121212 !important; /* Hardcoded dark value instead of using variables */
    border-color: #333 !important;
}

/* Override Bootstrap body-bg variable within dark theme scope */
body[data-bs-theme="dark"] {
    --bs-body-bg: var(--background-color) !important; /* Override Bootstrap's body background */
}

.accordion-button {
    background-color: transparent; /* Inherit background from parent */
    color: var(--text-color);
    font-weight: 500;
    border-radius: calc(0.3rem - 1px); /* Match item radius */
    width: 100%; /* Make it use full width */
}

.accordion-button:not(.collapsed) {
    background-color: rgba(var(--bs-primary-rgb), 0.1); /* Subtle highlight when open */
    color: var(--primary-color); /* Highlight text when open */
    box-shadow: inset 0 -1px 0 var(--border-color);
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-color), 0.25);
    border-color: var(--primary-color);
}

.accordion-button::after {
    /* Default chevron uses background-image, hard to color. 
       Consider replacing with a font icon if more control needed. */
    filter: invert(1) grayscale(100%) brightness(200%); /* Invert for dark mode */
}

/* Policy/Law Accordion Header */
.policy-law-header {
    display: flex; /* Use flex to align checkbox and label */
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem; /* Restore original padding */
}

.policy-law-header .form-check-input {
    margin-top: 0 !important; /* Reset margin */
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

.policy-law-header .form-check-label {
    margin-left: 0.5rem;
    cursor: pointer; /* Indicate label is clickable */
    flex-grow: 1; /* Allow the label to take up available space */
}

/* Container to prevent event propagation to accordion toggle */
.form-check-container {
    display: flex;
    align-items: center;
    flex-grow: 1;
    position: relative;
    z-index: 5; /* Ensure it's above other elements in stacking context */
}

/* Make sure clicking on labels only affects the checkboxes */
.form-check-label {
    cursor: pointer;
    position: relative;
    z-index: 2;
}

/* Ensure inputs stay above the accordion button */
.form-check-input {
    position: relative;
    z-index: 2;
}

/* Ensure the accordion button properly contains the form check */
.accordion-button {
    padding: 0.75rem 1rem;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

#rationalesAccordion .accordion-button {
    padding: 0.75rem 1rem;
}

/* Remove the custom collapse-toggle styles as they're no longer needed */

/* RAG Doc Accordion Body */
.doc-accordion-body {
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.9em;
    background-color: var(--card-bg-color); /* Match card background */
    border-top: 1px solid var(--border-color);
    color: var(--text-color); /* Explicitly set text color */
    padding: 1rem; /* Add padding */
}

.doc-accordion-body .form-check {
    /* Ensure checkbox is aligned well when label is block */
    padding-left: 1.75em; 
}

.doc-accordion-body .form-check-input {
    margin-left: -1.75em;
}

.doc-accordion-body .doc-text {
    white-space: normal; /* Changed from pre-wrap to normal */
    background-color: rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: 0.3rem;
    font-family: var(--font-family-sans-serif);
    font-size: 0.95em;
    color: var(--text-color);
    line-height: 1.5;
    max-height: 500px;
    overflow-y: auto;
}

/* Special formatting for bullet points */
.doc-text p {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    padding: 0;
    min-height: 1.2em; /* Reduced from 1.5em */
}

/* Style for bullets using traditional selectors since :has isn't fully supported */
.doc-text p.bullet-point {
    padding-left: 1.5rem;
    text-indent: -0.75rem;
    margin-bottom: 0.3rem; /* Reduced from 0.5rem */
}

/* For bullet points with dashes */
.doc-text p.dash-bullet {
    padding-left: 1rem;
    text-indent: -0.5rem;
    margin-bottom: 0.3rem; /* Reduced from 0.5rem */
}

/* Empty lines for spacing - make these smaller */
.doc-text p.empty-line {
    height: 0.5em; /* Reduced from 1em */
    margin-bottom: 0; /* Removed margin */
    line-height: 0.5; /* Reduces the rendered height */
}

/* Style for section headers - add some space above */
.doc-text p:first-child {
    font-weight: 600;
    font-size: 1.05em;
    margin-bottom: 0.75rem; /* Reduced from 1rem */
    color: var(--primary-color);
}

/* Make headings stand out but reduce space */
.doc-text p.heading {
    font-weight: 600;
    margin-top: 0.5rem; /* Reduced from 0.75rem */
    margin-bottom: 0.3rem; /* Reduced from 0.5rem */
}

/* Style for the pre-formatted document text in accordions */
.pre-formatted {
    white-space: normal; /* Changed from pre-wrap to normal */
    line-height: 1.4; /* Slightly reduced from 1.5 */
}

/* Special formatting for keywords */
.badge {
    font-size: 0.75em;
    font-weight: normal;
    padding: 0.35em 0.65em;
    background-color: var(--primary-color);
    color: white;
    border-radius: 0.25rem;
}

/* Improve content within the accordion */
.accordion-body {
    padding: 1.25rem;
}

/* Ensure last item doesn't have extra border */
.doc-accordion-body .form-check:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Rationale Accordion Specifics */
#rationalesAccordion .accordion-item {
    /* Add specific styles if needed */
}

#rationalesAccordion .accordion-button {
    /* Align radio button and label */
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
}

#rationalesAccordion .accordion-button .form-check-input {
    margin-top: 0;
    flex-shrink: 0;
}

#rationalesAccordion .accordion-button .form-check-label {
    margin-left: 0.5rem;
    flex-grow: 1; /* Allow label to take remaining space */
}

/* Remove the previous rationale-specific styling that is now handled by general rules */
/* .rationale-accordion-body { ... } - Remove this if general .accordion-body is sufficient */


/* Add a bit more space below the RAG accordions */
#policiesAccordion,
#lawsAccordion {
    margin-bottom: 1.5rem !important;
}

/* Rationale Accordion Body */
.rationale-accordion-body {
    white-space: pre-line; /* Changed from pre-wrap to pre-line to handle excessive indentation */
    font-size: 0.9em;
    padding: 0.75rem 1rem;
    background-color: var(--card-bg-color); /* Match card background */
    border-top: 1px solid var(--border-color);
    color: var(--text-color); /* Explicitly set text color */
    text-indent: 0; /* Remove any text indentation */
}

/* Format the rationale text to remove excessive indentation */
.rationale-text {
    text-indent: 0;
    display: block;
    margin-bottom: 1rem;
}

.rationale-text p {
    margin-bottom: 0.75rem;
    text-indent: 0;
}

/* Style for disabled but checked radio buttons - keep them visible */
#rationalesAccordion .form-check-input:disabled:checked {
    opacity: 0.7;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Selected rationale style */
#rationalesAccordion .accordion-item .text-success {
    color: var(--primary-color) !important;
    font-weight: 500;
}

/* Reduce prominence of filename display */
.filename-display {
    font-size: 0.9rem; /* Slightly smaller */
    font-weight: 500; /* Less bold */
    color: #aaa; /* Greyed out */
    margin-bottom: 1.5rem; /* Add some space below */
}

/* Increase size of facts summary textarea */
#facts_summary_area {
    /* rows: 15; */ /* Remove non-standard CSS property */
    min-height: 400px; /* Further increase minimum height */
    width: 100%; /* Make it use full width */
}

/* Dark mode adjustments for accordion headers containing form inputs */
[data-bs-theme="dark"] .accordion-header.d-flex {
    background-color: transparent; /* Inherit background from parent */
}

/* Ensure the accordion button itself still looks correct */
[data-bs-theme="dark"] .accordion-header.d-flex .accordion-button {
    /* Optionally add specific styles if needed, but transparency might be enough */
}

/* POBR specific styling */
.section-header {
    font-weight: 600;
    font-size: 1.1em;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(13, 202, 240, 0.3);
    padding-bottom: 0.3rem;
}

.subsection-header {
    font-weight: 500;
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
    padding-left: 1rem;
    text-indent: -1rem;
}

.note-text {
    color: #adb5bd;
    font-style: italic;
    margin-top: 0.5rem;
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
}

/* Enhanced section header for POBR */
.section-header.fw-bold {
    font-size: 1.15em;
    background-color: rgba(13, 202, 240, 0.1);
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-top: 1.25rem;
}

/* Format section numbers in POBR text */
p[class*="section-"] {
    font-family: var(--bs-font-monospace);
    letter-spacing: -0.01em;
}

/* Add space above first section header */
.doc-text .section-header:first-child {
    margin-top: 0;
}

/* Enhanced POBR section formatting */
.pobr-section {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dotted rgba(13, 202, 240, 0.2);
}

.pobr-section:last-child {
    border-bottom: none;
}

.pobr-section .section-title {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.pobr-section .section-content {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

/* Loading indicator for POBR content */
.pobr-content .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Error messages in POBR content */
.pobr-content .error-message {
    color: #f77;
    font-style: italic;
    border-left: 3px solid #f77;
    padding-left: 1rem;
}

/* Additional POBR Content Fixes */
.pobr-content {
    min-height: 50px; /* Ensure there's space for the loading state */
}

/* Fix for escaped quotes in class names */
[class*="pobr-section"],  /* Match elements with potentially escaped class names */
.pobr-section {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dotted rgba(13, 202, 240, 0.2);
}

[class*="section-title"],
.section-title {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

[class*="section-content"],
.section-content {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

/* POBR subsection styling */
.pobr-subsection {
    margin-left: 1.5rem;
    border-left: 2px solid rgba(13, 202, 240, 0.2);
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.pobr-subsection .section-subtitle {
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

/* Update POBR accordion button to show section names */
#pobrAccordion .accordion-button strong {
    max-width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Styles for section identifier in POBR accordions */
.section-identifier {
    width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
}

.section-identifier strong {
    display: block;
    width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
} 