/* TODO: May break up into component local CSS.  Pending future discussions by
 * React component group on how to best handle CSS. */

/**
 * CSS Variables specific to the responsive design mode
 */

.theme-light {
  --rdm-box-shadow: 0 4px 4px 0 rgba(155, 155, 155, 0.26);
  --submit-button-active-background-color: rgba(0,0,0,0.12);
  --submit-button-active-color: var(--theme-body-color);
  --viewport-color: #999797;
  --viewport-hover-color: var(--theme-body-color);
  --viewport-active-color: #3b3b3b;
  --viewport-selection-arrow: url("./images/select-arrow.svg");
}

.theme-dark {
  --rdm-box-shadow: 0 4px 4px 0 rgba(105, 105, 105, 0.26);
  --submit-button-active-background-color: var(--theme-toolbar-hover-active);
  --submit-button-active-color: var(--theme-selection-color);
  --viewport-color: #c6ccd0;
  --viewport-hover-color: #dde1e4;
  --viewport-active-color: #fcfcfc;
  --viewport-selection-arrow: url("./images/select-arrow.svg");
}

* {
  box-sizing: border-box;
}

:root,
input,
select,
button {
  font-size: 11px;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

#app {
  /* Center the viewports container */
  display: flex;
  align-items: center;
  flex-direction: column;
  padding-top: 15px;
  padding-bottom: 1%;
  position: relative;
  height: 100%;
}

/**
 * Common styles for shared components
 */

.container {
  background-color: var(--theme-toolbar-background);
  border: 1px solid var(--theme-splitter-color);
}

.toolbar-button {
  margin: 0;
  padding: 0;
  border: none;
}

.toolbar-button:empty:hover:not(:disabled),
.toolbar-button:empty:-moz-any(:hover:active, .checked):not(:disabled) {
  /* Reset background from .devtools-button */
  background: none;
}

.toolbar-button:active::before {
  filter: var(--checked-icon-filter);
}

select {
  -moz-appearance: none;
  background-color: var(--theme-toolbar-background);
  background-image: var(--viewport-selection-arrow);
  -moz-context-properties: fill;
  fill: currentColor;
  color: var(--viewport-color);
  background-position: 100% 50%;
  background-repeat: no-repeat;
  background-size: 7px;
  border: none;
  height: 100%;
  padding: 0 8px;
  text-align: center;
  text-overflow: ellipsis;
}

select.selected {
  color: var(--viewport-active-color);
}

select:not(:disabled):hover {
  color: var(--viewport-hover-color);
}

/* This is (believed to be?) separate from the identical select.selected rule
   set so that it overrides select:hover because of file ordering once the
   select is focused.  It's unclear whether the visual effect that results here
   is intentional and desired. */
select:focus {
  color: var(--viewport-active-color);
}

select > option {
  text-align: left;
  padding: 5px 10px;
}

select > option,
select > option:hover {
  color: var(--viewport-active-color);
}

select > option.divider {
  border-top: 1px solid var(--theme-splitter-color);
  height: 0px;
  padding: 0;
  font-size: 0px;
}

/**
 * Global Toolbar
 */

#global-toolbar {
  color: var(--theme-body-color-alt);
  border-radius: 2px;
  box-shadow: var(--rdm-box-shadow);
  margin: 0 0 15px 0;
  padding: 4px 5px;
  display: inline-flex;
  -moz-user-select: none;
}

#global-toolbar > .title {
  border-right: 1px solid var(--theme-splitter-color);
  padding: 1px 6px 0 2px;
}

#global-toolbar > .toolbar-button::before {
  width: 12px;
  height: 12px;
}

#global-touch-simulation-button::before {
  background-image: url("./images/touch-events.svg");
}

#global-screenshot-button::before {
  background-image: url("./images/screenshot.svg");
}

#global-exit-button::before {
  background-image: url("chrome://devtools/skin/images/close.svg");
}

