/* Container Structure */
.clads-wrapper {
    width: 100%;
}

/* Mobile Dropdown Wrapper */
.clads-mobile-select-wrapper {
    position: relative;
    display: none;
    width: 100%;
    margin-bottom: 20px;
}

/* Custom Dropdown Icon */
.clads-dropdown-icon {
    position: absolute;
    top: 50%;
    right: 15px; /* Default spacing, can be overridden by Elementor controls */
    transform: translateY(-50%);
    pointer-events: none;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    color: #555; /* Default color */
    font-size: 14px; /* Default size */
    z-index: 2; /* Ensure it stays above the select */
}

/* Mobile Dropdown */
.clads-mobile-select {
    width: 100%;
    padding: 10px 40px 10px 10px; /* Extra right padding to avoid text overlapping icon */
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    /* Remove default browser arrow completely */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    position: relative;
    z-index: 1;
    cursor: pointer;
}

/* WebKit (Chrome, Safari, Edge) specific hiding of the select arrow */
.clads-mobile-select::-webkit-calendar-picker-indicator {
    display: none !important;
    opacity: 0;
}

/* For IE/Edge to remove the arrow */
.clads-mobile-select::-ms-expand {
    display: none !important;
}

/* Horizontal Layout (Default) */
.clads-layout-top .clads-tabs-container {
    width: 100%;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e5e5;
}

.clads-layout-top .clads-tabs-scroll {
    display: flex;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

/* Vertical Layout (Left) */
.clads-layout-left {
    display: flex;
    flex-wrap: wrap; 
}

.clads-layout-left .clads-tabs-container {
    border-right: 2px solid #e5e5e5;
    padding-right: 20px;
}

.clads-layout-left .clads-tabs-scroll {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 100%;
}

/* Added flex-grow and flex-shrink rules so content container doesn't collapse */
.clads-layout-left .clads-content-container {
    padding-left: 20px;
    flex: 1 1 100%; /* Force it to take available space */
    min-width: 0;
    width: 100%;
}

/* Scrollbar Hiding */
.clads-tabs-scroll::-webkit-scrollbar { 
    display: none; 
}
.clads-tabs-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Tab Items */
.clads-tab-item {
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    transition: all 0.3s ease;
    outline: none;
    text-align: center;
    /* Force equal width with flex */
    flex: 1 1 0px; 
    min-width: fit-content;
}

/* Horizontal Specifics */
.clads-layout-top .clads-tab-item {
    border-bottom: 3px solid transparent;
}
.clads-layout-top .clads-tab-item.active {
    border-bottom-color: #0073e6;
    color: #000;
}

/* Vertical Specifics */
.clads-layout-left .clads-tab-item {
    border-left: 3px solid transparent;
    text-align: left; /* Keep left alignment for vertical layout */
}
.clads-layout-left .clads-tab-item.active {
    border-left-color: #0073e6;
    color: #000;
    background-color: #f9f9f9;
}

/* Content Area */
.clads-content-container {
    position: relative;
    min-height: 200px;
    width: 100%; 
}

/* Search Bar */
.clads-search-wrapper {
    margin-bottom: 20px;
    width: 100%;
    display: flex;
}

.clads-search-inner {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Added wrapper for input to correctly position clear button */
.clads-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
}

.clads-search-input {
    flex: 1;
    padding: 12px 35px 12px 15px; /* Right padding ensures text doesn't hide under clear button */
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s ease;
    outline: none;
    width: 100%;
}

.clads-search-input:focus {
    border-color: #0073e6;
}

/* Fixed clear button positioning */
.clads-search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    display: none; 
    outline: none;
    line-height: 1;
}

.clads-search-clear-btn:hover {
    color: #333;
}

.clads-search-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    background-color: #0073e6;
    color: #fff;
    border: 1px solid #0073e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.clads-search-btn:hover {
    opacity: 0.9;
}

.clads-loader {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: clads-spin 1s linear infinite;
    z-index: 10;
}

@keyframes clads-spin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* Grid Layout */
.clads-grid {
    display: grid;
    width: 100%;
    align-items: start;
    justify-content: start; /* Prevents space-between stretching */
}

/* Desktop Grid Layout classes - Default fallback if elementor responsive doesn't inject inline style */
.clads-grid.clads-cols-desktop-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.clads-grid.clads-cols-desktop-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.clads-grid.clads-cols-desktop-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.clads-grid.clads-cols-desktop-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.clads-grid.clads-cols-desktop-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.clads-grid.clads-cols-desktop-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* Tablet Grid Layout classes */
@media (max-width: 1024px) and (min-width: 768px) {
    .clads-grid.clads-cols-tablet-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-tablet-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-tablet-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-tablet-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-tablet-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-tablet-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
}

/* Mobile Grid Layout classes */
@media (max-width: 767px) {
    .clads-grid.clads-cols-mobile-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-mobile-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-mobile-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-mobile-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
    .clads-grid.clads-cols-mobile-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
}

