/**
 * Sortable Post Gallery Widget - Dedicated Styles
 */

/* ========================================
   Gallery Wrapper
   ======================================== */

.spg-gallery-wrapper {
    width: 100%;
    margin: 0 auto;
    clear: both;
}

/* ========================================
   Filter Header
   ======================================== */

.spg-filter-header {
    margin-bottom: 40px;
    border-bottom: 1px solid #e0e0e0;
}

/* Sticky Filter Header */
.spg-sticky-enabled .spg-filter-sticky-wrapper {
    position: relative;
}

.spg-sticky-enabled .spg-filter-sticky-wrapper.is-stuck {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.spg-sticky-enabled .spg-filter-header.has-stuck-header {
    margin-bottom: 0;
}

.spg-sticky-placeholder {
    display: none;
}

.spg-sticky-enabled .spg-filter-header.has-stuck-header .spg-sticky-placeholder {
    display: block;
    height: 140px;
}

/* Filter Top Row */
.spg-filter-top-row {
    display: flex;
    align-items: center;
    padding: 20px 0;
    gap: 15px;
}

.spg-filter-menu {
    display: flex;
    gap: 40px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.spg-menu-item {
    cursor: pointer;
    font-size: 15px;
    font-weight: 400;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
    letter-spacing: 0.3px;
}

.spg-menu-item.active {
    font-weight: 600;
    color: #000;
}

.spg-menu-item:hover {
    color: #000;
}

/* Custom Year Dropdown (Timeline View) */
.spg-year-dropdown-wrapper {
    display: none;
    align-items: center;
}

.spg-custom-select {
    position: relative;
    min-width: 120px;
    user-select: none;
}

.spg-select-selected {
    padding: 6px 30px 6px 12px;
    font-size: 14px;
    font-weight: 400;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.spg-select-selected:hover {
    border-color: #000;
    color: #000;
}

.spg-select-selected.spg-select-arrow-active {
    border-color: #000;
}

/* Show dropdown on hover */
.spg-year-dropdown-wrapper:hover .spg-select-items {
    display: block;
}

.spg-select-items {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 99;
    max-height: 300px;
    overflow-y: auto;
}

.spg-select-hide {
    display: none;
}

.spg-select-items div {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.spg-select-items div:last-child {
    border-bottom: none;
}

.spg-select-items div:hover {
    background-color: #f5f5f5;
    color: #000;
}

.spg-select-items div.same-as-selected {
    background-color: #f0f0f0;
    font-weight: 600;
    color: #000;
}

/* Search - New Implementation with Unique Classes */
div.spg-search-bar {
    display: flex;
    align-items: center;
    margin-left: auto; /* Push to right */
}

form.spg-search-form {
    display: inline-flex;
    align-items: center;
    max-width: 0;
    width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.5s ease, opacity 0.5s ease, width 0.5s ease;
}

form.spg-search-form.spg-open {
    max-width: 200px;
    width: 200px;
    opacity: 1;
}

input.spg-search-input {
    margin: 0 0.4em;
    border: none;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    color: #333;
    font-family: inherit;
    font-size: 16px;
    padding: 8px 12px;
    width: 100%;
    min-width: 150px;
}

input.spg-search-input:focus {
    outline: none;
    border-bottom-color: #000;
    background: #fff;
}

input.spg-search-input::placeholder {
    color: #999;
}

span.spg-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: color 0.3s ease;
    flex-shrink: 0;
}

span.spg-search-icon:hover {
    color: #000;
}

span.spg-search-icon i {
    font-size: 18px;
    pointer-events: none; /* Ensure clicks pass through to parent */
}

/* Filter Bottom Row */
.spg-filter-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    position: relative;
}

.spg-filter-options {
    display: none;
    gap: 30px;
    align-items: center;
    flex: 1;
}

.spg-filter-options.active {
    display: flex;
}

.spg-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: color 0.2s ease;
}

.spg-filter-option:hover {
    color: #000;
}

.spg-filter-option input[type="radio"] {
    display: none;
}

.spg-radio {
    width: 14px;
    height: 14px;
    border: 2px solid #000;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}

.spg-filter-option input[type="radio"]:checked + .spg-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: #000;
    border-radius: 50%;
}

.spg-filter-option:hover .spg-radio {
    box-shadow: 0 0 0 4px rgba(0,0,0,0.05);
}

/* View Toggle */
.spg-view-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.spg-view-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #999;
    transition: color 0.3s ease;
}

.spg-view-btn.active {
    color: #000;
}

.spg-view-btn:hover {
    color: #000;
}

.spg-view-divider {
    color: #ddd;
    font-size: 18px;
}

/* ========================================
   Grid View
   ======================================== */

.spg-grid-container {
    padding: 0;
    margin: 0;
    max-width: 100%;
}

.spg-grid-row {
    margin-bottom: 0;
}

.spg-grid-col {
    padding: 0;
    margin-bottom: 20px;
}

/* Grid Post Container */
.spg-grid-post {
    position: relative;
    overflow: hidden;
    border-bottom: 10px solid #333;
    background: #fff;
}

.spg-post-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0f0f0;
    padding-bottom: 0;
}

.spg-post-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.spg-grid-post:hover .spg-post-image-wrapper img {
    transform: scale(1.05);
}

/* Overlay Container (contains title + content) */
.spg-post-overlay {
    position: absolute;
    bottom: -125px; /* Hide 125px of 135px content, show only 10px */
    left: 0;
    right: 0;
    transition: bottom 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3;
}

/* Hover: Show full 135px of overlay content */
.spg-grid-post:hover .spg-post-overlay {
    bottom: 0;
}

