/* --- Global Styles --- */
:root {
    --dark-bg: #111827; /* Dark blue-grey background */
    --card-bg: #1F2937; /* Lighter grey for cards */
    --border-color: #374151; /* Subtle border */
    --text-primary: #F9FAFB; /* Off-white */
    --text-secondary: #9CA3AF; /* Lighter grey */
    --brand-accent: #3B82F6; /* Blue for buttons/links */
    --brand-accent-hover: #2563EB;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--dark-bg);
    color: var(--text-primary);
}

a {
    color: var(--brand-accent);
    text-decoration: none;
}

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

img {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

h1, h2 {
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }

.loading, .error {
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-align: center;
    padding: 2rem;
}

.error {
    color: #F87171; /* Red for errors */
}

/* --- Header & Search Bar --- */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

header nav .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between logo and text */
}

.header-logo-img {
    height: 32px; /* Control the size of the logo */
    width: 32px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between filter and search */
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header nav form {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--dark-bg);
}

header nav form:focus-within {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 2px var(--brand-accent);
}

header nav input[type="search"] {
    min-width: 250px;
    padding: 0.4rem 0.6rem;
    border: none; /* Remove individual border */
    background-color: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
}

header nav input[type="search"]:focus {
    outline: none;
    box-shadow: none; /* Remove the focus shadow from the input itself */
}

header nav button[type="submit"] {
    padding: 0.4rem 0.6rem;
    border: none; /* Remove individual border */
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem; /* Adjust size for the icon */
}

header nav button[type="submit"]:hover {
    color: var(--brand-accent);
}

/* --- NEW --- */
.toggle-control {
  display: flex;
  align-items: center;
  margin-right: 20px;
}

.toggle-control label {
    margin-right: 10px;
    font-size: 14px;
    color: #f5f3f3;
    white-space: nowrap;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #007bff;
}

input:focus + .slider {
  box-shadow: 0 0 1px #007bff;
}

input:checked + .slider:before {
  -webkit-transform: translateX(20px);
  -ms-transform: translateX(20px);
  transform: translateX(20px);
}


#results {
  margin-bottom: 20px;
}

/* --- Integration Grid & Cards --- */
.integration-grid {
    display: grid;
    /* This will create 1-4 columns based on viewport width */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.integration-card {
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box; /* Include padding/border in width */
}

.integration-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: #4B5563;
}

.integration-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.integration-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    background-color: white;
    padding: 4px;
    flex-shrink: 0;
}

.integration-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
}

.integration-version {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-family: monospace;
}

.integration-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    flex-grow: 1; /* Pushes the button to the bottom */
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.btn-details {
    display: inline-block;
    text-align: center;
    padding: 0.6rem 1rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-details:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
}


/* --- Integration Detail Page --- */
.detail-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.detail-icon {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    background-color: white;
    padding: 8px;
}

.detail-header h1 {
    border-bottom: none;
    margin: 0;
}

.download-controls {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    align-items: center;
}

.download-controls select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.btn-download {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--brand-accent);
    color: var(--text-primary);
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s;
    border: 1px solid var(--brand-accent);
}

.btn-download:hover {
    background-color: var(--brand-accent-hover);
    text-decoration: none;
}

.category-icon {
    height: 1.75rem; /* Match the font size of the h2 */
    width: 1.75rem;
    vertical-align: middle; /* Align the icon with the text */
    margin-right: 0.75rem;
}

/* --- Three-Column Detail Page Layout --- */
.three-column-layout {
    display: grid;
    grid-template-columns: 275px 1fr 275px; /* Left, Center, Right */
    gap: 2rem;
    align-items: start;
}

.detail-left-sidebar {
    position: sticky;
    top: 2rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.detail-left-sidebar .detail-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
}

.detail-left-sidebar h1 {
    font-size: 1.5rem;
    border: none;
    margin-bottom: 0.5rem;
}

