/**
 * Changeloger Frontend Changelog Styles
 */

:root {
    --cha-fg-bg: #ffffff;
    --cha-fg-bg-light: #f7f8fc;
    --cha-fg-text: #111827;
    --cha-fg-text-muted: #6b7280;
    --cha-fg-border: #e5e7eb;
    --cha-fg-accent-light: rgba(82, 93, 249, 0.08);
}

.cha-changelog-page {
    width: 100%;

    &.single-cha_release {
        background-color: #fff;
    }
}

.cha-changelog-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 12px;
    background: var(--cha-fg-bg);
    color: var(--cha-fg-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

    .cha-release-item {
        display: flex;
        gap: 56px;
        padding: 48px 0;
        border-bottom: 1px solid var(--cha-fg-border);

        &:first-child {
            padding-top: 0;
        }

        &:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }
    }

    .cha-release-left {
        flex-shrink: 0;
        width: 180px;
        position: sticky;
        top: 100px;
        align-self: flex-start;

        .cha-release-version {
            margin-bottom: 5px;

            .cha-type-badge {
                display: inline-flex;
                align-items: center;
                padding: 3px 8px;
                font-size: 11px;
                font-weight: 600;
                text-transform: uppercase;
                letter-spacing: 0.04em;
                border-radius: 4px;
                margin-left: 10px;
            }
        }
    }

    .cha-version-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: 700;
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
        color: var(--changeloger_brand_color);
        letter-spacing: -0.02em;
    }

    .cha-release-date {
        font-size: 13px;
        color: var(--cha-fg-text-muted);
        font-weight: 500;
    }

    .cha-type-badge {
        &.major {
            background: rgba(239, 68, 68, 0.12);
            color: #dc2626;
        }

        &.minor {
            background: rgba(59, 130, 246, 0.12);
            color: #2563eb;
        }

        &.patch {
            background: rgba(16, 185, 129, 0.12);
            color: #059669;
        }
    }

    .cha-release-right {
        flex: 1;
        min-width: 0;
    }

    .cha-release-featured-image {
        margin-bottom: 16px;
        border-radius: 12px;
        overflow: hidden;
        line-height: 0;

        .cha-featured-img {
            width: 100%;
            height: auto;
            display: block;
            object-fit: cover;
            border-radius: 12px;
        }
    }

    .cha-release-title {
        font-size: 28px;
        font-weight: 700;
        margin: 0 0 12px 0;
        color: var(--cha-fg-text);
        line-height: 1.3;
        letter-spacing: -0.025em;

        a {
            color: inherit;
            text-decoration: none;
            transition: color 0.2s ease;

            &:hover {
                color: var(--changeloger_brand_color, #525df9);
            }
        }
    }

    .cha-release-content {
        font-size: 16px;
        line-height: 1.75;
        color: var(--cha-fg-text-muted);
        margin-bottom: 28px;

        p {
            margin: 0 0 16px 0;

            &:last-child {
                margin-bottom: 0;
            }
        }

        h3,
        h4 {
            font-weight: 600;
            margin: 28px 0 12px 0;
            color: var(--cha-fg-text);
        }

        code {
            background: var(--cha-fg-bg-light);
            padding: 4px 10px;
            border-radius: 6px;
            font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
            font-size: 0.875em;
            color: var(--changeloger_brand_color);
            border: 1px solid var(--cha-fg-border);
        }

        a {
            color: var(--changeloger_brand_color);
            text-decoration: none;
            font-weight: 500;

            &:hover {
                text-decoration: underline;
            }
        }
    }

    .cha-change-section {
        margin-top: 8px;

        & + .cha-change-section {
            margin-top: 12px;
        }

        .cha-change-items {
            padding: 0 14px 16px 14px;
            background: var(--cha-fg-bg-light);
            border: 1px solid var(--cha-fg-border);
            border-top: none;
            border-radius: 0 0 10px 20px;
            transition: all 0.2s ease;

            &[hidden] {
                display: none;
            }

            ul {
                margin: 0;
                padding: 0 !important;
                list-style: none !important;
            }

            li {
                position: relative;
                padding: 0 0 4px 20px;
                margin-bottom: 0 !important;
                font-size: 14px;
                color: var(--cha-fg-text-muted);
                line-height: 1.6;

                &::before {
                    content: '';
                    position: absolute;
                    left: 0;
                    top: 8px;
                    width: 7px;
                    height: 7px;
                    background: var(--changeloger_brand_color);
                    border-radius: 50%;
                }

                &:first-child {
                    padding-top: 0;
                }

                &:last-child {
                    padding-bottom: 0;
                }
            }
        }
    }

    .cha-change-toggle[type=button] {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 14px;
        background-color: transparent;
        border: 0;
        border-bottom: 1px solid var(--cha-fg-border);
        border-radius: 0;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        color: var(--cha-fg-text);
        text-align: left;
        box-shadow: none;

        &:hover {
            color: var(--cha-fg-text);
            border-color: var(--cha-fg-border);
            background-color: transparent;
        }

        &:focus {
            color: var(--cha-fg-text);
            background-color: var(--cha-fg-bg-light);
        }

        &[aria-expanded="true"] {
            border-radius: 10px 10px 0 0;
            border: 1px solid var(--cha-fg-border);
            border-bottom: none;
            background-color: var(--cha-fg-bg-light);

            .cha-toggle-icon {
                transform: rotate(180deg);
            }
        }
    }

    .cha-change-group-name {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .cha-change-count {
        color: var(--cha-fg-text-muted);
        font-weight: 500;
        font-size: 13px;
    }

    .cha-toggle-icon {
        width: 18px;
        height: 18px;
        transition: transform 0.25s ease;
        color: var(--cha-fg-text-muted);
    }

    .cha-no-releases {
        text-align: center;
        padding: 100px 24px;
        color: var(--cha-fg-text-muted);
        font-size: 16px;
        background: var(--cha-fg-bg-light);
        border-radius: 16px;
        border: 1px solid var(--cha-fg-border);
    }
}

@media (max-width: 991px) {
    .cha-changelog-container {
        padding: 36px 16px;

        .cha-release-item {
            gap: 36px;
            padding: 36px 0;
        }

        .cha-release-left {
            width: 150px;
        }

        .cha-version-badge {
            font-size: 20px;
        }

        .cha-release-date {
            font-size: 12px;
        }

        .cha-release-title {
            font-size: 24px;
            margin-bottom: 10px;
        }

        .cha-release-content {
            font-size: 15px;
            line-height: 1.7;
            margin-bottom: 24px;

            h3,
            h4 {
                font-size: 16px;
                margin: 24px 0 10px 0;
            }
        }

        .cha-change-toggle[type=button] {
            font-size: 13px;
            padding: 10px 12px;
        }

        .cha-change-count {
            font-size: 12px;
        }

        .cha-change-section .cha-change-items li {
            font-size: 13px;
        }

        .cha-type-badge {
            font-size: 10px;
            padding: 2px 6px;
        }

        .cha-no-releases {
            font-size: 15px;
            padding: 80px 20px;
        }
    }
}

@media (max-width: 767px) {
    .cha-changelog-container {
        padding: 24px 12px;

        .cha-release-item {
            flex-direction: column;
            gap: 16px;
            padding: 28px 0;
        }

        .cha-release-left {
            position: static;
            width: 100%;
            display: flex;
            align-items: center;
            gap: 12px;

            .cha-release-version {
                margin-bottom: 0;
            }
        }

        .cha-version-badge {
            font-size: 18px;
        }

        .cha-release-date {
            font-size: 11px;
            margin-top: 0;
            padding-left: 0;
        }

        .cha-release-title {
            font-size: 20px;
            margin-bottom: 8px;
        }

        .cha-release-content {
            font-size: 14px;
            line-height: 1.65;
            margin-bottom: 20px;

            p {
                margin: 0 0 12px 0;
            }

            h3,
            h4 {
                font-size: 15px;
                margin: 20px 0 8px 0;
            }

            code {
                font-size: 0.8em;
                padding: 3px 8px;
            }
        }

        .cha-change-toggle[type=button] {
            font-size: 13px;
            padding: 10px 12px;
        }

        .cha-change-count {
            font-size: 11px;
        }

        .cha-toggle-icon {
            width: 16px;
            height: 16px;
        }

        .cha-change-section .cha-change-items {
            padding: 0 12px 14px 12px;

            li {
                font-size: 13px;
                padding: 0 0 4px 18px;

                &::before {
                    width: 6px;
                    height: 6px;
                    top: 10px;
                }

                &:first-child::before {
                    top: 7px;
                }
            }
        }

        .cha-type-badge {
            font-size: 9px;
            padding: 2px 5px;
            margin-left: 8px;
        }

        .cha-no-releases {
            font-size: 14px;
            padding: 60px 16px;
            border-radius: 12px;
        }
    }
}

@media (max-width: 479px) {
    .cha-changelog-container {
        padding: 20px 10px;

        .cha-release-item {
            gap: 14px;
            padding: 24px 0;
        }

        .cha-version-badge {
            font-size: 16px;
        }

        .cha-release-title {
            font-size: 18px;
        }

        .cha-release-content {
            font-size: 13px;
        }

        .cha-change-toggle[type=button] {
            font-size: 12px;
            padding: 8px 10px;
        }

        .cha-change-section .cha-change-items li {
            font-size: 12px;
        }

        .cha-no-releases {
            font-size: 13px;
            padding: 50px 14px;
        }
    }

    .cha-interactions-bar {
        .cha-bar-divider {
            display: none;
        }

        .cha-inline-comment {
            flex: auto !important;
        }
    }
}

.cha-release-excerpt-wrapper {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.4s ease;

    .cha-release-excerpt-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 120px;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 80%, #fff 100%);
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 1;
    }

    .cha-excerpt-read-more {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        padding: 10px 20px;
        background: transparent;
        color: var(--changeloger_brand_color);
        border: none;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        position: absolute;
        bottom: 10px;
        z-index: 2;
        box-shadow: none;
        margin-top: 0;

        svg {
            transition: transform 0.3s ease;
            flex-shrink: 0;
        }
    }

    &.cha-expanded {
        max-height: none;
        overflow: visible;

        .cha-release-excerpt-overlay,
        .cha-excerpt-read-more {
            display: none;
        }
    }

    &.cha-excerpt-no-overflow {
        max-height: none;
        overflow: visible;

        .cha-release-excerpt-overlay,
        .cha-excerpt-read-more {
            display: none;
        }
    }
}

