/* app-switch */
.app-switch {
    --switch-gap: 5px;
    --switch-padding: 3px;
    --switch-item-size: 36px;
    display: flex;
    gap: var(--switch-gap);
    padding: var(--switch-padding);
    position: relative;
    overflow: hidden;

    & span {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--switch-item-size);
        height: var(--switch-item-size);
        cursor: pointer;
    }

    & > span {
        position: relative;
        z-index: 1;
        opacity: .6;
        transition: opacity 260ms;
        &:hover, &._active { opacity: 1; }
    }

    &:before {
        content: '';
        display: block;
        width: var(--switch-item-size);
        height: var(--switch-item-size);
        border: 1px solid #ddd;
        border-radius: 5px;
        background: white;
        position: absolute;
        top: var(--switch-padding);
        left: var(--switch-padding);
        transition: left 180ms;
        box-shadow: 0 0 6px 0 rgba(0, 0, 0, .1);
    }

    &._active:before {
        left: calc(var(--switch-item-size) + var(--switch-padding) + var(--switch-gap));
    }
}

/* app-pagination */
button.app-pagination {
    border: 1px solid transparent;
    border-radius: 6px;
    min-width: 44px;

    &._active, &:focus {
        border-color: #e4e8ea;
        background: white;
    }
    &:hover, &:active {
        border-color: #e4e8ea !important;
    }
    &:active {
        background: #f6f6f6;
    }
    &:disabled {
        opacity: .5;
        cursor: not-allowed;
        border: none;
    }
}
span.app-pagination {
    color: #999;
    font-size: 1.2rem;
    pointer-events: none;
    user-select: none;
    position: relative;
    top: -.3em;
}

/* app-input-search */
.app-input-search {
    position: relative;
    input {
        padding-left: 36px !important;
        padding-right: 36px !important;
        &:not(:placeholder-shown) {
            border-color: var(--sc-color);
        }
    }
    [data-role="icon"] {
        position: absolute;
        top: 50%;
        left: 10px;
        transform: translateY(-50%);
        color: #999;
    }
    [data-role="close"] {
        position: absolute;
        top: 54%;
        right: 10px;
        transform: translateY(-50%);
        color: #999;
        transition: all 0.25s;
        transition-behavior: allow-discrete;
        scale: 1.2;
    }
}

/* loadings */
.app-loading {
    position: relative;
    &:after {
        content: '';
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(255, 255, 255, .34);
        z-index: 1;
    }
}
.app-progress {
    width: 60px;
    height: 40px;
    --color: #514b82;
    --g1: conic-gradient(from  90deg at left 0 top 0, var(--color) 90deg, var(--color) 0);
    --g2: conic-gradient(from -90deg at bottom 0 right 0, var(--color) 90deg, var(--color) 0);
    background: var(--g1), var(--g1), var(--g1), var(--g2), var(--g2), var(--g2);
    background-position: left,center,right;
    background-repeat: no-repeat;
    animation: progress-l9 1s infinite;
    border-radius: 2px;
    opacity: .6;
}
@keyframes progress-l9 {
    0%   {background-size:15px 50% ,15px 50% ,15px 50%}
    25%  {background-size:15px 100%,15px 50% ,15px 50%}
    50%  {background-size:15px 50% ,15px 100%,15px 50%}
    75%  {background-size:15px 50% ,15px 50% ,15px 100%}
    100% {background-size:15px 50% ,15px 50% ,15px 50%}
}

/* app-show-more */
@media screen {
    .app-show-more {
        --initial-height: 150px;
        overflow: hidden;
        position: relative;
        transition: height 150ms ease-in-out;
        transition-behavior: allow-discrete;
        height: auto;
        height: calc-size(auto, size);

        &._closed {
            height: var(--initial-height);
            cursor: pointer;

            @starting-style {
                height: var(--initial-height);
            }

            &:after {
                content: '';
                display: block;
                position: absolute;
                inset: 0;
                background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 1) 100%);
                z-index: 1;
                pointer-events: none;
            }
        }
    }

    .app-show-more-btn {
        right: 15px;
        top: 10px;
    }
}

