@import "/customize/src/less/variables.less";
@import "/customize/src/less/mixins.less";

@poll-th-bg: #aaa;
@poll-th-user-bg: #999;
@poll-td-bg: #aaa;
@poll-editing: #88b8cc;
@poll-placeholder: #666;
@poll-border-color: #555;
@poll-cover-color: #000;
@poll-fg: #000;
@poll-option-yellow: #ff5;
@poll-option-gray: #ccc;

html, body {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
    border: 0px;
}
body {
    display: flex;
    flex-flow: column;
    overflow-x: hidden;
}
#content {
    display: flex;
    flex: 1;
    #poll {
        flex: 1;
        overflow-y: auto;
    }
}

.cryptpad-toolbar h2 {
    font: normal normal normal 12px Arial, Helvetica, Tahoma, Verdana, Sans-Serif;
    color: #000;
    line-height: auto;
}
.cryptpad-toolbar {
    display: inline-block;
}
.realtime {
    display: block;
    max-height: 100%;
    max-width: 100%;
}

.realtime input[type="text"] {
    height: 1em;
    margin: 0px;
}
.text-cell input[type="text"] {
    width: 400px;
}

input[type="text"], textarea {
    background-color: white;
    color: black;
    border: 0;
}

input[type="text"][disabled], textarea[disabled] {
    background-color: transparent;
    border: 0px;
}

// The placeholder color only seems to effect Safari when not set

input[type="text"]::placeholder {
    color: @poll-placeholder;
}

table#table {
    margin: 0px;
}
#tableContainer {
    position: relative;
    padding: 29px;
    padding-right: 79px;
}
#tableContainer button {
    height: 2rem;
    display: none;
}
#publish {
    display: none;
}
#publish, #admin {
    margin-top: 15px;
    margin-bottom: 15px;
}
#create-user {
    position: absolute;
    display: inline-block;
    /*left: 0px;*/
    top: 55px;
    width: 50px;
    overflow: hidden;
}
#create-option {
    width: 50px;
}
#tableScroll {
    overflow-y: hidden;
    overflow-x: auto;
    margin-left: calc(~"30% - 50px + 31px");
    max-width: 70%;
    width: auto;
    display: inline-block;
}
#description {
    padding: 15px;
    margin: auto;

    min-width: 80%;
    width: 80%;
    min-height: 7em;
    font-size: 20px;
    font-weight: bold;
    border: 1px solid black;

}
#description[disabled] {
    resize: none;
    color: #000;
    border: 1px solid #444;
}

#commit {
    width: 100%;
}
#howItWorks {
    width: 80%;
    margin: auto;
}
div.upper {
    width: 80%;
    margin: auto;

    & > * {
        margin-right: 1em;
    }
}

// from cryptpad.less

table {
    border-collapse: collapse;
    border-spacing: 0;
    margin: 20px;
}
tbody {
    border: 1px solid @poll-border-color;
    * {
        box-sizing: border-box;
    }
    tr {
        text-align: center;
        &:first-of-type th{
            font-size: 20px;
            border-top: 0px;
            font-weight: bold;
            padding: 10px;
            text-decoration: underline;
            &.table-refresh {
                color: @cp-green;
                text-decoration: none;
                cursor: pointer;
            }

        }
        &:nth-child(odd) {
            background-color: @light-base;
        }
        th:first-of-type {
            border-left: 0px;
        }
        th {
            box-sizing: border-box;
            border: 1px solid @poll-border-color;
        }
        th, td {
            color: @fore;

            &.remove {
                cursor: pointer;
            }
        }
        th:last-child {
            border-right: 0px;
        }
    }

    td {
        border-right: 1px solid @poll-border-color;
        padding: 12px;
        padding-top: 0px;
        padding-bottom: 0px;
        &:last-child {
            border-right: none;
        }
    }
}

