@tailwind base;
@tailwind components;
@tailwind utilities;

/* Theme */

:root {
  --primary: theme('colors.light-theme.orange.DEFAULT');
  --primary-dark: theme('colors.light-theme.orange.dark');
  --red: theme('colors.light-theme.red.DEFAULT');
  --red-dark: theme('colors.light-theme.red.dark');
  --red-muted: theme('colors.light-theme.red.muted');
  --green: theme('colors.light-theme.green.DEFAULT');
  --green-dark: theme('colors.light-theme.green.dark');
  --green-muted: theme('colors.light-theme.green.muted');
  --orange: theme('colors.light-theme.orange.DEFAULT');
  --bkg-1: theme('colors.light-theme.bkg-1');
  --bkg-2: theme('colors.light-theme.bkg-2');
  --bkg-3: theme('colors.light-theme.bkg-3');
  --bkg-4: theme('colors.light-theme.bkg-4');
  --fgd-1: theme('colors.light-theme.fgd-1');
  --fgd-2: theme('colors.light-theme.fgd-2');
  --fgd-3: theme('colors.light-theme.fgd-3');
  --fgd-4: theme('colors.light-theme.fgd-4');
  --bkg-button: theme('colors.light-theme.bkg-button');
}

[data-theme='Dark'] {
  --primary: theme('colors.dark-theme.yellow.DEFAULT');
  --primary-dark: theme('colors.dark-theme.yellow.dark');
  --red: theme('colors.dark-theme.red.DEFAULT');
  --red-dark: theme('colors.dark-theme.red.dark');
  --red-muted: theme('colors.dark-theme.red.muted');
  --green: theme('colors.dark-theme.green.DEFAULT');
  --green-dark: theme('colors.dark-theme.green.dark');
  --green-muted: theme('colors.dark-theme.green.muted');
  --orange: theme('colors.dark-theme.orange.DEFAULT');
  --bkg-1: theme('colors.dark-theme.bkg-1');
  --bkg-2: theme('colors.dark-theme.bkg-2');
  --bkg-3: theme('colors.dark-theme.bkg-3');
  --bkg-4: theme('colors.dark-theme.bkg-4');
  --fgd-1: theme('colors.dark-theme.fgd-1');
  --fgd-2: theme('colors.dark-theme.fgd-2');
  --fgd-3: theme('colors.dark-theme.fgd-3');
  --fgd-4: theme('colors.dark-theme.fgd-4');
  --bkg-button: theme('colors.dark-theme.bkg-button');
}

[data-theme='Mango'] {
  --primary: theme('colors.mango-theme.yellow.DEFAULT');
  --primary-dark: theme('colors.mango-theme.yellow.dark');
  --red: theme('colors.mango-theme.red.DEFAULT');
  --red-dark: theme('colors.mango-theme.red.dark');
  --red-muted: theme('colors.mango-theme.red.muted');
  --green: theme('colors.mango-theme.green.DEFAULT');
  --green-dark: theme('colors.mango-theme.green.dark');
  --green-muted: theme('colors.mango-theme.green.muted');
  --orange: theme('colors.mango-theme.orange.DEFAULT');
  --bkg-1: theme('colors.mango-theme.bkg-1');
  --bkg-2: theme('colors.mango-theme.bkg-2');
  --bkg-3: theme('colors.mango-theme.bkg-3');
  --bkg-4: theme('colors.mango-theme.bkg-4');
  --fgd-1: theme('colors.mango-theme.fgd-1');
  --fgd-2: theme('colors.mango-theme.fgd-2');
  --fgd-3: theme('colors.mango-theme.fgd-3');
  --fgd-4: theme('colors.mango-theme.fgd-4');
  --bkg-button: theme('colors.mango-theme.bkg-button');
}

/* Base */

body {
  @apply font-body text-sm tracking-wider;
}

h1 {
  @apply text-xl font-bold text-th-fgd-1 md:text-2xl;
}