/* app-popover */
.app-popover {
    position: absolute;
    margin: 0;
    inset: auto;
    top: calc(anchor(top) - 5px);
    right: anchor(right);
    background: white;
    padding: 10px;
    border: 1px solid #e9e9e9;
    border-radius: 12px;
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, .1);
    opacity: 0;
    transition: display 200ms, opacity 200ms;
    transition-behavior: allow-discrete;
}

.app-popover:popover-open {
    display: grid;
    opacity: 1;
    @starting-style {
        opacity: 0;
    }
}

/* app-me */
.app-me {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #ccc;
    color: white;
    font-size: .9rem;
}

/* app-list */
.app-list {
    background: transparent;
}
.app-list-item {
    position: relative;
    background: transparent;
}
.app-list-item-active {
    background: white;
}
.app-list-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-rows: 1fr;
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--app-border-color);
    border-radius: var(--app-border-radius);
    overflow: hidden;
    border-collapse: collapse;
}
.app-list-gallery-item {
    padding: 1rem;
    border: 1px solid var(--app-border-color);
    margin: -1px;
}
.app-list-filter-tabs {
    span {
        font-weight: bold;
        cursor: pointer;
        display: inline-block;
        padding-right: 1rem;
        color: var(--sc-gray);
        position: relative;

        &._active {
            color: black;

            &:after {
                content: '';
                position: absolute;
                left: 0;
                right: 1em;
                bottom: -3px;
                height: 3px;
                background: var(--sc-color);
                border-radius: 3px;
            }
        }
    }
    small {
        font-weight: normal;
        font-size: 1em;
    }
}
:nth-last-child(1 of .app-list-divider) {
    border-bottom-width: 4px;
}
@media (min-width: 1400px) {
    .app-list-gallery {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* app-panel-right */
.app-panel-right {
    --width : 380px;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 7;
    background: white;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, .1);

    &._collapsed {
        width: auto !important;
        cursor: default !important;
        box-shadow: none;

        .app-panel-right-content {
            width: 0 !important;
            opacity: 0 !important;
            right: -400px !important;
        }
    }
}

.app-panel-right-content {
    right: 0;
    width: var(--width);
    opacity: 1;
    overflow: hidden;
    max-width: calc(100vw - 10px);
    position: relative;
    transition: all 180ms ease;
    z-index: 9;
    height: auto;
}

.app-panel-right-tabs {
    background: #fbfbfb;
    position: relative;
    z-index: 9;
}
.app-panel-right-tab {
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 120ms ease;
    transition-behavior: allow-discrete;
    position: relative;
    border-left: 1px solid #dee2e6;
    color: var(--sc-gray);
    left: -1px;

    i {
        opacity: .7;
        transition: all 120ms ease;
        scale: 1;
    }

    &:hover i {
        opacity: 1;
        scale: 1.2;
    }

    &:not(:last-child):after {
        content: '';
        position: absolute;
        left: 10px;
        right: 10px;
        bottom: 0;
        height: 1px;
        background: #ddd;
    }

    &._active {
        background: white;
        color: var(--sc-color);

        i {
            opacity: 1;
            scale: 1.2;
        }
    }
}

/* app-box-scroll */
.app-box-scroll {
    overflow: auto !important;

    &::-webkit-scrollbar {
        width: 4px;
    }

    &::-webkit-scrollbar-track {
        background: transparent;
        position: relative;
    }

    &::-webkit-scrollbar-thumb {
        background-color: transparent;
        border-radius: 4px;
        transition: background-color 320ms ease;
    }

    &:has(> *:hover)::-webkit-scrollbar-thumb {
        background-color: #ccc;
    }

    &::-webkit-scrollbar-thumb:hover {
        background-color: #999;
    }
}

.app-box-absolute {
    position: absolute;
    inset: 0;
}

/* app-ai-support */
.ai-support-message {
    display: flex;
    gap: 1rem;
    border-radius: 12px;
    color: var(--sc-color);
    background: var(--sc-color-bg);
    padding: .8em;
    font-size: .9rem;
    margin-bottom: 1em;
    overflow: visible;

    * {
        font-size: .9rem !important;
    }
    &:last-child {
        margin-bottom: 0;
    }
    &._user {
        color: white;
        background: var(--sc-color);
        justify-self: flex-end;
        margin-left: 1.4em;
    }
    &._bot {
        justify-self: flex-start;
    }
}

.ai-support-avatar {
    display: flex;
    width: 28px;
    height: 28px;
    margin-top: 2px;
    border-radius: 30px;
    border: 1px solid #ccc;
    color: white;
    background: var(--sc-color);
    font-size: .8rem;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: all 600ms;

    &._error {
        rotate: 180deg;
    }
}

.ai-support-message  {
    position: relative;
    padding-top: 1.4em;
    margin-top: .4em;
    margin-bottom: 2em;

    .ai-support-avatar {
        position: absolute;
        top: -14px;
    }
    &._user .ai-support-avatar {
        right: 6px;
    }
    &._bot .ai-support-avatar {
        left: 10px;
    }
}

.ai-support-prompt {
    textarea {
        border: none;
        outline: none;
        max-height: 400px;

        &:disabled {
            opacity: .4;
        }
    }
}

.ai-support-send {
    opacity: .4;
}

.ai-support-prompt-root {
    transition: all 240ms;
    outline: 1px solid transparent;

    &:has(textarea:focus), &:has(textarea:not(:placeholder-shown)) {
        border-color: #ccc;
        outline: 1px solid var(--sc-color);
    }

    &:has(textarea:not(:placeholder-shown)) .ai-support-send {
        opacity: .8;
        cursor: pointer;
    }
}

.ai-support-header {
    position: relative;

    &:after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        height: 20px;
        bottom: -20px;
        z-index: 1;
        background: #ffffff;
        background: linear-gradient(0deg,rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .44) 100%);
        pointer-events: none;
    }
}

