// Variables
$primary-blue: #008cba;
$primary-blue-hover: #1a5492;
$border-gray: #dee2e6;
$danger-red: #dc3545;
$white: #fff;

// Mixins
@mixin flex-center {
  display: flex;
  align-items: center;
}

@mixin text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// Modal Container
.plot-modal-container {
  background-color: $white;
  display: flex;
  flex-direction: column;
  border: 1px solid $border-gray;
  overflow: hidden;
  position: fixed;
  top: 54%;
  transform: translate(-50%, -50%);
  height: 95vh;
  z-index: 999;
  min-width: 300px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

// Top Horizontal Panel for Minimized Plots
.plot-top-panel {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  max-width: 80vw;
  background-color: transparent;
  padding: 0 1rem;
  border-radius: 0;
  border: none;
  box-shadow: none;
  z-index: 1001;
  @include flex-center;
  gap: 12px;
  overflow-y: hidden;
  overflow-x: auto;
}

// Minimized Windows Container
.plot-minimized-container {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  max-width: 800px;
}

// Top Panel Items (Minimized Windows)
.plot-top-item {
  padding: 6px 12px;
  background-color: $primary-blue;
  border: 1px solid $border-gray;
  cursor: pointer;
  @include flex-center;
  gap: 6px;
  font-size: 16px;
  font-weight: 500;
  color: $white;
  min-width: 200px;
  max-width: 300px;
  white-space: nowrap;

  &:hover {
    background-color: $primary-blue-hover;
  }
}

// Plot Item Text
.plot-item-text {
  @include text-ellipsis;
  flex: 1;
}

// Close Button
.plot-close-btn {
  padding: 2px !important;
  font-size: 12px !important;
  color: $white !important;
  line-height: 1 !important;
  min-width: auto !important;
  width: 16px !important;
  height: 14px !important;
  border: none !important;
  background-color: $danger-red !important;
}

.plot-window-header {
  background: $primary-blue;
  border-bottom: 1px solid $border-gray;
  flex-shrink: 0;
  padding: 1rem;
  display: flex;
  align-items: center;
  position: relative;
  height: 21px;
}

.plot-window-title {
  margin-bottom: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 1;
  @include text-ellipsis;
  max-width: 60%;
}
.button {
  margin-left: auto;
  margin-right: -1rem;
}

.plot-modal-single {
  left: 50%;
  width: 85vw;
}

.plot-modal-left {
  left: 25%;
  width: 45vw;
}

.plot-modal-right {
  left: 75%;
  width: 45vw;
}

// Window Content
.plot-window-content {
  flex: 1;
  overflow-y: scroll;
  overflow-x: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 1rem auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

    &.full-width {
      width: 100%;
    }

    &.center {
      display: block;
      margin-left: auto;
      margin-right: auto;
    }

    &.left {
      float: left;
      margin-right: 1rem;
    }

    &.right {
      float: right;
      margin-left: 1rem;
    }
  }
}

// Stacked windows vertically on smaller screens
@media (max-width: 900px) {
  .plot-modal-left,
  .plot-modal-right {
    left: 50%;
    width: 90vw;
    height: 40vh;
  }

  .plot-modal-left {
    top: 25%;
  }

  .plot-modal-right {
    top: 75%;
  }

  .plot-window-title {
    font-size: 1.25rem;
  }

  .plot-window-header {
    padding: 0.75rem 1rem;
  }

  .plot-window-content {
    padding: 0.5rem;
  }
}

@media (max-width: 600px) {
  .plot-modal-container {
    height: 90vh;
  }

  .plot-modal-single,
  .plot-modal-left,
  .plot-modal-right {
    width: 95vw;
    left: 50%;
  }

  .plot-top-panel {
    max-width: 95vw;
  }
}