h2 {
  @apply text-lg font-bold text-th-fgd-1;
}

h3 {
  @apply text-base font-bold text-th-fgd-1;
}

h4 {
  @apply text-sm font-bold text-th-fgd-3;
}

p {
  @apply mb-2 text-sm text-th-fgd-3;
}

a {
  @apply text-th-primary md:hover:text-th-primary-dark;
}

li {
  @apply mb-2.5 text-sm text-th-fgd-3 last:mb-0;
}

tbody {
  @apply border-t border-th-bkg-3;
}

button {
  transition: all 0.3s ease;
  @apply rounded-md tracking-wider md:hover:brightness-[1.1] md:disabled:hover:brightness-100;
}

.transition-none {
  transition: none;
}

.default-transition {
  @apply transition-all duration-200;
}

.tiny-text {
  font-size: 0.65rem;
  line-height: 1.5;

  @media screen and (max-width: 767px) {
    font-size: 14px;
  }
}

/* Chart */

.TVChartContainer {
  height: 100%;
  width: 100%;
}

.tradingview-chart {
  display: contents;
}

/* Grid */

.react-grid-item.react-grid-placeholder {
  background: var(--bkg-3);
  opacity: 90%;
  border-radius: 8px;
  transition-duration: 100ms;
  z-index: 2;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
}

.react-resizable-handle {
  background-image: none;
  z-index: 100;
}

.react-grid-item > .react-resizable-handle {
  width: 24px;
  height: 24px;
}

.react-grid-item > .react-resizable-handle::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 0;
  width: 8px;
  height: 8px;
  border-right: 3px solid var(--primary);
  border-bottom: 3px solid var(--primary);
  border-radius: 1px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
}

/* Scrollbars */

body::-webkit-scrollbar {
  width: 8px;
  background-color: var(--bkg-1);
}

body::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background-color: var(--bkg-4);
}

body::-webkit-scrollbar-track {
  background-color: inherit;
}

body::-webkit-scrollbar-corner {
  background-color: var(--bkg-3);
}