.cha-single-release-container {
    .cha-release-item {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .cha-release-title {
        font-size: 28px;
        line-height: 1.3;
    }
}

@media (max-width: 768px) {
    .cha-single-release-container {
        margin: 20px auto;
        padding: 0 14px;

        .cha-release-title {
            font-size: 22px;
        }
    }

    .cha-release-excerpt-wrapper {
        max-height: 200px;
    }
}

.cha-version-nav {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 16px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--cha-fg-border);

    .cha-version-nav__link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px 20px;
        border: 1px solid var(--cha-fg-border);
        border-radius: 12px;
        text-decoration: none;
        color: var(--cha-fg-text);
        background: var(--cha-fg-bg);
        transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
        min-width: 0;
        flex: 1;
        max-width: 50%;

        &:not(.elementor-button-link):hover {
            border-color: var(--changeloger_brand_color, #525df9);
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
            background: color-mix(in srgb, var(--changeloger_brand_color, #525df9) 4%, var(--cha-fg-bg));
            text-decoration: none;
            color: var(--cha-fg-text);
        }

        &:not(.elementor-button-link) svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            color: var(--cha-fg-text-muted);
            transition: color 0.2s ease;
        }

        &:hover svg {
            color: var(--changeloger_brand_color, #525df9);
        }
    }

    .cha-version-nav__next {
        justify-content: flex-end;
        text-align: right;
        margin-left: auto;
    }

    .cha-version-nav__text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .cha-version-nav__label {
        font-size: 12px;
        font-weight: 500;
        color: var(--cha-fg-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .cha-version-nav__version {
        font-size: 16px;
        font-weight: 700;
        color: var(--changeloger_brand_color, #525df9);
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
        letter-spacing: -0.01em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cha-version-nav__placeholder {
        flex: 1;
        max-width: 50%;
    }
}

@media (max-width: 767px) {
    .cha-version-nav {
        flex-direction: column;
        gap: 10px;
        margin-top: 32px;
        padding-top: 24px;

        .cha-version-nav__link {
            max-width: 100%;
            padding: 14px 16px;
        }

        .cha-version-nav__next {
            flex-direction: row-reverse;
            justify-content: flex-end;
            text-align: left;
        }

        .cha-version-nav__placeholder {
            display: none;
        }

        .cha-version-nav__version {
            font-size: 15px;
        }

        .cha-version-nav__label {
            font-size: 11px;
        }
    }
}

.cha-changelog-container--compact {
    padding: 24px 12px;

    .cha-release-item {
        flex-direction: column;
        gap: 0;
        padding: 20px 24px;
        border-bottom: none;
        margin-bottom: 10px;
        border: 1px solid var(--cha-fg-border);
        border-radius: 10px;
        background: var(--cha-fg-bg);
        transition: box-shadow 0.2s ease, border-color 0.2s ease;

        &:hover {
            border-color: color-mix(in srgb, var(--changeloger_brand_color, #525df9) 30%, transparent);
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
        }

        &:first-child {
            padding-top: 20px;
        }

        &:last-child {
            margin-bottom: 0;
        }
    }

    .cha-release-left {
        position: static;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: initial;
        margin-bottom: 10px;

        .cha-release-version {
            margin-bottom: 0;
        }
    }

    .cha-version-badge {
        font-size: 16px;
    }

    .cha-release-date {
        font-size: 12px;
        opacity: 0.7;
    }

    .cha-release-title {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .cha-release-content {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 12px;
    }

    .cha-release-featured-image {
        margin-bottom: 12px;
        border-radius: 8px;
    }

    .cha-change-toggle[type=button] {
        font-size: 13px;
        padding: 8px 10px;
    }

    .cha-change-section .cha-change-items li {
        font-size: 13px;
    }

    .cha-release-excerpt-wrapper {
        max-height: 150px;
    }

    .cha-type-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

.cha-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 32px 0 16px;
    flex-wrap: wrap;

    a,
    span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        border: 1px solid var(--cha-fg-border);
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        color: var(--cha-fg-text-muted);
        text-decoration: none !important;
        background: var(--cha-fg-bg);
        transition: all 0.2s ease;
        cursor: pointer;
    }

    a:hover {
        border-color: var(--changeloger_brand_color, #525df9);
        color: var(--changeloger_brand_color, #525df9);
        background: color-mix(in srgb, var(--changeloger_brand_color, #525df9) 6%, white);
    }

    .current {
        background: var(--changeloger_brand_color, #525df9);
        border-color: var(--changeloger_brand_color, #525df9);
        color: #fff;
        font-weight: 600;
        cursor: default;
    }

    .dots {
        border: none;
        background: transparent;
        cursor: default;
        min-width: 24px;
        padding: 0;
        letter-spacing: 2px;
    }

    .prev,
    .next {
        font-size: 13px;
        padding: 0 14px;
        gap: 4px;

        svg {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }
    }

    .disabled {
        opacity: 0.4;
        pointer-events: none;
        cursor: default;
    }
}

@media (max-width: 767px) {
    .cha-pagination {
        gap: 4px;
        padding: 24px 0 12px;

        a,
        span {
            min-width: 32px;
            height: 32px;
            font-size: 13px;
            padding: 0 8px;
        }
    }
}
