// Use this file only for editor styles
// (changes to the renderer will not work in production)
//

// Variables
// Should be consistent with webapp's variables.less

// Colors
@grayDarker:            #333;
@gray:                  #999;
@grayExtraLight:        #eee;
@grayLighter:           #ddd;
@white:                 #fff;

// Editor Style
@editorBorderWidth:     1px;
@editorBorder:          @editorBorderWidth solid @grayLighter;
@editorBorderRadius:    3px;
@editorPadding:         10px;

@widgetBorderWidth:     1px;
@widgetBorderColor:     #ccc;
@widgetBorder:          @widgetBorderWidth solid @widgetBorderColor;
@widgetBorderRadius:    3px;

// Dimensions
@questionWidth:         480px;
@leftCellWidth:         360px;
@cellPadding:           30px;
@rightCellWidth:        @questionWidth + 2 * @cellPadding;

// Colors
@wrongRed:              #f2dede;
@correctGreen:          #dff0d8;
@ungradedBlue:          #d9edf7;

.border-box-sizing() {
    -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
            box-sizing: border-box;

}

.size(@width: auto, @height: auto) {
    height: @height;
    width: @width;
}

.position(@position: static, @top: auto, @right: auto, @bottom: auto, @left: auto) {
    position: @position;
    top: @top;
    right: @right;
    bottom: @bottom;
    left: @left;
}

.user-select (@select) {
  -webkit-user-select: @select;
  -khtml-user-drag: @select;
  -khtml-user-select: @select;
  -moz-user-select: @select;
  -ms-user-select: @select;
  user-select: @select;
}

.pod-title {
    background-color: @grayExtraLight;
    border: 1px solid @grayLighter;
    border-bottom: 0;
    font-size: 1.25em;
    padding: 4px 10px;
    border-radius: @editorBorderRadius @editorBorderRadius 0 0;
    &.closed {
        border-radius: @editorBorderRadius;
    }
}

.smiley {
    position: absolute;
    left: 0px;
    top: 4px;
}

//
// General editor styles
//

.perseus-single-editor {
    box-sizing: border-box;
    width: 100%;
}

.perseus-json-editor {
    width: 100%;
    font-family: monospace;
    height: 500px;
}

.perseus-json-editor.invalid {
    background-color: #ffe6e6;
}

.perseus-textarea-pair {
    border: 1px solid @grayLighter;
    font-size: 12px;
    line-height: 1.6;
    position: relative;
}