.ai-support-content {
    ul, ol {
        padding: .2em 0 1em 1.4em;
        margin: 0;
    }

    li {
        padding: 0;
        margin: 0;
    }

    table {
        --color: var(--sc-color);
        border-left: 1px solid var(--color);
        border-top: 1px solid var(--color);
        margin-top: 1.4em;
        margin-bottom: 1.4em;
        width: 100%;
        border-radius: 4px;

        td {
            border-right: 1px solid var(--color);
            border-bottom: 1px solid var(--color);
            padding: .5em;
        }

        th {
            background-color: var(--color);
            color: white;
            padding: .5em;
        }
    }
}

.ai-support-message-like {
    font-size: 1rem;
}

.ai-support-attachment {
    border: 1px solid var(--sc-color-light);
    border-radius: 6px;
}

.ai-support-attachment-label {
    &, & > * {
        font-size: .8rem !important;
    }
}
.ai-support-attachment-page {
    &, & > * {
        font-size: .8rem !important;
    }
    display: inline-block;
    border-radius: 16px;
    border: 1px solid var(--sc-color);
    padding: 0 .6em;
    opacity: .7;
    transition: all 120ms ease;

    &:hover {
        opacity: 1;
    }
}

/* app-context-menu-dots */
.app-context-menu-dots {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid transparent;
    border-radius: 50%;
    opacity: .5;
    transition: all 120ms ease;
    cursor: pointer;

    &:hover, &._open {
        border-color: #cccccc88;
        opacity: 1;
    }

    > .position-absolute {
        top: -2px;
        background: white;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, .1);
        border-radius: 4px;
        z-index: 1;
        border: 1px solid #ccc;

        li {
            padding: .5em 1em;
            cursor: pointer;
            transition: all 120ms ease;

            &:hover {
                background: #f5f5f5;
                color: black;
            }
        }
    }
}

