/* Use a CSS variable for easy theme integration. Your theme can override this. */
:root {
	--rpls-theme-color: #ed1c24;
	--rpls-admin-bar-offset: var(--wp-admin--admin-bar--height, 0px);
	--rpls-filter-bar-height: 83px; /* Estimated height of the sticky filter bar. Adjust if filters wrap. */
}

.entry-content p{
    color: black !important;
    margin-bottom: 0.2em !important;
}

.rpls-reaction-wrapper{
    margin-top: 0px !important;
    padding-top: 0px !important;
    border-top: none !important;
    border-bottom: none !important;
}

/* Accordion List Styles */
.rpls-accordion-list-container {
    position: relative;
    margin-top: 0px !important;
}

.rpls-accordion-list {
	margin-bottom: 20px;
	/* Removed accordion-specific styles like border, radius, overflow */
}

.rpls-accordion-item {
	/* Use padding/margin for separation instead of a full border */
	padding-bottom: 15px;
	margin-bottom: 15px;
	border-bottom: 1px solid #e2e2e2;
}

.rpls-accordion-item:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.rpls-accordion-title {
	margin: 0;
	padding: 0;
	/* Font styling is handled by the trigger button inside */
}

.rpls-accordion-trigger {
	/* Reset button styles to appear as plain text */
	background: none;
	border: none;
	outline: none;
	box-shadow: none;
	color: #222;
	cursor: pointer;
	display: flex;
	align-items: center;
	padding: 0;
	width: 100%;
	text-align: left;
	/* font-size: 18px; */
	font-weight: 600;
	transition: color 0.2s ease-in-out;
}

/* Apply theme color on hover, focus, and when the accordion is active */
.rpls-accordion-trigger:hover,
.rpls-accordion-trigger:focus, .rpls-accordion-item:hover,
.rpls-accordion-item.is-active .rpls-accordion-trigger {
	color: var(--rpls-theme-color);
    background: none;
}

.rpls-accordion-item:hover {
    background: none;
}

.rifnote-summary {
    color: black;
}

.rpls-accordion-icon {
	display: none; /* Remove the icon from view */
}

/* All icon-related styles have been removed for cleanliness as the icon is hidden. */

.rpls-accordion-content {
	padding-top: 10px;
	background: none;
}

/* Loader Styles */
.rpls-accordion-loader {
    padding: 20px 0;
    text-align: center;
    height: 40px;
}

.rpls-loader {
    display: inline-block;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: rpls-spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}

.rpls-accordion-loader.is-loading .rpls-loader {
    opacity: 1;
}