#global-screenshot-button:disabled {
  filter: var(--checked-icon-filter);
  opacity: 1 !important;
}

#global-network-throttling-selector {
  height: 15px;
  padding-left: 0;
  width: 103px;
}

#global-dpr-selector > select {
  padding: 0 8px 0 0;
  margin-left: 2px;
}

#global-dpr-selector {
  margin: 0 8px;
  -moz-user-select: none;
  color: var(--viewport-color);
  height: 15px;
}

#global-dpr-selector.focused,
#global-dpr-selector:not(.disabled):hover {
  color: var(--viewport-hover-color);
}

#global-dpr-selector:not(.disabled):hover > select {
  color: var(--viewport-hover-color);
}

#global-dpr-selector:focus > select {
  color: var(--viewport-active-color);
}

#global-dpr-selector.selected,
#global-dpr-selector.selected > select {
  color: var(--viewport-active-color);
}

#global-dpr-selector > select > option {
  padding: 5px;
}

#viewports {
  /* Make sure left-most viewport is visible when there's horizontal overflow.
     That is, when the horizontal space become smaller than the viewports and a
     scrollbar appears, then the first viewport will still be visible */
  position: sticky;
  left: 0;
  /* Individual viewports are inline elements, make sure they stay on a single
     line */
  white-space: nowrap;
}

/**
 * Viewport Container
 */

.viewport {
  display: inline-block;
  /* Align all viewports to the top */
  vertical-align: top;
}

.resizable-viewport {
  border: 1px solid var(--theme-splitter-color);
  box-shadow: var(--rdm-box-shadow);
  position: relative;
}

/**
 * Viewport Toolbar
 */

.viewport-toolbar {
  border-width: 0;
  border-bottom-width: 1px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  height: 16px;
}

.viewport-rotate-button {
  position: absolute;
  right: 0;
}

.viewport-rotate-button::before {
  background-image: url("./images/rotate-viewport.svg");
}

/**
 * Viewport Content
 */

.viewport-content.resizing {
  pointer-events: none;
}

/**
 * Viewport Browser
 */

.browser-container {
  width: inherit;
  height: inherit;
}

.browser {
  display: block;
  border: 0;
  -moz-user-select: none;
}

.browser:-moz-focusring {
  outline: none;
}

/**
 * Viewport Resize Handles
 */

.viewport-resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  bottom: 0;
  right: 0;
  background-image: url("./images/grippers.svg");
  background-position: bottom right;
  padding: 0 1px 1px 0;
  background-repeat: no-repeat;
  background-origin: content-box;
  cursor: se-resize;
}

.viewport-resize-handle.hidden {
  display: none;
}

.viewport-horizontal-resize-handle {
  position: absolute;
  width: 5px;
  height: calc(100% - 16px);
  right: -4px;
  top: 0;
  cursor: e-resize;
}

.viewport-vertical-resize-handle {
  position: absolute;
  width: calc(100% - 16px);
  height: 5px;
  left: 0;
  bottom: -4px;
  cursor: s-resize;
}

/**
 * Viewport Dimension Label
 */

.viewport-dimension {
  display: flex;
  justify-content: center;
  font: 10px sans-serif;
  margin-bottom: 10px;
}

.viewport-dimension-editable {
  border-bottom: 1px solid transparent;
}

.viewport-dimension-editable,
.viewport-dimension-input {
  color: var(--theme-body-color-inactive);
  transition: all 0.25s ease;
}

.viewport-dimension-editable.editing,
.viewport-dimension-input.editing {
  color: var(--viewport-active-color);
  outline: none;
}

.viewport-dimension-editable.editing {
  border-bottom: 1px solid var(--theme-selection-background);
}

.viewport-dimension-editable.editing.invalid {
  border-bottom: 1px solid #d92215;
}

.viewport-dimension-input {
  background: transparent;
  border: none;
  text-align: center;
}

.viewport-dimension-separator {
  -moz-user-select: none;
}