/* app-loader- */
.app-loader-dots {
    --_g: no-repeat radial-gradient(farthest-side,#999 90%,#0000);
    height: 30px;
    aspect-ratio: 2.5;
    position: relative;
    background: var(--_g), var(--_g), var(--_g), var(--_g);
    background-size: 20% 50%;
    animation: ai-support-loading 1s infinite linear;
    opacity: .9;

    &._ai-thinking {
        --_g: no-repeat radial-gradient(farthest-side,#a53c6e 90%,#0000);
        scale: .3;
        left: -20px;
        opacity: 1;
    }
}
@keyframes ai-support-loading {
    0%     {background-position: calc(0*100%/3) 50% ,calc(1*100%/3) 50% ,calc(2*100%/3) 50% ,calc(3*100%/3) 50% }
    16.67% {background-position: calc(0*100%/3) 0   ,calc(1*100%/3) 50% ,calc(2*100%/3) 50% ,calc(3*100%/3) 50% }
    33.33% {background-position: calc(0*100%/3) 100%,calc(1*100%/3) 0   ,calc(2*100%/3) 50% ,calc(3*100%/3) 50% }
    50%    {background-position: calc(0*100%/3) 50% ,calc(1*100%/3) 100%,calc(2*100%/3) 0   ,calc(3*100%/3) 50% }
    66.67% {background-position: calc(0*100%/3) 50% ,calc(1*100%/3) 50% ,calc(2*100%/3) 100%,calc(3*100%/3) 0   }
    83.33% {background-position: calc(0*100%/3) 50% ,calc(1*100%/3) 50% ,calc(2*100%/3) 50% ,calc(3*100%/3) 100%}
    100%   {background-position: calc(0*100%/3) 50% ,calc(1*100%/3) 50% ,calc(2*100%/3) 50% ,calc(3*100%/3) 50% }
}

.app-loader-spinner {
    width: 32px;
    height: 32px;
    border: 4px solid #66666699;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* app-editable */
.app-editable:has(> [contenteditable="plaintext-only"]) {
    position: relative;
    display: inline-block;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: .2em 34px .2em .4em;
    transition: all 120ms ease;
    background: #efefef;

    .app-editable-action {
        display: block;
    }

    [contenteditable="plaintext-only"] {
        outline: none;
        border: none;
        display: block;
        width: 100%;
    }

    &:has(> :focus) {
        border-color: var(--sc-color);
    }
}

.app-editable-action {
    display: none;
    position: absolute;
    bottom: 4px;
    cursor: pointer;
    right: 8px;
    rotate: 30deg;
    opacity: .5;
    transition: opacity 120ms ease;

    &:hover {
        opacity: 1;
    }
}

/** app-collapse */
.app-collapse {
    .app-collapse-icon {
        display: block;
        transform: rotate(90deg);
        transition: all 200ms ease;
    }
    &._collapsed {
        .app-collapse-body {
            height: 0;
            visibility: hidden;
        }

        & .app-collapse-icon {
            transform: rotate(0deg);
        }
    }
}

.app-collapse-body {
    height: auto;
    visibility: visible;
    interpolate-size: allow-keywords;
    transition: height 200ms ease;
    overflow: hidden;
}

/** app-article-media */
.app-article-media {
    ul, li {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    li li {
        padding-left: 25px;
    }
    li {
        border-bottom: 1px dotted #eaeaea;

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

.app-article-media-label {
    background-color: #f3f3f300;
    transition: background-color 80ms ease;

    &:hover {
        background-color: #f3f3f3ff;
    }
}

/** app-tour */

.app-tour {
    .driver-popover-title {
        padding-bottom: 8px;
    }
    .driver-popover-description {
        font-size: 1rem;
    }
    .driver-popover-navigation-btns {
        button {
            font-size: .8rem;
            background-color: var(--sc-color);
            color: white;
            border-radius: 18px;
            padding: 6px 15px;
            text-shadow: none;
            border: none;
        }
    }
    .driver-popover-footer {
        margin-top: 22px;
    }
}

.driver-fade .driver-overlay {
    animation: animate-fade-in .4s ease-in-out;
}