.thin-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.thin-scroll::-webkit-scrollbar-thumb {
  @apply rounded bg-th-bkg-4;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.thin-scroll::-webkit-scrollbar-thumb:hover {
  border: 0;
}

.thin-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.thin-scroll::-webkit-scrollbar-thumb:window-inactive {
  @apply bg-th-bkg-4;
}

/* Responsive table */
/* inspired by: https://css-tricks.com/responsive-data-tables/ */

.responsiveTable {
  width: 100%;
}

.responsiveTable td .tdBefore {
  display: none;
}

@media screen and (max-width: 767px) {
  .responsiveTable table,
  .responsiveTable thead,
  .responsiveTable tbody,
  .responsiveTable th,
  .responsiveTable td,
  .responsiveTable tr {
    display: block;
  }

  .responsiveTable thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
    border-bottom: 2px solid #333;
  }

  .responsiveTable tbody tr {
    @apply px-4;
  }

  .responsiveTable td.pivoted {
    /* Behave like a "row" */
    @apply pb-1;
    position: relative;
    padding-left: calc(50% + 10px) !important;
    text-align: left !important;
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  .responsiveTable td.pivoted:last-child {
    /* Behave like a "row" */
    @apply pb-4;
  }

  .responsiveTable td.pivoted:last-child {
    /* Behave like a "row" */
    @apply border-b-0;
  }

  .responsiveTable td .tdBefore {
    /* Now like a table header */
    @apply font-normal text-th-fgd-3;
    position: absolute;
    display: block;

    /* Top/left values mimic padding */
    left: 1rem;
    width: calc(50% - 20px);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    text-align: left !important;
  }
}

/* phone input */

.react-tel-input .form-control:hover + div {
  border-right: 1px solid var(--primary) !important;
}

.react-tel-input .form-control:focus + div {
  border-right: 1px solid var(--primary) !important;
}

.react-tel-input .selected-flag:hover {
  background-color: transparent !important;
}

.react-tel-input .flag-dropdown .open {
  background-color: transparent !important;
}

.react-tel-input .flag-dropdown:active {
  background-color: transparent !important;
}

.react-tel-input .country-list .country:hover {
  background-color: var(--bkg-3) !important;
}

.react-tel-input .country-list .highlight {
  background-color: var(--bkg-3) !important;
}

.react-tel-input .country-list {
  margin: 8px 0 10px -6px !important;
}

.react-tel-input .selected-flag:hover,
.react-tel-input .selected-flag:focus,
.react-tel-input .selected-flag.open {
  background-color: transparent !important;
}

/* orderbook flash */

@keyframes green-flash {
  from {
    background-color: var(--green-muted);
  }
  to {
    background-color: transparent;
  }
}

@-webkit-keyframes green-flash {
  from {
    background-color: var(--green-muted);
  }
  to {
    background-color: transparent;
  }
}
@-moz-keyframes green-flash {
  from {
    background-color: var(--green-muted);
  }
  to {
    background-color: transparent;
  }
}

@keyframes red-flash {
  from {
    background-color: var(--red-muted);
  }
  to {
    background-color: transparent;
  }
}

@-webkit-keyframes red-flash {
  from {
    background-color: var(--red-muted);
  }
  to {
    background-color: transparent;
  }
}
@-moz-keyframes red-flash {
  from {
    background-color: var(--red-muted);
  }
  to {
    background-color: transparent;
  }
}

.green-flash {
  -moz-animation: green-flash 0.5s ease 0s 1 alternate;
  -webkit-animation: green-flash 0.5s ease 0s 1 alternate;
  animation: green-flash 0.5s ease 0s 1 alternate;
}

.red-flash {
  -moz-animation: red-flash 0.5s ease 0s 1 alternate;
  -webkit-animation: red-flash 0.5s ease 0s 1 alternate;
  animation: red-flash 0.5s ease 0s 1 alternate;
}

.react-swipeable-view-container > div[aria-hidden='false'] {
  height: 100%;
}

.react-swipeable-view-container > div[aria-hidden='true'] {
  height: 0;
}

/* Intro Tour */

.intro-tooltip * {
  @apply bg-th-bkg-1 font-body text-th-fgd-1;
}

.introjs-tooltip {
  @apply bg-transparent;
}

.introjs-arrow {
  @apply border-0;
}

.introjs-skipbutton {
  @apply text-xs text-th-fgd-4 hover:text-th-fgd-2;
}

.introjs-tooltip-header {
  @apply rounded-t-md;
  padding: 10px 10px 0px;
}

.introjs-tooltiptext {
  padding: 10px 20px 20px;
}

.introjs-tooltipbuttons {
  @apply rounded-b-md border-th-bkg-4 font-bold focus:outline-none;
}

.introjs-nextbutton {
  @apply pointer-events-none flex h-4 items-center rounded-full border-th-bkg-4 bg-th-bkg-4 text-sm text-th-fgd-1 opacity-60;
  text-shadow: none;
}

.introjs-prevbutton {
  @apply hidden;
}

.introjs-button:hover {
  @apply border-th-bkg-4 bg-th-bkg-4 text-th-fgd-1 brightness-[1.15];
}

.introjs-button:focus {
  @apply border-th-bkg-4 bg-th-bkg-4 text-th-fgd-1 shadow-none;
}

.introjs-hidden {
  @apply hidden;
}

.introjs-progressbar {
  @apply bg-th-primary;
}

.intro-tooltip h4 {
  @apply mb-2 font-body text-lg font-bold;
}

.intro-tooltip p {
  @apply mb-1 font-body text-sm text-th-fgd-3;
}

.introjs-bullets ul li a {
  @apply bg-th-bkg-4;
}

.introjs-bullets ul li a:hover {
  @apply bg-th-fgd-4;
}

.introjs-bullets ul li a.active {
  @apply bg-th-primary;
}

.intro-highlight {
  @apply border-0;
}

.introjs-progress {
  @apply m-0 h-0.5 rounded-none;
}

@keyframes fadein {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.flipcard {
  background-color: transparent;
  height: 100%;
  perspective: 1000px;
}

.flipcard-front {
  @media screen and (min-width: 768px) {
    height: 100%;
    position: absolute;
  }
}

.fadein-floating-element {
  animation: fadein 1s linear;
}

/* CJK characters */
.keep-break {
  word-break: keep-all;
}

.react-horizontal-scrolling-menu--item {
  @apply w-full;
}

.pro-sidebar {
  @apply text-th-fgd-1;
}

.pro-sidebar > .pro-sidebar-inner {
  @apply border-r border-th-bkg-3 bg-th-bkg-1;
}

.pro-sidebar > .pro-sidebar-inner > .pro-sidebar-layout .pro-sidebar-header {
  @apply border-b-0;
}

.pro-sidebar > .pro-sidebar-inner > .pro-sidebar-layout .pro-sidebar-footer {
  @apply border-t border-th-bkg-3 bg-th-bkg-1;
}

.pro-sidebar .pro-menu .pro-menu-item.active {
  @apply text-th-primary;
}

.pro-sidebar .pro-menu > ul > .pro-sub-menu > .pro-inner-list-item {
  @apply bg-th-bkg-1;
}

.pro-sidebar .pro-menu > ul > .pro-sub-menu > .pro-inner-list-item > div > ul {
  @apply pt-2 pb-2;
}

.pro-sidebar
  .pro-menu
  .pro-menu-item.pro-sub-menu
  .pro-inner-list-item
  .pro-inner-item {
  @apply py-1;
}

.pro-sidebar .pro-menu .pro-menu-item {
  @apply text-sm;
}

.pro-sidebar .pro-menu > ul > li {
  @apply mb-0 text-th-fgd-2;
}

.pro-sidebar .pro-menu .pro-menu-item li {
  @apply mb-0;
}

.pro-sidebar .pro-menu .pro-menu-item.pro-sub-menu .pro-inner-list-item {
  @apply pl-2;
}

.pro-sidebar .pro-menu .pro-menu-item > .pro-inner-item:hover {
  @apply text-th-primary;
}

.pro-sidebar .pro-menu a:hover {
  @apply text-th-primary;
}

.pro-sidebar.collapsed
  .pro-menu
  > ul
  > .pro-menu-item.pro-sub-menu
  > .pro-inner-list-item
  > .popper-inner {
  @apply bg-th-bkg-2;
}

.pro-sidebar.collapsed
  .pro-menu
  > ul
  > .pro-menu-item.pro-sub-menu
  .pro-inner-list-item
  .pro-sub-menu-item,
.pro-sidebar.collapsed
  .pro-menu
  > ul
  > .pro-menu-item.pro-sub-menu
  .pro-inner-list-item
  .pro-inner-item {
  @apply py-1;
}

.pro-sidebar .pro-menu .pro-menu-item > .pro-inner-item {
  padding-left: 14px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.pro-sidebar
  .pro-menu.shaped
  .pro-menu-item
  > .pro-inner-item
  > .pro-icon-wrapper {
  @apply bg-th-bkg-3;
}

.pro-sidebar
  .pro-menu
  .pro-menu-item
  > .pro-inner-item:hover
  .pro-icon-wrapper
  .pro-icon {
  @apply animate-none;
}

.pro-sidebar.collapsed
  .pro-menu
  > ul
  > .pro-menu-item.pro-sub-menu:hover
  .pro-icon-wrapper
  .pro-icon {
  @apply animate-none;
}

.pro-sidebar .pro-menu a {
  @apply transition-all duration-200;
  color: inherit;
}

@keyframes sideways-bounce {
  0%,
  100% {
    transform: translateX(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateX(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.sideways-bounce {
  animation: sideways-bounce 1s infinite;
}
