@import '../../utils/colors.less';
@import '../../utils/fonts.less';
@import '../../utils/spacing.less';

#interface.theme-light {
    .daggerheart.chat-sidebar .chat-log,
    #chat-notifications .chat-log {
        --text-color: @dark-blue;
        --bg-color: @dark-blue-40;

        .chat-message {
            .roll-formula {
                background: @dark-15;
                color: @dark;
            }

            &.duality {
                background-image: url(../assets/parchments/dh-parchment-dark.png);

                .message-content {
                    color: @beige;
                }

                .roll-formula {
                    background: @dark-15;
                    color: @dark;
                }

                .message-header {
                    .message-sub-header-container {
                        color: @beige;
                        h4 {
                            color: @golden;
                        }
                    }
                    .message-header-metadata {
                        .message-metadata {
                            color: @beige;
                        }
                    }
                }

                &.hope {
                    --text-color: @golden;
                    --bg-color: @golden-40;
                    .message-header,
                    .message-content {
                        background-color: @golden-bg;
                    }
                    .roll-formula {
                        background: var(--bg-color);
                        color: var(--text-color);
                    }
                }

                &.fear {
                    --text-color: @chat-blue;
                    --bg-color: @chat-blue-40;
                    .message-header,
                    .message-content {
                        background-color: @chat-blue-bg;
                    }
                    .roll-formula {
                        background: var(--bg-color);
                        color: var(--text-color);
                    }
                }

                &.critical {
                    --text-color: @chat-purple;
                    --bg-color: @chat-purple-40;
                    .message-header,
                    .message-content {
                        background-color: @chat-purple-bg;
                    }
                    .roll-formula {
                        background: var(--bg-color);
                        color: var(--text-color);
                    }
                }
            }

            &:not(.duality) {
                .font-20 {
                    color: @dark;
                }

                .roll-die {
                    color: @beige;
                }

                fieldset {
                    color: @dark-blue;
                    border-color: @dark-blue;

                    legend {
                        color: @dark-blue;
                    }
                }
                .chat-roll {
                    .roll-part-header {
                        color: @dark-blue;

                        span::before,
                        span::after {
                            color: @dark-blue;
                        }

                        &:before {
                            background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, @dark-blue 100%);
                        }

                        &:after {
                            background: linear-gradient(90deg, @dark-blue 0%, rgba(0, 0, 0, 0) 100%);
                        }
                    }

                    .roll-part-content {
                        &.dice-result {
                            color: @dark;
                        }
                        .roll-result-container {
                            color: @dark-blue;
                        }
                    }
                }
            }
        }
    }
}

.daggerheart.chat {
    &.resource-roll {
        .reroll-message {
            color: @beige;
            text-align: center;
            font-size: var(--font-size-18);
            margin-bottom: 0;
        }
    }

    button {
        &.inner-button {
            --button-size: 1.25rem;
            --input-height: 1.25rem;
            padding: 0 0.25rem;
            margin: 5px 1px -4px auto;
            &.inner-button-right {
                margin-left: auto;
            }
        }
    }
}

