@import "colors-dark.less";
@import "colors-light.less";

@login-height: 53px;
@max-logins-height: @login-height * 7;
@login-part-padding: 6px;
@login-part-height: @login-height - 2 * @login-part-padding;

@font-face {
    font-family: "Open Sans";
    font-style: normal;
    font-weight: 400;
    src: local("Open Sans"), url("/fonts/OpenSans-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Open Sans";
    font-style: normal;
    font-weight: 300;
    src: local("Open Sans Light"), url("/fonts/OpenSans-Light.ttf") format("truetype");
}

@font-face {
    font-family: "Source Code Pro";
    font-style: normal;
    font-weight: 400;
    src: local("Source Code Pro"), url("/fonts/SourceCodePro-Regular.ttf") format("truetype");
}

html,
body {
    font-family: "Open Sans";
    font-size: 14px;
    margin: 0;
    padding: 0;
    min-width: 260px;
    overflow-x: hidden;
    white-space: nowrap;
}

html.attached,
body.attached {
    width: min-content;
}

@media (min-resolution: 192dpi) {
    html,
    body {
        font-weight: 300;
    }
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

body {
    display: flex;
    flex-direction: column;
}

.logins {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: inherit;
    max-height: @max-logins-height;
}

.badge {
    display: flex;
    align-items: center;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 8px;
    padding: 1px 4px;
}

.details .header {
    display: flex;
    margin-bottom: 4px;
}

.part {
    box-sizing: border-box;
    display: flex;
    flex-shrink: 0;
    width: 100%;
}

.part:last-child {
    border-bottom: none;
}

.part > .badge:first-child {
    margin-left: 0;
}

.part.error {
    white-space: normal;
    padding: 7px;
}

.part.notice {
    white-space: normal;
    padding: 7px;
}

.part.details {
    flex-direction: column;
    padding: 5px 10px 10px;
    & > .part {
        display: flex;
        margin-bottom: 11px;
        &:last-child {
            margin-bottom: 0;
        }
        &.snack {
            border: 1px solid;
            border-radius: 2px;
            height: 36px;
            padding: 4px;
            .char {
                white-space: pre;
            }
            & > .label {
                border-radius: 2px 0 0 2px;
                cursor: default;
                display: flex;
                flex-grow: 0;
                font-weight: bold;
                justify-content: flex-end;
                margin: -5px 8px -5px -5px;
                padding: 4px 8px 4px 4px;
                width: 3.25em;
            }
            & > :not(.label) {
                display: flex;
                align-items: center;
                font-family: Source Code Pro, monospace;
            }
            & > .copy,
            & > .generate {
                cursor: pointer;
                flex-grow: 0;
                padding: 0 24px 0 0;
                background-position: top 4px right 4px;
                background-repeat: no-repeat;
                background-size: 16px;
                margin: 2px;
            }

            & > .copy {
                background-image: url("/popup/icon-copy.svg");
            }

            & > .generate {
                background-image: url("/popup/icon-generate.svg");
            }

            & > .progress-container {
                z-index: 2;
                position: absolute;
                margin: 30px 0 -4px calc(3.25em + 7px);
                height: 1px;
                width: calc(100% - 6.5em + 12px);
                & > .progress {
                    height: 100%;
                    margin: 0;
                }
            }
        }
        &.raw textarea {
            border: 1px solid;
            border-radius: 2px;
            flex-grow: 1;
            font-family: Source Code Pro, monospace;
            min-height: 110px;
            min-width: 340px;
            outline: none;
            padding: 10px;
            white-space: pre;
        }
        & > * {
            flex-grow: 1;
            align-items: center;
        }
    }
}

.part.search {
    padding: 6px 28px 6px 6px;
    background-image: url("/popup/icon-search.svg");
    background-position: top 6px right 6px;
    background-repeat: no-repeat;
    background-size: 18px;
}

.part.search > .hint {
    line-height: 19px;
}

.part.search > .hint > .remove-hint {
    background-image: url("/popup/icon-bs-delete.svg");
    background-repeat: no-repeat;
    background-size: contain;
    cursor: pointer;
    height: 12px;
    margin: 3px 0 3px 4px;
    width: 16px;
}

.part.search > input[type="text"] {
    border: none;
    outline: none;
    width: 100%;
    font-family: "Open Sans";
}

.part.search > input[type="text"]::placeholder {
    opacity: 1;
}

.part.login > .name:hover,
.part.login > .name:focus,
.part.login > .action:hover,
.part.login > .action:focus,
.part.login:focus > .name {
    outline: none;
}

.part.login {
    display: flex;
    align-items: center;
    height: @login-height;

    &.details-header {
        height: calc(@login-height + 6px);
        padding: 0 4px;
        outline: none;
    }

    &:not(.details-header) {
        cursor: pointer;
    }

    &:hover,
    &:focus {
        outline: none;
    }

    .name {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: @login-part-height;
        padding: @login-part-padding;

        .line1 {
            display: flex;
            flex-direction: row;
            font-size: 12px;

            .recent {
                background-image: url("/popup/icon-history.svg");
                background-repeat: no-repeat;
                background-size: contain;
                margin-left: 8px;
                width: 9.5px;
                margin-top: 4px;
            }
        }

        .line2 {
            font-size: 18px;
            margin-top: 2px;
        }
    }

    .action {
        background-position: center;
        background-repeat: no-repeat;
        background-size: 19px;
        cursor: pointer;
        width: 30px;
        height: @login-part-height;
        padding: @login-part-padding;

        &.back {
            background-image: url("/popup/icon-back.svg");
        }

        &.copy-password {
            background-image: url("/popup/icon-key.svg");
        }

        &.copy-user {
            background-image: url("/popup/icon-user.svg");
        }

        &.details {
            background-image: url("/popup/icon-details.svg");
        }

        &.edit {
            background-image: url("/popup/icon-edit.svg");
        }

        &.save {
            background-image: url("/popup/icon-save.svg");
        }

        &.delete {
            background-image: url("/popup/icon-delete.svg");
        }
    }
}

.part.login em {
    font-style: normal;
}

.part.add {
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    height: 30px;
}

.chars {
    display: flex;
    flex-grow: 1;
    align-items: center;
    font-family: Source Code Pro, monospace;
    .char {
        white-space: pre;
    }
}

.addEdit,
.details {
    .loading {
        width: 300px;
        height: 300px;
        display: flex;
        align-items: flex-end;
        p {
            margin: 50px auto;
            font-size: large;
        }
    }

    .title {
        display: flex;
        box-sizing: border-box;
        // justify-content: space-between;

        span {
            // align-self: center;
            margin: auto;
        }
    }

    .btn {
        cursor: pointer;
        background-position: center;
        background-repeat: no-repeat;
        padding: 6px;
        background-size: 19px;
        height: 21px;

        &:hover,
        &:focus {
            outline: none;
        }

        &.back {
            background-image: url("/popup/icon-back.svg");
            width: 20px;
        }

        &.edit {
            background-image: url("/popup/icon-edit.svg");
            width: 25px;
        }

        &.alignment {
            width: 20px;
            cursor: default;
            background: none !important;
        }

        &.generate {
            width: 15px;
            padding-right: 10px;
            background-image: url("/popup/icon-generate.svg");
        }
    }

    .location {
        margin: 6px;

        .store,
        .path {
            display: flex;
            align-items: center;
            margin-bottom: 6px;
            padding-right: 5px;
        }

        .store {
            select {
                border-radius: 4px;
            }
        }

        .storePath {
            margin-left: 10px;
            font-size: 12px;
        }

        .path {
            border: 1px solid;

            input {
                padding-right: 0;
            }
        }

        .suffix {
            font-size: 13px;
            font-family: Source Code Pro, monospace;
        }

        select {
            border: none;
            outline: none;
            padding: 5px;
            cursor: pointer;
        }

        input[disabled],
        select[disabled],
        .suffix.disabled {
            color: grey;
            cursor: default;
        }
    }

    .contents {
        display: flex;
        flex-direction: column;
        margin: 0 6px 5px;

        label {
            display: flex;
            flex-grow: 0;
            justify-content: flex-end;
            font-weight: bold;
            padding: 6px 6px;
            margin-right: 8px;
            border: none;
            min-width: 55px;
        }

        .password,
        .options,
        .details {
            display: flex;
            margin-bottom: 6px;
            border-radius: 2px;
        }

        .password,
        .details {
            border: 1px solid;
        }

        .options {
            align-items: center;

            label {
                margin-right: 0;
            }

            input[type="checkbox"] {
                margin: 3px 6px;
                height: 25px;
                width: 20px;
            }

            input[type="number"] {
                font-size: 12px;
                width: 40px;
                height: 20px;
            }
        }
    }

    .actions {
        display: flex;
        margin-bottom: 10px;

        .save,
        .delete {
            cursor: pointer;
            font-weight: bolder;
            font-size: medium;
            padding: 0.25rem 0.75rem;
            border-radius: 0.25rem;
        }

        .save::after,
        .delete::after {
            display: inline-block;
            width: 15px;
            margin-left: 5px;
        }

        .save {
            margin-left: auto;
            margin-right: 5px;
        }
        .save::after {
            content: url("/popup/icon-save.svg");
        }

        .delete {
            margin-left: 5px;
            margin-right: auto;
        }
        .delete::after {
            content: url("/popup/icon-delete.svg");
        }
    }

    input[type="number"],
    input[type="text"],
    textarea {
        border: none;
        outline: none;
        width: 100%;
        font-family: "Open Sans";
        padding: 5px 8px;
        font-family: Source Code Pro, monospace;
    }

    textarea {
        resize: none;
        min-height: 110px;
        min-width: 340px;
    }
}

.updates {
    padding: @login-part-padding;
}

.m-notifications {
    position: fixed;
    top: 20px;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 10;

    .m-notification {
        width: auto;
        margin: 0 10px 3px;
        cursor: pointer;
        animation: fade-in 0.3s;
        white-space: normal;
        // display errors in notifications nicely
        overflow-wrap: anywhere;

        &.destroy {
            animation: fade-out 0.3s;
        }

        &.info,
        &.warning,
        &.error,
        &.success {
            padding: 0.75rem 1.25rem;
            border-radius: 0.25rem;
        }
    }
}

div#tree-dirs {
    position: absolute;
    overflow-y: scroll;
    max-height: 265px;
    margin-top: -8px;

    div.dropdown {
        padding: 2px;

        a {
            display: block;
            text-align: left;
            padding: 2px 6px;
        }
    }
}

dialog#browserpass-modal {
    margin: auto 6px;
    width: auto;
    border-radius: 0.25rem;

    .modal-content {
        margin-bottom: 15px;
        white-space: pre-wrap;

        p {
            margin: 0;
        }
    }

    .modal-actions {
        display: flex;

        button {
            font-weight: bold;
            padding: 5px 10px;
            border-radius: 0.25rem;

            &.cancel {
                margin-right: auto;
            }
            &.confirm {
                margin-left: auto;
            }
        }
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.generate-heights(@start, @end, @i: 0, @step: 25) when ((@start + @i * @step) =< @end) {
    .mh-@{i} {
        min-height: (1px * @start) + (1px * @i * @step);
    }
    .generate-heights(@start, @end, (@i + 1));
}
.generate-heights(300, 1000);