.perseus-textarea-pair > .perseus-textarea-underlay {
    color: transparent;
    margin-bottom: 12px;
    padding: @editorPadding;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.perseus-textarea-pair > .perseus-textarea-underlay b {
    font-weight: normal;
    background-color: #dfd;
}

.perseus-textarea-pair > .perseus-textarea-underlay b.selected {
    background-color: #ddf;
}

.perseus-textarea-pair > .perseus-textarea-underlay b.error {
    background-color: #fcc;
}

.perseus-textarea-pair > textarea {
    background: transparent;
    border: 0;
    -moz-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
    font: inherit;
    height: 100%;
    left: 0;
    padding: @editorPadding;
    position: absolute;
    resize: none;
    top: 0;
    width: 100%;

    /* for Firefox, this helps. it seems that the underlay is still 1px off and
    I'm not really sure why. not too noticeable if we're just setting the
    background color though. */
    margin: 0;
}

.perseus-widget-row {
    margin: 7px 0;
    width: 100%;

    .perseus-widget-left-col,
    .perseus-widget-right-col {
        display: inline-block;
        width: 50%;

        .range-input {
            float: right;
            margin-right: 5px;
        }
    }
    > .range-input {
        margin-left: 10px;
    }
}

.perseus-answer-editor {
    .perseus-textarea-pair {
        min-height: 50px;
    }
}

.perseus-answer-options {
    border: @editorBorder;
    border-bottom: 0;
    padding: @editorPadding;
}

.perseus-answer-widget {
    border: @editorBorder;
    border-radius: 0 0 @editorBorderRadius @editorBorderRadius;
    padding: @editorPadding;
}

.perseus-answer-none {
    & > div {
        display: none;
    }

    border-bottom: @editorBorder;
}

.perseus-widget-editor {
    border: @editorBorder;
    border-radius: @editorBorderRadius;
    margin-top: 10px;

    .perseus-widget-editor-title {
        .pod-title;
        border: 0;
        display: block;
        position: relative;

        > a {
            color: inherit;
            text-decoration: none;

            > i {
                float: left;
                font-size: 14px;
                margin-right: 10px;
            }
        }

        .remove-widget {
            position: absolute;
            right: 5px;
        }

        .simple-button {
            font-size: 13px;
            padding: 0 10px;
        }
    }

    .perseus-widget-editor-content {
        border-radius: 0 0 @editorBorderRadius @editorBorderRadius;
        border-top: @editorBorder;
        padding: @editorPadding;
        transition: all 0s;

        &.enter {}
        &.leave {
            display: none;
        }
    }

    // Are any widgets capable of overflowing in the editor interface?
    .categorizer-container {
        overflow-x: scroll;
    }

}

.perseus-editor-widgets-selectors {
    background-color: @grayExtraLight;
    border: 1px solid @grayLighter;
    border-top: 0;
    border-radius: 0 0 @editorBorderRadius @editorBorderRadius;
    padding: @editorPadding/2;

    select {
        margin: 2px;
    }
}

.perseus-editor-widgets > div.selected > strong {
    background-color: #ddf;
}

.perseus-editor-widgets .warning {
    background-color: #ffcccc;
    padding: 4px;
    margin: 4px;
}
//
// Misc styles
//

.MathJax .math {
    // override athena silliness
    color: inherit;
}

//
// DOM-based styles that overwrite rules set in khan-exercise.css
//

#perseus {
    margin: 20px;

    // Question area styles
    #problemarea {
        /* Override the min-height property used for displaying the problem.
        While editing, the size of the editor itself is a better constraint on
        the size of the problemarea, and having a smaller problemarea is nicer
        if it means it aligns better with the editor. */
        min-height: 0;

        // Force the question width to make too-wide items visually overflow,
        // to indicate that there is a problem to content creators
        width: @questionWidth;

        #workarea {
            margin: 0; // override ke
            outline: 1px solid #ccc;
        }
    }

    // Answer area styles
    #answer_area {
        position: relative;

        #solutionarea, .answer-buttons {
            border: 0; // override ke
            box-sizing: border-box;
            margin: 0; // override ke
            width: 225px;
        }

        #solutionarea {
            margin-left: 0; // override ke
            margin-top: 20px;
            outline: 1px solid #ccc;
            // Make too-wide items visually overflow, to indicate
            // that there is a problem to content creators
            overflow-x: visible;
        }
    }

    // Space out the question, answer, and hint areas
    .perseus-question-container > div, .perseus-answer-container > div {
        padding-bottom: 25px;
    }

    // Add radio choice/hint button styles
    .add-choice-container,
    .add-hint-container {
        margin-bottom: 20px;
        text-align: left;
    }
}

//
// Table styles for Editor/Renderer pairs
//

.perseus-editor-table {
    display: table;
    table-layout: fixed;
}

.perseus-editor-row {
    display: table-row;
}

.perseus-editor-left-cell {
    display: table-cell;
    padding-right: 30px;
    vertical-align: top;
    width: @leftCellWidth;
    max-width: @leftCellWidth;
    min-width: @leftCellWidth;
}

.perseus-editor-right-cell {
    background-color: #f7f7f7;
    .border-box-sizing();
    display: table-cell;
    padding: @cellPadding;
    vertical-align: top;
    width: @rightCellWidth;
}

//
// Hint Editor
//


.perseus-hint-editor {
    padding-bottom: 20px;

    .perseus-single-editor {
        margin-bottom: 5px;
    }

    .reorder-hints button {
        font-size: 16px;

        &:hover, &:active {
            color: #000;
            text-decoration: none;
        }

        &.hidden {
            visibility: hidden;
        }
    }

    .remove-hint {
        float: right;
        font-size: 13px;
        padding: 0 10px;
    }
}

.perseus-hints-editor .add-hint {
    font-size: 13px;
}

// Only apply borders to hints if they immediately follow a hint-editor
.perseus-hint-editor + div .perseus-hint-renderer {
    div.paragraph {
        margin: 0px 0px 22px 0px;
    }
    outline: 1px solid #ccc;

    // Force the hint width to make too-wide items visually overflow,
    // to indicate that there is a problem to content creators
    width: @questionWidth;
}

// Article Editor
.perseus-article {
    .perseus-single-editor {
        margin-bottom: 10px;
    }

    .section-control-button, .step-control-button {
        font-size: 13px;
        padding: 2px 10px;
        margin: 0 2px;
    }

    .perseus-editor-left-cell {
        min-width: 360px;
    }

    .perseus-editor-right-cell > div {
        width: 640px;
    }
}

