//! (C) Copyright 2011-2012 Hewlett-Packard Development Company, L.P.

@import "hp-piano-mixins";

form.hp-show-form {
  width: 100%;
  margin-bottom: 20px;
  
  fieldset {
    margin: 20px 0px;
    border: none;
    
    &:first-of-type {
      margin-top: 0px;
    }
    
    &:last-of-type {
      margin-bottom: 0px;
    }
    
    > legend {
      color: $secondary-color;
      font-size: 16px;
      padding-bottom: 20px;
      
      html.hp-high-contrast & {
        color: $projection-secondary-color;
      }
    }
  }

  li.hp-form-item {
    font-size: 0px;
    &:last-of-type {
      margin-bottom: 0px;
    }
    
    > * {
      vertical-align: top;
      display: inline-block;
      font-size: $body-font-size;
      line-height: $body-font-size + 4;
    }
    
    > label:first-of-type {
      max-width: $form-label-width;
      width: 33%;
      margin-bottom: 5px;
      color: #7f7f7f;
      padding-right: 10px;
      @include box-sizing(border-box);

      &.hp-condensed {
        width: auto;
      }
    }
    
    > .hp-form-content {

      width: 66%;
      margin-bottom: 5px;
      font-size: $body-font-size;
      color: #000;
      &.hp-ellipsis {
        width: 66%;
      }
    }
    
    .hp-help, .hp-error, .hp-optional, .hp-important {
      display: inline-block;
      margin: 0px;
      min-width: 80px;
      max-width: 33%;
      color: $secondary-color;
    }
    
    .hp-status {
      display: inline-block;
      top: 4px;
    }
    
    .hp-important {
      position: relative;
      top: -5px;
      background-color: $attention-background;
      color: $primary-color;
      padding: 5px;
    }
    
    .hp-ellipsis {
      display: inline-block;
      width: 80%;
    }
    
    label {
      color: $secondary-color;
      white-space: normal;
      
      html.hp-high-contrast & {
        color: $projection-secondary-color;
      }
      
      &.hp-value {
        color: #000;
        margin-right: 10px;
        width: auto;
        
        html.hp-high-contrast & {
          color: $projection-color;
        }
      }
      
      &.hp-error {
        color: $error;
      }
    }
  }
}