.daggerheart,
#chat-notifications {
    .chat-message {
        --text-color: @golden;
        --bg-color: @golden-40;

        [data-use-perm='false'] {
            pointer-events: none;
            border-color: transparent;
        }
        [data-view-perm='false'] {
            &[data-perm-hidden='true'],
            > * {
                display: none;
            }
            &::after {
                content: '??';
            }
        }

        &.duality {
            &.hope {
                --text-color: @golden;
                --bg-color: @golden-40;
                .message-header,
                .message-content {
                    background-color: @golden-bg;
                }
            }

            &.fear {
                --text-color: @chat-blue;
                --bg-color: @chat-blue-40;
                .message-header,
                .message-content {
                    background-color: @chat-blue-bg;
                }
            }

            &.critical {
                --text-color: @chat-purple;
                --bg-color: @chat-purple-40;
                .message-header,
                .message-content {
                    background-color: @chat-purple-bg;
                }
            }
        }

        .chat-roll {
            font-size: var(--font-size-12);
            padding: 0 20px;

            > .roll-part-header {
                font-size: var(--font-size-14);
            }

            .roll-part-header {
                display: grid;
                grid-template-columns: 1fr auto 1fr;
                align-items: center;
                color: @beige;
                margin: 10px 0;

                span {
                    display: flex;
                    align-items: center;
                    gap: 5px;
                    text-transform: capitalize;
                    padding: 0 10px;
                }

                &:before,
                &:after {
                    content: ' ';
                    height: 1px;
                }

                &:before {
                    background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, var(--text-color) 100%);
                }

                &:after {
                    background: linear-gradient(90deg, var(--text-color) 0%, rgba(0, 0, 0, 0) 100%);
                }
            }

            .roll-part-extra {
                display: flex;
                justify-content: center;
                align-items: center;
                gap: 10px;
                margin-top: 8px;
            }

            .roll-part-content {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 5px;

                .dice-tooltip {
                    width: 100%;

                    .wrapper {
                        display: flex;
                        flex-direction: column;
                        gap: 10px;

                        > :first-child:not(.target-selector) {
                            margin-top: 5px;
                        }

                        > :last-child {
                            margin-bottom: 5px;
                        }

                        .roll-die {
                            position: relative;

                            .dice-rerolled {
                                position: absolute;
                                top: 0;
                                right: 0;
                                font-size: var(--font-size-10);
                                z-index: 2;
                                filter: drop-shadow(0 0 3px black);
                            }
                        }
                    }
                }

                .roll-result-container {
                    display: flex;
                    justify-content: center;
                    color: var(--text-color);
                    font-weight: 700;
                    font-family: 'Cinzel', sans-serif;
                    line-height: 0.75;

                    .roll-result-value {
                        font-size: var(--font-size-24);
                    }

                    .roll-result-desc {
                        font-size: var(--font-size-16);
                        margin-top: 2px;

                        span {
                            margin-left: 10px;
                        }
                    }
                }
            }
        }

        .roll-dice {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            font-weight: 700;
            font-family: 'Cinzel', sans-serif;
            flex-wrap: wrap;

            .roll-die {
                display: grid;
                grid-template-areas:
                    '. a a'
                    'c b b';
                gap: 3px;

                .reroll-button:hover {
                    filter: drop-shadow(0 0 3px @golden);
                }

                label {
                    text-align: center;
                    height: var(--font-size-12);
                    grid-area: a;
                }

                > div {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 5px;
                    grid-area: b;
                }

                &.has-plus:before {
                    content: '+';
                    font-size: var(--font-size-20);
                    grid-area: c;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    width: 15px;
                }
            }
        }

        fieldset {
            display: flex;
            flex-direction: column;
            border-color: var(--text-color);
            border-radius: 5px;

            legend {
                display: flex;
                align-items: center;
                gap: 10px;
                padding: 0 5px;
                color: var(--text-color);
            }
        }

        .target-selector {
            + .roll-part-extra {
                margin: 0;
            }

            .target-choice {
                display: flex;
                font-size: var(--font-size-14);
                color: var(--text-color);

                .button-target-selection {
                    flex: 1;
                    text-align: center;
                    margin: -5px 0;
                }

                .button-target-selection:hover,
                .target-selected {
                    font-weight: bold;
                    text-shadow: 0px 0px 8px var(--text-color);
                }
            }
        }

        i {
            text-align: center;
        }

        .roll-target {
            display: flex;
            width: 100%;
            gap: 10px;
            align-items: center;
            border-radius: 3px;

            &:hover {
                background-color: rgba(255, 255, 255, 0.1);
            }

            .target-img {
                border-radius: 50%;
                width: 40px;
                height: 40px;
                object-fit: cover;
            }

            .target-data {
                flex: 1;
            }

            .target-save {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 22px;
                height: 22px;
                &:hover > i {
                    scale: 1.2;
                }

                i {
                    &.fa-check {
                        color: @green;
                    }
                    &.fa-xmark {
                        color: @medium-red;
                    }
                }
            }
        }

        .roll-formula {
            background-color: var(--bg-color);
            color: var(--text-color);
            border-radius: 4px;
            padding: 3px 5px;
            width: fit-content;
            margin: auto;
            white-space: nowrap;
        }

        .roll-difficulty,
        .target-hit-status {
            color: @green;
            background-color: @green-10;
            border: 1px solid currentColor;
            border-radius: 4px;
            padding: 3px 5px;
            text-transform: uppercase;
            font-weight: 600;

            &.is-miss {
                color: @medium-red;
                background-color: @medium-red-10;
            }
        }

        .target-hit-status {
            width: fit-content;
            margin-top: 2px;
        }

        div[data-action='expandRoll'] {
            .roll-part-header > div > span {
                &:before,
                &:after {
                    content: '\f078';
                    font-family: var(--font-awesome);
                    color: var(--text-color);
                    transition: all 0.3s ease;
                }
            }

            .on-reduced {
                display: grid;
                overflow: hidden;
                grid-template-rows: 1fr;
                transition: grid-template-rows 250ms ease;
                margin: 0;

                .wrapper {
                    display: flex;
                    gap: 10px;
                    overflow: hidden;
                }
            }

            &.expanded {
                .roll-part-header > div > span {
                    &:before,
                    &:after {
                        transform: rotate(180deg);
                    }
                }

                .on-reduced {
                    grid-template-rows: 0fr;
                }
            }
        }

        .roll-part + .roll-part {
            margin-top: 0;
        }

        .damage-section[data-action='expandRoll'] {
            .on-reduced {
                .wrapper {
                    flex-wrap: wrap;
                    gap: 10px 5px;
                }

                .roll-formula {
                    font-size: var(--font-size-16);
                }
            }
        }

        .target-section {
            .roll-part-content {
                gap: 10px;
            }

            .roll-part-extra {
                position: relative;

                .target-pending-saves {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    height: 25px;
                    width: 25px;
                    &:not(:first-child) {
                        position: absolute;
                        bottom: 0;
                        right: 0;
                    }
                }
            }
        }

        .roll-buttons {
            display: flex;
            gap: 5px;
            margin-top: 8px;
            button {
                height: 32px;
                flex: 1;
            }
        }

        .font-20 {
            font-size: var(--font-size-20);
        }

        .dice-roll .dice-tooltip fieldset {
            margin-bottom: 5px;
        }
    }
}