//
// Button Group
//

.perseus-button-group {
    display: inline-block;

    & > button {
        background-color: white;
        border: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
        border-left: 0;
        cursor: pointer;
        margin: 0;
        padding: 5px 10px;
        position: relative; // for hover

        &.selected {
            background-color: #ddd;
        }

        &:first-child {
            border-left: 1px solid #ccc;
            border-top-left-radius: 3px;
            border-bottom-left-radius: 3px;
        }

        &:last-child {
            border-right: 1px solid #ccc;
            border-top-right-radius: 3px;
            border-bottom-right-radius: 3px;
        }

        &:hover, &:focus {
            outline: 2px solid #999;
            outline-offset: -1px;
            z-index: 2;
        }
    }
}

//
// More Options
//
.more-options-container {
    display: block;
    padding-bottom: 24px;
    position: relative;

    .more-options-title {
        border-radius: 0 0 @editorBorderRadius @editorBorderRadius;
        color: @gray;
        height: 20px;
        font-size: 14px;
        padding: 5px 0;
        width: @leftCellWidth - 2 * @editorBorderWidth;

        position: absolute;
        left: -1 * @editorPadding;
        right: 0;
        bottom: -1 * @editorPadding;

        text-align: center;

        &:hover {
            background-color: @grayLighter;
            cursor: pointer;
        }
    }
}

//
// Expression editor
//
.perseus-widget-expression-editor {
    .answer-options-list li {
        margin: 5px 0;
    }

    .answer-status {
        color: inherit;
        cursor: pointer;
        display: inline-block;
        text-align: center;
        text-decoration: none;
        width: 75%; // TODO(joel) 60%?
        .user-select(none);

        &.wrong {
            background-color: @wrongRed;
        }

        &.correct {
            background-color: @correctGreen;
        }

        &.ungraded {
            background-color: @ungradedBlue;
        }
    }

    .expression-editor-h3 {
        margin: 10px 0 4px;
    }
}