@keyframes rpls-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Date Group Heading Styles */
.rpls-date-group-heading {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
    padding: 8px 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: -webkit-sticky;
	position: sticky;
	/* Stick below the admin bar and the filter bar */
	top: calc(var(--rpls-admin-bar-offset) + var(--rpls-filter-bar-height) - 15px);
	z-index: 99; /* Below the filter bar */
	background: #f9f9f9; /* Give it a background to hide content scrolling under it */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

/* Add margin to the container of the items, not the heading itself */
.rpls-date-group-heading + .rpls-accordion-item {
    margin-top: 0px !important;
}

.rpls-date-nav-buttons {
    display: flex;
    gap: 10px;
}

.rpls-date-nav-button {
    background: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
    color: #555;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.rpls-accordion-list > .rpls-date-group-heading:first-child {
    margin-top: 0;
}

/* Filter Form Styles */
.rpls-accordion-filters {
    display: flex;
    width: 100% !important;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    position: -webkit-sticky;
	position: sticky;
	top: var(--rpls-admin-bar-offset);
	z-index: 101;
	background: #fff;
	padding: 15px;
	margin-bottom: 10px;
	box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Layout for when the advanced filters are open */
.rpls-accordion-filters.advanced-filters-open {
	flex-wrap: wrap;
}

.rpls-accordion-filters .rpls-advanced-filters {
	/* This is the main container for the advanced controls */
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 15px; /* A little more space for a cleaner look */
	width: 100%;
	padding-top: 15px; /* Add some space above the advanced controls */
}

.rpls-accordion-filters .rpls-advanced-filters .rpls-filter-search {
	/* Make the search bar take up the full width */
	flex-basis: 100%;
}

.rpls-accordion-filters .rpls-advanced-filters .rpls-date-filters-wrapper,
.rpls-accordion-filters .rpls-advanced-filters .rpls-filter-actions {
	/* These containers will now sit on the second line */
	display: flex;
	align-items: center;
	gap: 10px;
}

.rpls-trending-button.is-active {
	background-color: #2d3748; /* A dark gray-blue */
	color: #ffffff;
	border-color: #2d3748;
	transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.rpls-trending-buttons-scroll-wrapper {
	flex: 1; /* Allow the wrapper to grow and fill available space */
	min-width: 0; /* Important for flex items to shrink below their content size */
	overflow-x: auto; /* This enables horizontal scrolling */
	-webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
	position: relative; /* Needed for the peek-a-boo gradient */

	/* Hide the scrollbar for a cleaner look across browsers */
	scrollbar-width: none; /* Firefox */
	-ms-overflow-style: none;  /* IE and Edge */
}

.rpls-trending-buttons-scroll-wrapper::-webkit-scrollbar {
	display: none; /* Chrome, Safari, and Opera */
}

.rpls-trending-buttons {
	display: flex;
	flex-wrap: nowrap; /* This is crucial to prevent buttons from wrapping */
	gap: 8px; /* Adds spacing between the buttons */
}

.rpls-trending-buttons .rpls-trending-button {
	flex-shrink: 0; /* This is the key: prevent buttons from shrinking */
}

.rpls-trending-button.has-image {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding-left: 6px;
}

.rpls-trending-button .rpls-term-image {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	object-fit: cover;
	background-color: #e0e0e0; /* A light gray placeholder */
	border: 1px solid rgba(0,0,0,0.05);
}

/* Peek-a-boo gradient effect to hint at scrollability */
.rpls-trending-buttons-scroll-wrapper.is-scrollable::after {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 40px;
	background: linear-gradient(to right, rgba(255, 255, 255, 0), #ffffff 80%);
	pointer-events: none; /* Allow clicks to pass through */
	transition: opacity 0.3s ease-in-out;
	opacity: 1;
}

.rpls-trending-buttons-scroll-wrapper.has-scrolled::after {
	opacity: 0;
}

@keyframes rpls-peek-a-boo {
	0%, 100% { transform: translateX(0); }
	50% { transform: translateX(-25px); }
}

.rpls-trending-buttons-scroll-wrapper.is-peeking .rpls-trending-buttons {
	animation: rpls-peek-a-boo 1.5s ease-in-out;
}

.rpls-advanced-toggle-button {
	margin-left: auto; /* Push to the far right */
	padding: 6px;
	line-height: 1;
	min-width: auto;
	background: transparent;
	border: 1px solid #dcdcde;
	border-radius: 50%; /* Circular shape */
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.rpls-advanced-toggle-button svg {
	width: 20px;
	height: 20px;
	fill: #50575e; /* WordPress gray */
	transition: fill 0.2s ease;
}

.rpls-advanced-toggle-button:hover,
.rpls-advanced-toggle-button.is-active {
	background-color: #f0f0f1;
	border-color: #949494;
}

.rpls-advanced-toggle-button.is-active svg {
	fill: #2271b1; /* WordPress blue */
}

.rpls-date-filters-wrapper,
.rpls-filter-actions {
	display: contents; /* On desktop, these wrappers have no visual effect */
}

.rpls-date-toggle-button {
	display: none; /* Hide the mobile toggle button on desktop */
}

.rpls-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rpls-filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.rpls-filter-search {
    flex-grow: 1;
    min-width: 200px;
}

.rpls-accordion-filters input[type="search"],
.rpls-accordion-filters select,
.rpls-accordion-filters input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    height: 38px;
}

.rpls-accordion-filters button {
    padding: 8px 20px;
    border: 1px solid #ed1c24;
    background-color: #ed1c24;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    height: 38px;
}

.rpls-accordion-filters button:hover {
    background-color: #1b1b1b;
    border-color: #181818;
}

/* Obsolete reaction icon styles removed for clarity. */

/* Reaction Button Styles (at bottom of content) */
.rpls-reaction-container {
    margin-top: 0px;
    text-align: right;
}

.rpls-reaction-container .rpls-reaction-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 20px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.rpls-reaction-container .rpls-reaction-button:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
}

.rpls-reaction-container .rpls-reaction-icon {
    font-size: 1.2em;
}

/* Accordion Footer Styles */
.rpls-accordion-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.rifnote-readmore-button {
    display: none !important;
    background-color: #ed1c24;
    color: #fff;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.2s ease-in-out;
}

.rifnote-readmore-button:hover {
    background-color: #1e639a;
}

.rpls-refresh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    background-color: #f6f7f7;
    cursor: pointer;
    transition: border-color 0.2s ease-in-out;
}

.rpls-refresh-button svg {
    width: 18px;
    height: 18px;
}

.rpls-refresh-button.is-loading svg {
    animation: rpls-spin 1s linear infinite;
}

/* === Mobile Styles === */
@media screen and (max-width: 782px) {
    .rpls-filter-actions {
        gap: 10px;
    }

    .rpls-date-toggle-button,
    .rpls-refresh-button {
        flex-grow: 1;
    }

    .rpls-filter-submit {
        flex-grow: 1;
        flex-shrink: 1;
    }
    
    /* Make filters stack vertically for better usability */
    .rpls-accordion-filters {
        flex-direction: column;
        align-items: stretch;
        position: static; /* Make filter bar scroll with the page on mobile */
        box-shadow: none;
        margin-bottom: 25px;
    }

    /* On mobile, only the date heading is sticky */
    .rpls-date-group-heading {
        /* Stick just below the admin bar, as the filter bar is no longer sticky */
        top: var(--rpls-admin-bar-offset);
        position: -webkit-sticky;
        position: sticky;
        /* Stick below the admin bar and the filter bar */
        top: calc(var(--rpls-admin-bar-offset) + var(--rpls-filter-bar-height));
        z-index: 99; /* Below the filter bar */
        box-shadow: none;
    }

    .rpls-date-filters-wrapper {
        display: none; /* Hide date inputs by default on mobile */
        width: 100%;
    }

    .rpls-filter-actions {
        display: flex;
        width: 100%;
        gap: 15px;
    }

    .rpls-date-toggle-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex-grow: 1;
        padding: 8px 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 600;
        background-color: #f6f7f7;
        cursor: pointer;
        transition: border-color 0.2s ease-in-out;
    }

    .rpls-date-toggle-button.is-active {
        border-color: var(--rpls-theme-color);
    }

    .rpls-filter-submit {
        flex-shrink: 0;
    }

    /* Adjust accordion footer to stack buttons */
    .rpls-accordion-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .rpls-reaction-container {
        width: 100%; /* Make it take full width to align right */
    }

    /* Slightly reduce main title font size for better readability on small screens */
    .rpls-accordion-trigger {
        font-size: 16px;
    }

    .rifnote-readmore-button{
        display: none !important;
    }

	/* Default mobile padding for trending buttons (font-size is now controlled by settings) */
	.rpls-trending-buttons .rpls-trending-button {
		padding: 5px 10px;
	}
}
