@use "theme";

/* Grid */
.ec-days,
.ec-day,
.ec-day-title,
.ec-resource {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
}

.ec {
  display: flex;
  flex-direction: column;
  color: var(--ec-text-color);
  background-color: var(--ec-bg-color);
  -webkit-tap-highlight-color: transparent;

  /* Scrollbar */
  ::-webkit-scrollbar {
    background-color: transparent;
  }

  ::-webkit-scrollbar-thumb {
    border: 4px solid transparent;
    box-shadow: none;
    background-color: var(--ec-border-color);
    background-clip: padding-box;
    border-radius: 8px;
    min-height: 40px;
  }

  :hover::-webkit-scrollbar-thumb {
    background-color: var(--ec-accent-color);
  }
}

.ec-hidden-scroll {
  display: none;
  overflow-y: scroll;
  visibility: hidden;
  flex-shrink: 0;

  .ec-with-scroll & {
    display: block;
  }
}

/* Toolbar */
.ec-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;

  > * {
    margin-bottom: -.5em;

    > * {
      margin-bottom: .5em;

      &:not(:last-child) {
        margin-right: .75em;
      }
    }
  }
}

.ec-title {
  margin: 0;
}

.ec-button {
  background-color: var(--ec-button-bg-color);
  border: 1px solid var(--ec-button-border-color);
  padding: .375rem .75rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: .25rem;

  &:not(:disabled) {
    color: var(--ec-button-text-color);
    cursor: pointer;
  }

  &:not(:disabled):hover,
  &.ec-active {
    background-color: var(--ec-button-active-bg-color);
    border-color: var(--ec-button-active-border-color);
    color: var(--ec-button-active-text-color);
    z-index: 1;  // make all borders visible
  }
}

.ec-button-group {
  display: inline-flex;

  .ec-button:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -1px;
  }

  .ec-button:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }
}

.ec-icon {
  display: inline-block;
  width: 1em;

  &.ec-prev:after,
  &.ec-next:after {
    content: '';
    position: relative;
    width: .5em;
    height: .5em;
    border-top: 2px solid currentcolor;
    border-right: 2px solid currentcolor;
    display: inline-block;
  }

  &.ec-prev:after {
    transform: rotate(-135deg) translate(-2px, 2px);
  }

  &.ec-next:after {
    transform: rotate(45deg) translate(-2px, 2px);
  }
}

/* Header */
.ec-header,
.ec-all-day,
.ec-body,
.ec-days,
.ec-day,
.ec-list .ec-day-head {
  border: 1px solid var(--ec-border-color);
}