//
// Dropdown editor
//
.perseus-widget-dropdown .remove-choice {
    margin-bottom:10px;
}
//
// Input Number / Text Input
//
.perseus-input-number-editor {
    font-size: 14px;

    .ui-title, .msg-title {
        display: inline-block;
        text-align: center;
    }

    .ui-title {
        width: 100px;
    }

    .msg-title {
        margin-left: 5px;
        width: 230px;
    }

    .options-container {
        padding-left: 30px;
    }

    .input-answer-editor-value,
    .input-answer-editor-message {
        display: inline-block;
    }

    .input-answer-editor-value-container {
        border: @widgetBorder;
        border-radius: @widgetBorderRadius;
        float: left;
        .size(100px, 53px);
        overflow: hidden;
        position: relative;

        .numeric-input-value {
            border: 0;
            font-size: 13px;
            outline-offset: -3px;
            width: 100%;
        }

        &.with-max-error {
            .numeric-input-value {
                width: 60%;
            }
        }

        .max-error-container {
            display: inline-block;
            width: 40%;
            .max-error-plusmn {
                cursor: default;
                display: inline-block;
                width: 20%;
            }
            .number-input {
                border: 0;
                font-size: 13px;
                width: 80%;
            }
        }
    }

    .options-toggle,
    .answer-trash,
    .answer-status {
        height: 26px;
        line-height: 26px;
        outline-offset: -3px;
        vertical-align: middle;
    }

    .value-divider {
        border-top: @widgetBorder;
    }

    .options-toggle,
    .answer-trash {
        border-left: @widgetBorder;
        .border-box-sizing();
        cursor: pointer;
        display: inline-block;
        text-align: center;
        text-decoration: none;
        width: 20%;
    }

    .options-toggle {
        background-color: #eee;
        color: #444;
        &:hover {
            background-color: #ccc;
        }
    }

    .answer-trash {
        background-color: #C04F03;
        background-image: linear-gradient(to bottom, #E35D04, #C04F03);
        color: #FFF;
        &:hover {
            color: #FFF;
            background-image: linear-gradient(to bottom, #F46E15, #D16014);
        }
    }

    .is-strict-indicator {
        background-color: @ungradedBlue;
        border-bottom: @widgetBorder;
        border-right: @widgetBorder;
        cursor: default;
        font-size: 16px;
        line-height: 12px;
        .size(12px, 12px);
        text-align: center;
        .position(absolute, 0, auto, auto, 0);
        .user-select(none);
    }

    .simplify-indicator {
        border-top: @widgetBorder;
        border-right: @widgetBorder;
        cursor: default;
        font-size: 10px;
        line-height: 13px;
        .size(12px, 13px);
        text-align: center;
        .position(absolute, 12px, auto, auto, 0);
        .user-select(none);

        &.optional {
            background-color: @correctGreen;
        }
        &.enforced {
             background-color: @wrongRed;
        }
    }

    .answer-status {
        color: inherit;
        display: inline-block;
        text-align: center;
        text-decoration: none;
        width: 60%;
        .user-select(none);

        &.wrong {
            background-color: @wrongRed;
        }

        &.correct {
            background-color: @correctGreen;
        }

        &.ungraded {
            background-color: @ungradedBlue;
        }
    }

    .input-answer-editor-message {
        margin-left: 5px;

        .perseus-single-editor{
            font-family: 'Lucida Grande';
            width: 230px;

            .perseus-textarea-pair > textarea,
            .perseus-textarea-underlay {
                padding: 5px;
            }

            .perseus-textarea-pair {
                border-color: @widgetBorderColor;
                border-radius: @editorBorderRadius;
                min-height: 53px;
            }

            .perseus-textarea-underlay {
                margin-bottom: 0; //override
            }
        }
    }
}

//
// Radio editor / renderer
//

.perseus-widget-radio {

    .choice-editor {
        .perseus-single-editor {
            margin-bottom: 0;
        }
        &.correct textarea {
            background: #aaffaa;
        }
        &.incorrect textarea {
            background: #ffcccc;
        }
    }

    textarea {
        // http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css
        &::-webkit-input-placeholder {
            color: #777;
        }
        &:-moz-placeholder {
            color: #777;
            opacity: 1;
        }
        &::-moz-placeholder {
            color: #777;
            opacity: 1;
        }
        &:-ms-input-placeholder {
            color: #777;
        }
    }

    .clue-editor {
        .perseus-textarea-pair {
            border-top: 0;
        }
    }

    .choice-clue-editors,
    .choice-editor,
    .clue-editor {
        display: inline-block;
    }

    .delete-choice {
        margin-left: 5px;
        padding: 5px;
    }

    .perseus-single-editor {
        border: 0;
        display: inline-block;
        margin: 0 0 5px;
        vertical-align: top;
        width: 280px;

        p {margin: 0;}
    }
}

.perseus-widget-radio .perseus-textarea-pair {
    & > textarea, > .perseus-textarea-underlay {
        padding: 5px;
    }
}

.perseus-widget-editor-content {
    .perseus-widget-radio {
        .checkbox, .delete-choice {
            position: relative;
            top: -10px;
        }
    }
}

#solutionarea .perseus-widget-radio li {
    padding: 7px 0;
}

//
// Table of values editor
//

.framework-perseus table.perseus-widget-table-of-values {
    th {
        .perseus-single-editor {
            width: 80px;
            margin-bottom: 6px;
        }
        .perseus-textarea-pair,
        .perseus-single-editor {
            height: 50px;
        }
    }
}

//
// Categorization Editor
//

.categorization-container.categorization-container-editor {
    @categoryWidth: 160px;
    width: 350px;
    margin-bottom: 160px;

    .card input {
        margin: 7px 3px 7px 13px;
        font-size: 12px;
        display: block;
        width: 81%;
    }


    .category {
        float: left;
        padding: 5px;
        width: @categoryWidth;
    }
    .categories {
        width: (@categoryWidth + 16px);
    }

    .perseus-textarea-underlay {
        margin-bottom: 0;
    }

    .drag-bar {
        float: left;
        font-size: 10px;
        padding: 2px 0;
        height: 70%;
        margin-top: 3px;
    }
    .header {
        margin-bottom: 8px;
        input {
            display: block;
            margin-right: 24px;
            width: 76%;
        }
        .remove {
            position: relative;
            top: -14px;
            left: 12px;
            float: right;
            width: 20px;
            height: 20px;
            padding: 2px;
            color: #666;
            &:hover {
                color: @grayDarker;
            }
            cursor: pointer;
        }
    }
    .delete-item-area {
        position: absolute;
        width: 150px;
        height: 60px;
        padding-top: 40px;
        bottom: -150px;
        left: 10px;
        border: dashed 2px #888;
        color: #888;
        &.target {
            border-color: black;
            color: @grayDarker;
        }
        text-align: center;
        font-size: 20px;
    }
    .card {
        width: (@categoryWidth - 30px);
        padding: 0;
        &.dragging .drag-bar {
            margin-left: 2px;
        }
    }
}

.categorization-editor-area {
    height: 30px;

    .add-item {
        float: left;
        margin-left: 17px;
    }

    .add-category {
        margin-left: 173px;
    }
}

//
// Graph Editor
//

.perseus-widget-interactive-graph {
    display: block;
}

//
// Plot Editor
//

.perseus-widget-plotter-editor {
    .plotter-categories, .pic-url {
        width: 70%;
    }
}

//
// Text List Editors (Orderer, Matcher, Sorter)
//
.perseus-text-list-editor {
    input[type=text] {
        padding: 3px;
        margin-right: 5px;
        min-width: 20px;
        max-width: 340px;
    }

    &.layout-horizontal input[type=text] {
        float: left;
    }
}

.perseus-matcher-editor {
    .perseus-text-list-editor {
        float: left;
        max-width: 50%;

        input[type=text] {
            max-width: 90%;
        }
    }

    input[type=text] {
        width: 46%;
    }

    input[type=text] + input[type=text] {
        margin-left: 2%;
    }
}

// Info-tip lives in react-components but these styles are perseus-specific.
.info-tip {
    display: inline-block;
}

.info-tip-content-container p {
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
}

.info-tip-content-container p + p {
    margin-top: 22px;
}

.expression-answer-option {
    border: 1px solid #ddd;
    border-radius: 3px;

    .answer-handle {
        // textured draggy handle
        background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==) no-repeat 50% 50%;
        border-right: 1px solid #ddd;
        cursor: move;
        display: table-cell;
        width: 20px;
    }

    .answer-body {
        display: table-cell;
    }

    .answer-considered {
        display: table;
    }

    .answer-expression {
        display: table-cell;
    }

    .answer-status {
        display: table-cell;
        width: 100px;
    }

    .answer-option {
        padding-left: 5px;
    }

    .remove-container {
        padding: 5px;

        button {
            width: 100%;
        }
    }

    .perseus-math-input{
        width: 236px;

        .mq-root-block {
            border-top: none;
            border-right: none;
            border-bottom: 1px solid #ddd !important;
            border-left: 1px solid #ddd !important;
        }
    }
}