form.hp-edit-form, form.hp-add-form {
  .hp-form-contents {
    fieldset {
      padding-left:15px;
      padding-right:15px;
    }
  }

  position: relative;
  width: 100%;
  min-width: 600px;
  
  body.hp-narrow & {
    min-width: 340px;
  }
  
  ol.hp-stacked-panels {
    fieldset {
      padding-left:30px;
      padding-right:30px;
    }
  }
  
  fieldset {
    position: relative;
    border: none;
    @include box-sizing(border-box);
    padding: 20px 0px 0px;
    background-image: $horizontal-dot-url;
    background-position: left top;
    background-repeat: repeat-x;
    margin: 20px 0px;
    min-width: 630px;
    
    &:first-of-type {
      background-image: none;
      margin-top: 0px;
      padding-top: 0px;
    }
    
    > legend {
      float: left;
      width: 100%;
      
      span {
        display: block;
        color: $secondary-color;
        font-size: 16px;
        padding: 10px 0px 20px 0px;
      
        html.hp-high-contrast & {
          color: $projection-secondary-color;
        }
      }
    }
    
    &.hp-collapsible {
      &.hp-collapsed {
        > label {
          background-position: -407px -577px;
          &:hover {
            background-position: -407px -537px;
          }
        }
      }
      > label {
        position: relative;
        top: -10px;
        width: 100%;
        height: 20px; // span line-height + padding
        font-size: 16px;
        margin: 0px;
        padding: 0px 0px 0px 15px;
        background-position: -405px -455px;
        &:hover {
          background-position: -405px -415px;
        }
      }
    }
    
    table {
      margin-top: 10px;
      
      input, .selectBox, .hp-search-combo {
        margin-bottom: 0px;
      }
    }
    
    .hp-table-controls {
      margin-top: 15px;
      
      > * {
        display: inline-block;
        margin-right: 6px;
      }
      
      .hp-message {
        color: $secondary-color;
      }
    }
  }
  
  li.hp-form-item {
    margin-bottom: 10px;
    font-size: 0px;
    
    body.hp-narrow & {
      margin-bottom: 15px;
    }
    
    &:last-of-type {
      margin-bottom: 0px;
    }
    
    > * {
      vertical-align: top;
      display: inline-block;
      font-size: $body-font-size;
    }

    > label {
      margin: 10px 0px;
      
      &:first-child {
        text-align: right;
        min-width: 150px;
        width: 23%;
        padding-right: 20px;
        @include box-sizing(border-box);
        color: $secondary-color;
        
        body.hp-narrow & {
          display: block;
          text-align: left;
        }
      }
    }
    
    // simple items, single content element
    
    > input, > .hp-search-combo, > .selectBox {
      margin: 2px 15px 2px 0px;
      color: $primary-color;
    }

    > input[type="radio"] {
      margin: 10px 10px 10px 0px;
    }
    
    > input[type="checkbox"] {
      margin: 11px 10px 11px 0px;
      position: relative;
      top: -1px;
      *overflow: hidden;
    }

    > .hp-toggle {
      margin: 4px 10px 4px 0px;
    }
    
    // richer items, content elements with help/errors, etc.
    
    .hp-form-content {
      min-width: 390px;
      width: 73%;
      margin-right: 0px;
      font-size: $body-font-size;
      
      body.hp-narrow & {
        min-width: 340px;
      }

      &.hp-has-error {
        .hp-help, .hp-optional, &:hover .hp-help, &.hp-active .hp-help {
          display: none;
        }
      }
  
      > * {
        vertical-align: top;
        font-size: $body-font-size;
      }
  
      > label, > .hp-table-error {
        display: inline-block;
        margin: 10px 20px 10px 0px;
      }
      
      label.hp-help, label.hp-error, label.hp-optional {
        margin: 10px;
        
        ul li {
          list-style: disc inside none;
        }
      }
      
      label.hp-important {
        margin: 2px 0px;
      }
  
      > input, > textarea, > .hp-search-combo, > .selectBox {
        margin: 2px 15px 2px 0px;
        color: $primary-color;
      }
  
      > input[type="radio"] {
        margin: 10px 10px 10px 0px;
        width: 13px;
        height: 13px;
        position: relative;
        top: 1px;
        //*overflow: hidden;
      }
      > input[type="checkbox"] {
        margin: 10px 10px 10px 0px;
        width: 13px;
        height: 13px;
        position: relative;
        top: 1px;
        @include box-sizing(border-box);
        //*overflow: hidden;
      }
  
      > .hp-toggle {
        margin: 4px 10px 4px 0px;
      }
  
      > table {
        display: inline-block;
        margin-top: 5px;
      }
  
      > .hp-table-error {
        max-width: 30%;
        color: $error;
        margin-left: 10px;
      }

      .hp-help {
        opacity: 0;
        @include transition-full(opacity, 0.1s, ease-in-out, 0.2s);
      }

      &:hover .hp-help, &.hp-active .hp-help {
        opacity: 1;
        display:inline-block;
      }
      
      &:hover .hp-has-help, &.hp-active .hp-has-help {
        display:none;
      }
    }

    label.hp-help {
      display:none;
      margin: 10px;
      width: 200px;
      @include box-sizing(border-box);
    } 
    
    label.hp-error, label.hp-optional, label.hp-important {
      display: inline-block;
      margin: 10px;
      width: 200px;
      @include box-sizing(border-box);
    }

    label.hp-important {
      background-color: $attention-background;
      color: $primary-color;
      padding: 8px 10px;
    }
  }
  
  > .hp-footer {
    width: 100%;
    margin: 0px;
    @include box-sizing(border-box);
    border-top: 1px solid $change-header-divider;
    z-index: $header-z-index; // above stacked panels section header
    
    .hp-form-controls {
      position: absolute;
      padding: 15px;
      top: 0px;
      right: 4px;
      bottom: 0px;
      height: $form-footer-height;
      @include box-sizing(border-box);
      background-color: $primary-background;
      
      > * {
        vertical-align: top;
        margin-right: 11px;
      }
    }
    
    #hp-form-state {
      position: relative;
      height: $form-footer-height;
      line-height: $form-footer-height;
      white-space: nowrap;
      
      #hp-form-message {
        position: absolute;
        left: 60px;
        bottom: 0px;
        @include box-sizing(border-box);
        color: $secondary-primary-color;
        border: 1px solid #fff;
        @include transitions(background-color, 0.2s, max-height, 0.8s);
        max-height: $form-footer-height;
        
        html.hp-high-contrast & {
          color: $projection-color;
        }
        
        .hp-form-message-summary {
          position: relative;
          padding: 0px 0px 0px 15px;
          height: $form-footer-height;
          white-space: nowrap;
        
          > * {
            display: inline-block;
            vertical-align: top;
          }
        
          > .hp-status {
            position: relative;
            top: 22px;
            left: 0px;
            line-height: 14px;
            margin-right: 0px;
          }
          
          .hp-form-message-text {
            overflow: hidden;
            width: 95%;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
        
        > .hp-form-message-details {
          position: relative;
          @include box-sizing(border-box);
          max-height: 400px;
          line-height: normal;
          padding: 0px 20px 20px 20px;
          white-space: normal;
          overflow: auto;
          display: none;
        }
        
        &.hp-activateable {
          background-color: $attention-background;
          border-top-width: 0px;
          border-bottom-width: 0px;
          border-left-color: $change-header-divider;
          border-right-color: $change-header-divider;
          cursor: pointer;
          
          .hp-form-message-summary {
            
            &:hover {
              background-color: $attention-background;
              color: $primary-color;
              
              html.hp-high-contrast & {
                color: $projection-color;
              }
            }
          }
        }
        
        &.hp-active {
          
          max-height: 400px;
          background-color: $attention-background;
          color: $primary-color;
          border: 1px solid $change-header-divider;
          z-index: ($header-z-index + 10);
          
          html.hp-high-contrast & {
            color: $projection-color;
          }
          
          .hp-form-message-summary {
            height: auto;
            
            > .hp-status {
              top: 10px;
            }
          }
          
          .hp-form-message-text {
            line-height: normal;
            padding-top: 10px;
            padding-bottom: 10px;
            white-space: normal;
            text-overflow: clip;
          }
          
          .hp-form-message-details {
            display: block;
          }
        }
      }
    }
    
    #hp-form-changes {
      position: absolute;
      left: 0px;
      bottom: 0px;
      height: $form-footer-height;
      
      #hp-form-changes-control {
        position: relative;
        display: inline-block;
        color: $secondary-color;
        height: $form-footer-height - 2;
        width: 60px;
        cursor: pointer;
        @include transition(background-color, 0.1s);
        
        html.hp-high-contrast & {
          color: $projection-secondary-color;
        }
      
        .hp-icon {
          position: relative;
          top: 15px;
          left: 15px;
          width: 23px;
          height: 23px;
          background-image: url($img-file);
          background-position: $edit-x -40px;
          background-repeat: no-repeat;
          vertical-align: middle;
        }
      
        .hp-count {
          position: absolute;
          top: 8px;
          right: 8px;
          height: 17px;
          width: 20px;
          padding-top: 3px;
          text-align: center;
          background-image: url($img-file);
          background-repeat: no-repeat;
          background-position: -240px -100px;
          font-size: 11px;
          line-height: 14px;
          font-weight: bold;
          color: #000;
        }
      
        &:hover {
          z-index: $header-z-index;
        
          .hp-icon {
            background-position: $edit-x 0px;
          }
        }
      }
      
      ol {
        position: absolute;
        bottom: $form-footer-height;
        min-width: 80px;
        max-height: 400px;
        line-height: 14px;
        @include box-sizing(border-box);
        background-color: $primary-background;
        color: $primary-color;
        z-index: $drop-menu-z-index;
        @include drop-menu-border();
        border-top: 5px solid $dropdown-border;
        border-bottom: 1px solid #ccc;
        margin-bottom: 0px;
        overflow: auto;
        display: none;
        
        html.hp-high-contrast & {
          color: $projection-color;
        }
        
        li {
          padding: 15px;
          border-top: 1px solid $primary-divider;
          
          &:first-of-type {
            border-top: none;
          }
          
          .hp-form-change-label {
            color: $secondary-color;
            white-space: nowrap;
            
            html.hp-high-contrast & {
              color: $projection-secondary-color;
            }
          }
          
          .hp-form-change-value {
            white-space: nowrap;
            overflow: hidden;
            max-width: 200px;
            text-overflow: ellipsis;
          }
        }
      }
      
      &.hp-active {
        #hp-form-changes-control {
          background-color: $primary-background;
          
          .hp-icon {
            background-position: $edit-x 0px;
          }
          
          .hp-count {
            background-position: -140px -60px;
          }
        }
        ol {
          display: block;
        }
      }
    }
  }
}