/**
 * Device Modal
 */

@keyframes fade-in-and-up {
  0% {
    opacity: 0;
    transform: translateY(5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0px);
  }
}

@keyframes fade-down-and-out {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(5px);
    visibility: hidden;
  }
}

.device-modal {
  border-radius: 2px;
  box-shadow: var(--rdm-box-shadow);
  display: none;
  position: absolute;
  margin: auto;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 642px;
  height: 650px;
  z-index: 1;
}

/* Handles the opening/closing of the modal */
#device-modal-wrapper.opened .device-modal {
  animation: fade-in-and-up 0.3s ease;
  animation-fill-mode: forwards;
  display: block;
}

#device-modal-wrapper.closed .device-modal {
  animation: fade-down-and-out 0.3s ease;
  animation-fill-mode: forwards;
  display: block;
}

#device-modal-wrapper.opened .modal-overlay {
  background-color: var(--theme-splitter-color);
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: 0;
  opacity: 0.5;
}

.device-modal-content {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  overflow: auto;
  height: 515px;
  width: 600px;
  margin: 20px 20px 0;
}

#device-close-button,
#device-close-button::before {
  position: absolute;
  top: 5px;
  right: 2px;
  width: 12px;
  height: 12px;
}

#device-close-button::before {
  background-image: url("chrome://devtools/skin/images/close.svg");
  margin: -6px 0 0 -6px;
}

.device-type {
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.device-header {
  font-weight: bold;
  text-transform: capitalize;
  padding: 0 0 3px 23px;
}

.device-label {
  padding-bottom: 3px;
  display: flex;
  align-items: center;
  /* Largest size without horizontal scrollbars */
  max-width: 181px;
}

.device-input-checkbox {
  margin-right: 5px;
}

.device-name {
  flex: 1;
}

.device-remove-button,
.device-remove-button:empty::before {
  width: 12px;
  height: 12px;
}

.device-remove-button:empty::before {
  background-image: url("chrome://devtools/skin/images/close.svg");
  margin: -6px 0 0 -6px;
}

#device-submit-button {
  background-color: var(--theme-tab-toolbar-background);
  border-width: 1px 0 0 0;
  border-top-width: 1px;
  border-top-style: solid;
  border-top-color: var(--theme-splitter-color);
  color: var(--theme-body-color);
  width: 100%;
  height: 20px;
  position: absolute;
  bottom: 0;
}

#device-submit-button:hover {
  background-color: var(--theme-toolbar-hover);
}

#device-submit-button:hover:active {
  background-color: var(--submit-button-active-background-color);
  color: var(--submit-button-active-color);
}

/**
 * Device Adder
 */

#device-adder {
  display: flex;
  flex-direction: column;
  margin: 0 20px;
}

#device-adder-content {
  display: flex;
}

#device-adder-column-1 {
  flex: 1;
  margin-right: 10px;
}

#device-adder-column-2 {
  flex: 2;
}

#device-adder button {
  background-color: var(--theme-tab-toolbar-background);
  border: 1px solid var(--theme-splitter-color);
  border-radius: 2px;
  color: var(--theme-body-color);
  margin: 0 auto;
}

#device-adder label {
  display: flex;
  margin-bottom: 5px;
  align-items: center;
}

#device-adder label > input,
#device-adder label > .viewport-dimension {
  flex: 1;
  margin: 0;
}

#device-adder input {
  background: transparent;
  border: 1px solid transparent;
  text-align: center;
  color: var(--theme-body-color-inactive);
  transition: all 0.25s ease;
}

#device-adder input:focus {
  color: var(--viewport-active-color);
}

#device-adder label > input:focus,
#device-adder label > .viewport-dimension:focus  {
  border-bottom: 1px solid var(--theme-selection-background);
  outline: none;
}

.device-adder-label {
  display: inline-block;
  margin-right: 5px;
  min-width: 35px;
}