form.realtime, div.realtime {
    > input {
        &[type="text"] {

        }
    }
    > textarea {
        width: 50%;
        height: 15vh;
    }

    padding: 0px;
    margin: 0px;

    table {
        border-collapse: collapse;
        width: ~"calc(100% - 1px)";
        .editing {
            background-color: @poll-editing;
        }
        tr {
            td:first-child {
                position:absolute;
                left: 29px;
                top: auto;
                width: ~"calc(30% - 50px)";
            }
            td {
                padding: 0px;
                margin: 0px;

                div.text-cell {
                    padding: 0px;
                    margin: 0px;
                    height: 100%;

                    input {
                        width: 80%;
                        width: 90%;
                        height: 100%;
                        border: 0px;
                        &[disabled] {
                            background-color: transparent;
                            color: @poll-fg;
                            font-weight: bold;
                        }
                    }
                }

                &.checkbox-cell {
                    margin: 0px;
                    padding: 0px;
                    height: 100%;
                    min-width: 150px;

                    div.checkbox-contain {
                        display: inline-block;
                        height: 100%;
                        width: 100%;
                        position: relative;

                        label {
                            background-color: transparent;
                            display: block;
                            position: absolute;
                            top: 0px;
                            left: 0px;
                            height: 100%;
                            width: 100%;
                        }

                        input {
                            &[type="number"] {
                                &:not(.editable) {
                                    display: none;

                                    ~ .cover {
                                        display: block;
                                        font-weight: bold;

                                        color: @poll-cover-color;

                                        &:after {
                                            height: 100%;
                                        }

                                        display: block;
                                        &.yes {
                                            background-color: @cp-green;
                                        }

                                        &.uncommitted {
                                            background: #ddd;
                                        }

                                        &.mine {
                                            display: none;
                                        }
                                    }
                                }
                            }
                        }

                        input[type="number"][value="0"] {
                            ~ .cover {
                                background-color: @cp-red;
                                &:after { content: "✖"; }
                            }
                        }
                        input[type="number"][value="1"] {
                            ~ .cover {
                                background-color: @cp-green;
                                &:after { content: "✔"; }
                            }
                        }
                        input[type="number"][value="2"] {
                            ~ .cover {
                                background-color: @poll-option-yellow;
                                &:after { content: "~"; }
                            }
                        }
                        input[type="number"][value="3"] {
                            ~ .cover {
                                background-color: @poll-option-gray;
                                &:after { content: "?"; }
                            }
                        }
                    }
                }
            }
        }

        input {
            &[type="text"] {
                height: auto;
                width: 80%;
            }
        }
        span {
            user-select: none;
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
        }
        thead {
            td {
                padding: 0px 5px;
                background: @poll-th-bg;
                border-radius: 20px 20px 0 0;
                //text-align: center;
                &:nth-of-type(2) {
                    background: @poll-th-user-bg;
                    .lock {
                        cursor: default;
                    }
                }
                input {
                    &[type="text"] {
                        width: 100%;
                        box-sizing: border-box;
                        padding: 1px 5px;
                        &[disabled] {
                            color: @poll-fg;
                            border: 1px solid transparent;
                        }
                    }
                }
            }
        }

        tbody {
            td:not(.editing) {
                .text-cell {
                    background: @poll-td-bg;
                }
            }
            .text-cell {
                //border-radius: 20px 0 0 20px;
                input[type="text"] {
                    width: ~"calc(100% - 50px)";
                    padding: 0 0.5em;
                }
                .edit {
                    float:right;
                    margin: 0 10px 0 0;
                }
                .remove {
                    float: left;
                    margin: 0 0 0 10px;
                }
            }
            tr:not(:first-child) {
                td:not(:first-child) {
                    label {
                        border-top: 1px solid @poll-border-color;
                    }
                }
            }
        }
        .edit {
            color: @poll-cover-color;
            cursor: pointer;
            float: left;
            margin-left: 10px;
        }

        .lock {
            margin-left: ~"calc(50% - 0.5em)";
            cursor: pointer;
            width: 1em;
            text-align: center;
        }
        .remove {
            float: right;
            margin-right: 10px;
        }

        thead {
            tr {
                th {
                    input[type="text"][disabled] {
                        background-color: transparent;
                        color: @fore;
                        font-weight: bold;
                    }
                    .remove {
                        cursor: pointer;
                        font-size: 20px;
                    }
                }
            }
        }
        tbody {
            tr {
                td {

                }
            }
        }
        tfoot {
            tr {
                border: none;
                td {
                    border: none;
                    text-align: center;
                    .save {
                        padding: 15px;
                        border-top-left-radius: 5px;
                        border-top-right-radius: 5px;
                    }
                }
            }
        }
    }

    #adduser,
    #addoption {
        color: @cp-green;
        border: 1px solid @cp-green;
        padding: 15px;
        cursor: pointer;
    }

    #adduser { .top-left; }
    #addoption { .bottom-left; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