.hp-form-content fieldset {
  ol, p {
    &:last-of-type {
      margin-bottom:0px;
    }
  }
}

// Deprecated in sprint 25, would like to remove in sprint 26

/* 2-column form layout */
.hp-column-form {
  width: 100%;
  padding-bottom: 20px;
  overflow: hidden;

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    width: 100%;
    margin-top: 10px;
    padding-bottom: 10px;
    
    &:first-of-type {
      margin-top: 0px;
    }
    
    &:last-of-type {
      border-bottom: none;
      padding-bottom: 0px;
    }
    
    &:hover {
      a {
        &.hp-button {
          text-decoration: none;
        }
      }
    }
    
    > legend {
      color: $secondary-color;
      font-size: 16px;
      padding-bottom: 20px;
      
      html.hp-high-contrast & {
        color: $projection-secondary-color;
      }
    }
    
    > ol {
      
      > li {
        margin-bottom: 10px;
        
        > label:first-of-type {
          display: inline-block;
          width: 33%;
          padding-right: 5px;
          @include box-sizing(border-box);
          max-width: $form-label-width;
          
          &.hp-condensed {
            width: auto;
            margin-right: 10px;
          }
        }
        
        > .hp-form-content {
          width: 66%;
        }
      
        div, span, label {
          
          &.hp-help, &.hp-error, &.hp-optional, &.hp-important {
            display: inline-block;
            margin: 0px;
            padding: 10px 0px;
            min-width: 200px;
            max-width: 33%;
            line-height: 15px;
          }
          
          &.hp-important {
            position: relative;
            top: -5px;
            background-color: $attention-background;
            color: $primary-color;
            padding: 5px;
          }
        }
      
        .hp-details-notify { // todo: revisit
          max-width: 800px;
        }
      }
    }
      
    label {
      color: $secondary-color;
      white-space: normal;
      margin-bottom: 5px;
      
      html.hp-high-contrast & {
        color: $projection-secondary-color;
      }
      
      &.hp-value {
        color: $primary-color;
        margin-right: 10px;
        width: auto;
        
        html.hp-high-contrast & {
          color: $projection-color;
        }
      }
      
      &.hp-error {
        color: $error;
      }
    }
  
    .hp-form-label {
      float: left;
      width: $form-label-width;
      margin: 0;
      padding: 20px 0;
      line-height: 24px;
    }
    
    .hp-form-content {
      display: inline-block;
    }
    
    .hp-form-input {
      position: relative;
      display: inline-block;
      vertical-align: baseline;
      
      &.hp-form-input-large {
        vertical-align: text-top;
        top: -7px;
      }
      
      > input {
        margin-left: 15px;
        
        &:first-of-type {
          margin-left: 0px;
        }
      }
      
      .hp-help, .hp-error, table {
        display: inline-block;
      }
      
      .hp-table-help, .hp-table-error {
        position: relative;
        display: inline-block;
        vertical-align: top;
        top: 5px;
        margin-left: 15px;
      }
      
      .hp-table-help {
        color: $secondary-color;
        
        html.hp-high-contrast & {
          color: $projection-secondary-color;
        }
      }
      
      .hp-table-error {
        color: $error;
      }
      
      .hp-form-table-toolbar {
        > * {
          margin-bottom: 0px;
        }
      }
    }
    
    > table {
      margin-top: 10px;
    }
    
    .hp-table-controls {
      margin-top: 10px;
      
      > * {
        display: inline-block;
        margin-right: 6px;
      }
      
      .hp-message {
        color: $secondary-color;
      }
    }
  }
    
  .hp-form-content-divider {
    padding: 20px 0 20px 0;
    border-bottom: solid 1px $primary-divider;
  }
  
  .hp-form-item {
    padding: 15px 0 15px 0;
    border-top: solid 1px $primary-divider;
    
    &:last-of-type {
      border-bottom: solid 1px $primary-divider;
    }
    
    > .hp-form-item-controls {
      float: right;
      
      > * {
        display: inline-block;
        margin-left: 10px;
        //vertical-align: top;
      }
      
      .hp-close {
        position: relative;
        top: 5px;
        cursor: pointer;
      }
    }
  }
}

// TODO: clean up this tag
#cic-additemslist-items-table {
  @include no-select;
}

.hp-filter-pane {
  .hp-column-form fieldset > ol > li {
    white-space: normal;
    
    > label {
      float: left;
      width: 80px;
    }
    
    .hp-slider {
      position: relative;
      margin-top: 10px;
      width: 160px;
      
      .hp-slider-max {
        position: absolute;
        top: 0px;
        right: 0px;
      }
      
      .hp-slider-slider {
        margin-top: 10px;
        margin-bottom: 20px;
        height: 2px;
        background: none;
        background-color: #eee;
        
        .ui-slider-range {
          background: none;
          background-color: #bbb;
        }
        
        .ui-slider-handle {
          width: 10px;
          background: #ccc;
          border: none;
          border-radius: 0px;
          border-bottom-left-radius: 3px;
          border-bottom-right-radius: 3px;
          outline: none;
          
          &:after {
            content: "";
            position: absolute;
            top: -5px;
            border-width: 0 5px 5px;
            border-color: #ccc transparent;
            border-style: solid;
            display: block;
            width: 0;
          }
        }
      }
    }
  }
}