.ec-header {
  display: flex;
  flex-shrink: 0;

  .ec-resource {
    flex-direction: column;

    .ec-days {
      border-top-style: solid;
    }
  }

  .ec-days {
    border-bottom: none;
  }

  .ec-day {
    min-height: 24px;
    line-height: 24px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* All Day */
.ec-all-day {
  flex-shrink: 0;
  border-top: none;

  .ec-days {
    border-bottom: none;
  }

  .ec-day {
    padding-bottom: 4px;
  }
}

/* Body */
.ec-body {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;

  .ec:not(.ec-list) & {
    border-top: none;
  }

  .ec-day-grid & {
    flex: 1 1 auto;
  }
}

.ec-sidebar {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  padding: 0 4px 0 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ec-sidebar-title {
  visibility: hidden;
  overflow-y: hidden;
  height: 0;
  text-align: right;

  .ec-all-day & {
    visibility: visible;
    height: auto;
    padding: 8px 0;
  }
}

.ec-content {
  display: flex;

  .ec-day-grid & {
    flex-direction: column;
    height: 100%;
  }

  .ec-day-grid .ec-uniform & {
    overflow: hidden;  // remove scrolling due to hidden events
  }

  .ec-list & {
    flex-direction: column;
  }
}

.ec-resource {
  display: flex;
}

.ec-days {
  display: flex;
  border-style: none none solid;

  &:last-child {
    border-bottom: none;
  }

  .ec-day-grid &,
  .ec-resource & {
    flex: 1 0 auto;
  }

  .ec-day-grid .ec-uniform & {
    flex: 1 1 0%;  // % is required to work properly for both auto and fixed calendar height
    min-height: 0;
  }
}

.ec-day {
  border-style: none none none solid;

  &.ec-today {
    background-color: var(--ec-today-bg-color);
  }

  &.ec-highlight {
    background-color: var(--ec-highlight-color);
  }

  .ec-day-grid .ec-body & {
    min-height: 5em;
    position: relative;
  }

  .ec-day-grid .ec-uniform & {
    min-height: 0;
  }

  .ec-day-grid &:first-child {
    border-left: none;
  }

  &.ec-other-month .ec-day-head {
    opacity: .3;
  }

  .ec-list & {
    border: none;
  }
}

.ec-day-grid {
  .ec-day-head {
    display: block;
    text-align: right;
    padding: 4px 4px 3px;
  }

  .ec-day-foot {
    position: absolute;
    bottom: 0;
    padding: 2px;
    font-size: .85em;

    a {
      cursor: pointer;
    }
  }
}

.ec-list {
  .ec-day-head {
    flex: 1 0 auto;
    background-color: var(--ec-list-day-bg-color);
    border-style: solid none;
    margin: -1px 0 0;
    padding: 8px 14px;
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .ec-day:first-child .ec-day-head {
    border-top: none;
  }

  .ec-day-side {
    float: right;
  }

  .ec-no-events {
    text-align: center;
    padding: 5em 0;
  }
}

.ec-events {
  margin: 0 6px 0 0;

  .ec-time-grid &,
  &.ec-preview {
    position: relative;
  }
}

.ec-event {
  display: flex;
  padding: 2px;
  color: var(--ec-event-text-color);
  box-sizing: border-box;
  box-shadow: 0 0 1px 0 var(--ec-border-color);
  background-color: var(--ec-event-bg-color);
  border-radius: 3px;
  font-size: .85em;
  line-height: 1.5;
  z-index: 1;  // put it above the pointer event (for multi-day events in month view)

  .ec-day-grid &,
  .ec-all-day & {
    position: relative;
  }

  .ec-time-grid .ec-body & {
    position: absolute;
  }

  .ec-list & {
    flex-direction: row;
    padding: 8px 14px;
    color: inherit;
    background-color: transparent;
    border-radius: 0;
  }

  &.ec-preview {
    position: absolute;
    z-index: 1000;
    width: 100%;
    user-select: none;
    opacity: .8;
  }

  &.ec-pointer {
    color: inherit;
    pointer-events: none;
    user-select: none;
    position: absolute;
    z-index: 0;
    box-shadow: none;
    display: none;
    .ec-day:hover & {
      display: flex;
    }
  }
}

.ec-event-body {
  display: flex;
  flex-direction: column;
  width: 100%;

  .ec-day-grid &,
  .ec-all-day & {
    flex-direction: row;
  }
}

.ec-event-tag {
  width: 4px;
  border-radius: 2px;
  margin-right: 8px;
}

.ec-event-time {
  overflow: hidden;
  white-space: nowrap;
  margin: 0 0 1px 0;
  flex-shrink: 0;

  .ec-day-grid & {
    margin: 0 3px 0 0;
    max-width: 100%;
    text-overflow: ellipsis;
  }
}

.ec-event-title {
  overflow: hidden;
  margin: unset;
  font-weight: inherit;

  .ec-day-grid &,
  .ec-all-day & {
    min-height: 1.5em;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .ec-time-grid .ec-body & {
    position: sticky;
    top: 0;
  }

  .ec-list & {
    font-size: 1rem;
  }
}

.ec-draggable {
  cursor: pointer;
  user-select: none;
}

.ec-ghost {
  opacity: .5;
  user-select: none;
  pointer-events: none;
}

.ec-bg-events {
  position: relative;
}

.ec-bg-event {
  position: absolute;
  background-color: var(--ec-bg-event-color);
  opacity: var(--ec-bg-event-opacity);
  width: 100%;
  z-index: 1;
}

.ec-time,
.ec-line {
  height: 24px;
}

.ec-time {
  position: relative;
  line-height: 24px;
  top: -12px;
  text-align: right;
  white-space: nowrap;

  .ec-header &,
  .ec-all-day & {
    visibility: hidden;
    overflow-y: hidden;
    height: 0;
  }
}

.ec-lines {
  width: 8px;
}

.ec-line:not(:first-child):after {
  content: '';
  position: absolute;
  width: 100%;
  border-bottom: 1px solid var(--ec-border-color);
  pointer-events: none;
}

.ec-body:not(.ec-compact) .ec-line:nth-child(even):after {
  border-bottom-style: dotted;
}

.ec-popup {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 110%;
  min-width: 180px;
  z-index: 1010;
  padding: 8px 10px 14px;
  background-color: var(--ec-popup-bg-color);
  border: 1px solid var(--ec-border-color);
  border-radius: 6px;
  outline: 1px solid transparent;
  box-shadow: 0 1px 3px 0 hsla(var(--ec-hs), 50%, .15), 0 4px 8px 3px hsla(var(--ec-hs), 50%, .15);

  .ec-day-head {
    text-align: left;
    display: flex;
    justify-content: space-between;

    a {
      cursor: pointer;
      font-size: 1.5em;
      line-height: .8;
    }
  }

  .ec-events {
    margin: 0;
    min-height: 0;
    overflow: auto;
  }
}

.ec-extra {
  position: relative;
  height: 100%;
  overflow: hidden;
  margin-left: -6.5px;
  user-select: none;
}

.ec-now-indicator {
  position: absolute;
  z-index: 1005;
  width: 100%;
  border-top: var(--ec-now-indicator-color) solid 2px;
  pointer-events: none;

  &:before {
    background: var(--ec-now-indicator-color);
    border-radius: 50%;
    content: "";
    position: absolute;
    height: 12px;
    margin-top: -7px;
    width: 12px;
    pointer-events: none;
  }
}

.ec-resizer {
  position: absolute;
  user-select: none;

  .ec-day-grid &,
  .ec-all-day & {
    top: 0;
    right: 0;
    bottom: 0;
    width: 50%;
    max-width: 8px;
    cursor: ew-resize;
  }

  .ec-time-grid .ec-body & {
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    max-height: 8px;
    cursor: ns-resize;
  }
}

.ec-dragging {
  cursor: pointer!important;
}
.ec-resizing-y {
  cursor: ns-resize!important;
}
.ec-resizing-x {
  cursor: ew-resize!important;
}