//
// Interaction Editor
//

.perseus-widget-interaction-editor {
    .perseus-widget-interaction-editor-select-element {
        background-color: #eee;
        border: 1px solid #ddd;
        border-top: 0;
        border-radius: 0 0 3px 3px;
        padding: 5px 10px;
        margin: 20px -11px -11px -11px;
    }

    .colorpicker-circle {
        border-radius: 50%;
        width: 14px;
        height: 14px;
        position: absolute;
        left: 5px;
        top: 5px;
    }
}

.perseus-interaction-element {
    border: @editorBorder;
    border-radius: @editorBorderRadius;

    .perseus-interaction-element-title {
        .pod-title;
        border: 0;
        color: inherit;
        display: block;
        text-decoration: none;
        white-space: nowrap;
        font-size: 1em;

        overflow: hidden;

        > i {
            float: left;
            font-size: 14px;
            margin-right: 10px;
        }
    }

    .perseus-interaction-element-content {
        border-radius: 0 0 @editorBorderRadius @editorBorderRadius;
        border-top: @editorBorder;
        padding: @editorPadding;

        .edit-controls {
            text-align: right;
            margin-top: -30px;
            > button {
                background: #fff;
                border: 0;
                cursor: pointer;
                padding: 0;
                margin-left: 7px;
                font-size: 18px;
                color: #555;
            }
        }

        &.enter {}
        &.leave {
            display: none;
        }
    }
}

.button-set-label {
    display: block;
}

// Float the first one left because it has a suboption.
// This is a minor hack.
.button-set-label-float {
    display: block;
    float: left;
    margin-right: 10px;
}

.button-set-separator {
    margin: 10px 0;
}

// Don't allow selection on this label because I found it very easy to select
// (don't know why...) which caused the selection to not actually be made.
// I know this is autoprefixed in prod, but I want it to work in the perseus
// repo.
.show-div-button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

// double selector for specificity
.perseus-widget-editor .unit-radio {
    color: black;
    text-decoration: none;
}

.unit-example-not-okay {
    color: red;
}

.unit-example-okay {
    color: green;
}