/* Title (inside overlay, at top) */
.spg-post-info {
    padding: 20px 20px 10px 20px;
    pointer-events: none;
}

.spg-post-title {
    font-size: 20px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: #fff !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    line-height: 1.3 !important;
}

.spg-post-title a {
    color: #fff !important;
    text-decoration: none !important;
    pointer-events: all;
}

.spg-post-title a:hover {
    color: #fff !important;
}

/* Overlay Content (channel color background) */
.spg-overlay-content {
    padding: 20px;
    height: 135px; /* Fixed height for consistent behavior */
    overflow: hidden;
}

.spg-overlay-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    gap: 15px;
}

.spg-post-channels {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex: 1;
    line-height: 1.4;
}

.spg-post-status {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    text-align: right;
    white-space: nowrap;
}

.spg-post-excerpt {
    font-size: 13px;
    line-height: 1.7;
    color: #fff;
    margin: 0;
    opacity: 0.95;
}

.spg-no-image {
    width: 100%;
    height: 100%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Timeline View
   ======================================== */

.spg-timeline-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 40px 0;
}

.spg-timeline-intro {
    font-size: 15px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.spg-timeline-year-section {
    position: relative;
    margin-bottom: 30px;
}

.spg-timeline-year-section.collapsed .spg-timeline-posts {
    display: none;
}

.spg-timeline-year-section.collapsed .spg-year-toggle svg {
    transform: rotate(-90deg);
}

.spg-timeline-year {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    position: relative;
    padding-left: 5px;
}

.spg-year-marker {
    width: 14px;
    height: 14px;
    background: #000;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.spg-year-marker::before {
    content: '';
    position: absolute;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%);
    width: 1px;
    height: 50px;
    background-image: repeating-linear-gradient(
        to bottom,
        #000 0,
        #000 4px,
        transparent 4px,
        transparent 8px
    );
}

.spg-timeline-year-section:last-child .spg-year-marker::before {
    display: none;
}

.spg-year-text {
    font-size: 24px;
    font-weight: 600;
    color: #000;
    letter-spacing: -0.5px;
}

.spg-year-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
    transition: all 0.3s ease;
    margin-left: auto;
}

.spg-year-toggle:hover {
    color: #000;
}

.spg-timeline-posts {
    margin-left: 0;
    padding-left: 29px;
}

.spg-timeline-post {
    position: relative;
    border-left: 10px solid #333;
    padding: 18px 25px;
    margin-bottom: 12px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    background: transparent;
}

.spg-timeline-post-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.spg-timeline-post-title {
    font-size: 24px !important;
    font-weight: 400 !important;
    color: #000 !important;
    margin: 0 !important;
    flex: 1;
    letter-spacing: -0.3px;
    transition: color 0.3s ease;
}

.spg-timeline-post-title a {
    color: #000 !important;
    text-decoration: none !important;
}

.spg-timeline-post-status {
    font-size: 18px;
    color: #000;
    white-space: nowrap;
    font-weight: 400;
    transition: color 0.3s ease;
}

/* Timeline Hover Effect */
.spg-timeline-hover-image {
    position: absolute;
    left: 50%;
    top: -20px;
    transform: translateX(-50%);
    width: 350px;
    height: 230px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.spg-timeline-hover-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.spg-timeline-post {
    position: relative; /* Required for absolute positioning of image */
}

.spg-timeline-post:hover {
    /* Background color set via JavaScript */
}

.spg-timeline-post:hover .spg-timeline-post-title,
.spg-timeline-post:hover .spg-timeline-post-status {
    color: #fff !important;
}

.spg-timeline-post:hover .spg-timeline-post-title a {
    color: #fff !important;
}

.spg-timeline-post:hover .spg-timeline-hover-image {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Pagination
   ======================================== */

.spg-pagination {
    margin-top: 60px;
}

.spg-pagination-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.spg-load-more-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
    min-height: 44px;
    padding: 12px 28px;
    border: 1px solid #000;
    border-radius: 3px;
    background: #000;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.spg-load-more-button:hover:not(:disabled) {
    background: #fff;
    color: #000;
}

.spg-load-more-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

/* ========================================
   Loading & Messages
   ======================================== */

.spg-loading,
.spg-no-posts,
.spg-error {
    text-align: center;
    padding: 80px 20px;
    font-size: 15px;
    color: #999;
}

.spg-error {
    color: #d00;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 992px) {
    .spg-filter-menu {
        gap: 25px;
    }
    
    .spg-filter-options {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .spg-filter-top-row {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .spg-filter-menu {
        flex-wrap: wrap;
        gap: 15px;
        font-size: 14px;
    }
    
    .spg-filter-options {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .spg-search-wrapper.expanded .spg-search-input {
        width: 180px;
    }
    
    .spg-grid-col {
        margin-bottom: 15px;
    }
    
    .spg-post-title {
        font-size: 16px !important;
    }
    
    .spg-post-info {
        bottom: 15px;
        left: 15px;
        right: 15px;
    }
    
    .spg-overlay-content {
        padding: 15px;
    }
    
    .spg-post-channels,
    .spg-post-status,
    .spg-post-excerpt {
        font-size: 12px;
    }
    
    .spg-timeline-post-title {
        font-size: 18px !important;
    }
    
    .spg-timeline-post-status {
        font-size: 14px;
    }
    
    .spg-timeline-hover-image {
        display: none;
    }
    
    .spg-year-text {
        font-size: 20px;
    }
    
    .spg-timeline-post {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .spg-view-toggle {
        margin-top: 10px;
    }
    
    .spg-filter-bottom-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}