/* Item Wrapper */
.clads-item-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Category Badge */
.clads-category-badge {
    position: absolute;
    top: -15px; /* Offset to float outside slightly */
    right: 20px;
    background-color: #0073e6;
    color: #ffffff;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    /* Removed default border-radius to allow Elementor control to work without !important */
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Equal Height Logic */
.clads-equal-height .clads-grid {
    align-items: stretch;
}
.clads-equal-height .clads-grid-item {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.clads-equal-height .clads-item-wrapper > .elementor,
.clads-equal-height .clads-item-wrapper > .elementor > .e-con,
.clads-equal-height .clads-item-wrapper > .elementor > .e-container {
    height: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Equal Width Logic */
.clads-equal-width .clads-grid {
    justify-items: stretch;
}
.clads-equal-width .clads-grid-item {
    width: 100%;
}

/* Masonry Override */
.clads-grid.clads-masonry {
    display: block; 
    width: 100%;
}

.clads-grid-item {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevents content from overflowing and stretching the column */
}

.clads-item-wrapper > .elementor {
    flex-grow: 1;
    width: 100%;
}

/* Desktop Masonry Column Widths */
.clads-grid.clads-masonry.clads-cols-desktop-1 .clads-grid-item { width: 100%; }
.clads-grid.clads-masonry.clads-cols-desktop-2 .clads-grid-item { width: calc(50% - (var(--grid-gap, 20px) / 2)); float: left; }
.clads-grid.clads-masonry.clads-cols-desktop-3 .clads-grid-item { width: calc(33.333% - (var(--grid-gap, 20px) * 2 / 3)); float: left; }
.clads-grid.clads-masonry.clads-cols-desktop-4 .clads-grid-item { width: calc(25% - (var(--grid-gap, 20px) * 3 / 4)); float: left; }
.clads-grid.clads-masonry.clads-cols-desktop-5 .clads-grid-item { width: calc(20% - (var(--grid-gap, 20px) * 4 / 5)); float: left; }
.clads-grid.clads-masonry.clads-cols-desktop-6 .clads-grid-item { width: calc(16.666% - (var(--grid-gap, 20px) * 5 / 6)); float: left; }

/* Tablet Masonry Column Widths */
@media (max-width: 1024px) and (min-width: 768px) {
    .clads-grid.clads-masonry.clads-cols-tablet-1 .clads-grid-item { width: 100% !important; margin-right: 0 !important; }
    .clads-grid.clads-masonry.clads-cols-tablet-2 .clads-grid-item { width: calc(50% - 10px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-tablet-3 .clads-grid-item { width: calc(33.333% - 13.33px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-tablet-4 .clads-grid-item { width: calc(25% - 15px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-tablet-5 .clads-grid-item { width: calc(20% - 16px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-tablet-6 .clads-grid-item { width: calc(16.666% - 16.66px) !important; float: left; }
}

/* Mobile Masonry Column Widths */
@media (max-width: 767px) {
    .clads-grid.clads-masonry.clads-cols-mobile-1 .clads-grid-item { width: 100% !important; margin-right: 0 !important; }
    .clads-grid.clads-masonry.clads-cols-mobile-2 .clads-grid-item { width: calc(50% - 10px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-mobile-3 .clads-grid-item { width: calc(33.333% - 13.33px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-mobile-4 .clads-grid-item { width: calc(25% - 15px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-mobile-5 .clads-grid-item { width: calc(20% - 16px) !important; float: left; }
    .clads-grid.clads-masonry.clads-cols-mobile-6 .clads-grid-item { width: calc(16.666% - 16.66px) !important; float: left; }
}


/* Numbered Pagination */
.clads-pagination-wrapper {
    margin-top: 40px;
    text-align: center;
    width: 100%;
}

.clads-pagination-numbers {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    align-items: center;
}

.clads-page-link {
    background-color: #f1f1f1;
    color: #333;
    border: none;
    padding: 8px 16px;
    font-size: 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.clads-page-link:hover {
    background-color: #e0e0e0;
}

.clads-page-link.active {
    background-color: #0073e6;
    color: #ffffff;
    cursor: default;
}

.clads-page-dots {
    padding: 0 8px;
    color: #777;
    font-weight: bold;
}

/* Mobile Responsiveness General */
@media (max-width: 767px) {
    .clads-mobile-select-wrapper {
        display: block;
    }
    .clads-dropdown-icon {
        display: flex; /* Only show on mobile */
    }
    .clads-tabs-scroll {
        display: none !important;
    }
    .clads-tabs-container {
        border-bottom: none !important;
        border-right: none !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    .clads-layout-left {
        flex-direction: column;
    }
    .clads-layout-left .clads-content-container {
        width: 100% !important;
        padding-left: 0;
    }
    .clads-search-inner {
        flex-direction: column;
        width: 100%;
    }
    .clads-input-wrapper {
        width: 100%;
    }
    .clads-search-btn {
        width: 100%;
    }
}