.detail-left-sidebar .version-display {
    font-family: monospace;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.detail-left-sidebar .btn-download {
    width: 100%; /* Make button full-width */
    margin-top: 1.5rem;
}

.detail-center-content {
    min-width: 0;
}

.detail-right-sidebar {
    position: sticky;
    top: 2rem;
}

.detail-right-sidebar h3 {
    margin-top: 0;
}

.screenshot-gallery {
    margin-top: 2rem;
}

.screenshot-gallery h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.screenshot-carousel {
    position: relative;
}

.screenshot-carousel-viewport {
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.screenshot-carousel-track {
    display: flex;
    transition: transform 0.3s ease-in-out;
}

.screenshot-carousel-track img {
    width: 100%;
    flex-shrink: 0;
}

.screenshot-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.screenshot-nav button {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
}


/* --- Data Streams Styles --- */
.data-streams-list {
    margin: 2rem 0;
}

.data-streams-list h3 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.data-stream-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    cursor: pointer; /* Indicate it's clickable */
}

.data-stream-item h4 {
    margin: 0 0 0.5rem 0;
}

.data-stream-item p {
    margin: 0;
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.875rem;
}

.json-viewer {
    margin-top: 1rem;
    background-color: var(--dark-bg);
    padding: 1rem;
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.json-viewer pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Carousel Styles --- */
.carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.carousel-header h2 {
    margin: 0;
    border-bottom: none;
}

.carousel-nav .carousel-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.carousel-nav .carousel-btn:hover:not(:disabled) {
    background-color: #374151;
}

.carousel-nav .carousel-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.carousel-viewport {
    overflow: hidden;
    /* --- NEW --- Add some margin if buttons are outside */
}

.horizontal-list {
    display: flex;
    /* --- REMOVED gap --- We handle spacing via card width */
    transition: transform 0.3s ease-in-out;
}

.horizontal-list .integration-card {
    flex-shrink: 0; /* Prevent cards from shrinking */
    /* --- UPDATED --- Set base width for 5 cards across */
    width: 20%;
    /* --- NEW --- Add margin for spacing instead of gap */
    margin-right: 1.5rem;
}

/* --- UPDATED --- Remove the last card's margin */
.horizontal-list .integration-card:last-child {
    margin-right: 0;
}

/* --- New Browse Page Styles --- */
.browse-container {
    display: grid;
    grid-template-columns: 250px 1fr; /* Sidebar and main content */
    gap: 2rem;
    align-items: start;
}

.browse-sidebar {
    position: sticky;
    top: 2rem;
}

.filter-group {
    margin-bottom: 2rem;
}

.filter-group label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.owner-filter-group,
#type-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.owner-filter-group input[type="radio"],
#type-filters input[type="radio"] {
    display: none; /* Hide the default radio button */
}
.owner-filter-group label,
#type-filters label {
    display: block;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-weight: 500;
}
.owner-filter-group label:hover,
#type-filters label:hover {
    background-color: var(--border-color);
}
.owner-filter-group input[type="radio"]:checked + label,
#type-filters input[type="radio"]:checked + label {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--text-primary);
}

#text-filter {
    width: 100%;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.category-filter-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 1rem;
}

.category-filter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-filter-item label {
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.category-filter-item input {
    cursor: pointer;
}

/* --- New "Browse All" Link Styles --- */
/* .carousel-header .browse-all-link {
    font-size: 1rem;
    font-weight: 500;
    margin-left: 1.5rem; /* Add space between buttons and link
} */

.carousel-header .browse-all-link {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    margin-left: 1.5rem; /* Add space between buttons and link */
    transition: all 0.2s;
}

.carousel-header .browse-all-link:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
}

/* --- Responsive Design Adjustments for Carousel --- */

/* For Tablets and smaller desktops */
@media (max-width: 1200px) {
    .horizontal-list .integration-card {
        width: 25%; /* Show 4 cards */
    }
}
@media (max-width: 1024px) {
    .three-column-layout {
        grid-template-columns: 1fr; /* Switch to a single column */
    }

    .detail-left-sidebar, .detail-right-sidebar {
        position: static; /* Un-stick the sidebars */
        width: 100%;
        max-width: 500px; /* Stop them from being overly wide */
        margin: 0 auto 2rem auto; /* Center them */
    }

    .horizontal-list .integration-card {
        width: 33.333%; /* Show 3 cards */
    }
}

/* For mobile devices */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header nav {
        flex-direction: column;
        gap: 1rem;
    }

    .horizontal-list .integration-card {
        width: 50%; /* Show 2 cards */
         margin-right: 1rem; /* Reduce margin */
    }

    .integration-card {
        padding: 1rem;
    }
}

/* For very small mobile devices */
@media (max-width: 480px) {
    .horizontal-list .integration-card {
        width: 80%; /* Show ~1 card */
        margin-right: 1rem;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }

    header nav form, .filter-container {
        width: 100%;
    }

    header nav input[type="search"] {
        min-width: 0;
        width: 100%;
    }
}

/* --- README Styles --- */
.readme-container h3, .readme-container h4 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.readme-container p {
    line-height: 1.6;
    color: var(--text-secondary);
}

.readme-container a {
    color: var(--brand-accent);
}

.readme-container a:hover {
    text-decoration: underline;
}

.readme-container code {
    background-color: var(--dark-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.readme-container pre {
    background-color: var(--dark-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

/* --- Pagination Styles --- */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-bottom: 2rem; /* Add some space at the bottom */
}

.pagination-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--border-color);
}

.pagination-btn.active {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--text-primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-ellipsis {
    color: var(--text-secondary);
    padding: 0 0.25rem;
}
/* --- END NEW STYLES --- */