/* Enhanced Color Palette */
:root {
   --light: hsl(220, 20%, 98%);
   --text: hsl(220, 15%, 20%);
   --text-light: hsl(0, 0%, 98%);

   --shadow: hsla(220, 15%, 30%, 0.15);
   --shadow-strong: hsla(220, 15%, 30%, 0.25);
   --accent: hsl(338, 85%, 58%);
   --accent-hover: hsl(338, 85%, 52%);

   --muted-light: hsl(220, 15%, 92%);
   --muted-text: hsl(220, 10%, 35%);

   --current: hsl(12, 90%, 65%);
   --correct: hsl(142, 70%, 58%);
   --sorted: hsl(215, 85%, 62%);

   --primary: #3b82f6;
   --hover: #f3f4f6;
   --selected: #dbeafe;

   --gradient-bg: linear-gradient(
      135deg,
      hsl(220, 20%, 96%) 0%,
      hsl(220, 15%, 94%) 100%
   );
}

/* Global Styles */
* {
   margin: 0;
   padding: 0;
   box-sizing: border-box;
   font-family: "Jetbrains Mono", sans-serif, monospace;
}

b {
   color: var(--accent);
}

html,
body {
   background: var(--gradient-bg);
   height: 100%;
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
   gap: 1rem;
}

/* Main Container */
.container {
   z-index: 0;
   position: relative;
   display: flex;
   justify-content: center;
   align-items: center;
   gap: 1.5rem;
   height: 500px;
   width: max(200px, 85vw);
   min-width: 320px;
   padding: 1rem;
}

/* Graph Container */
.container-graph {
   background: var(--light);
   box-shadow: 0 4px 20px var(--shadow), 0 1px 3px var(--shadow-strong);
   flex: 1 2 auto;
   display: flex;
   flex-direction: column;
   justify-content: center;
   height: 100%;
   min-width: 280px;
   border-radius: 1.25rem;
   overflow: hidden;
   border: 1px solid hsla(220, 15%, 90%, 0.8);
   position: relative;
}

.graph {
   flex-grow: 1;
   display: flex;
   gap: 10px;
   width: 100%;
   height: 100%;
   overflow-x: auto;
   padding: 1.5rem;
   align-items: flex-end;
}

.graph::-webkit-scrollbar {
   height: 8px;
}

.graph::-webkit-scrollbar-track {
   background: var(--muted-light);
   border-radius: 4px;
}

.graph::-webkit-scrollbar-thumb {
   background: var(--accent);
   border-radius: 4px;
}

.graph::-webkit-scrollbar-thumb:hover {
   background: var(--accent-hover);
}

/* Graph Points */
.points {
   display: flex;
   flex-direction: column-reverse;
   gap: 8px;
   width: 100%;
   text-align: center;
   min-width: 45px;
}

.points.swap {
   transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

#bar {
   background: linear-gradient(
      135deg,
      var(--accent) 0%,
      hsl(338, 85%, 48%) 100%
   );
   box-shadow: 0 2px 8px hsla(338, 85%, 58%, 0.3);
   border-radius: 6px;
   width: 100%;
   transition: all 0.3s ease;
}

#bar:hover {
   transform: translateY(-2px);
   box-shadow: 0 4px 12px hsla(338, 85%, 58%, 0.4);
}

#text {
   color: var(--text);
   font-size: 1rem;
   font-weight: 700;
   margin-top: 4px;
}

/* Details Container */
.container-details {
   background: var(--light);
   border-radius: 1.25rem;
   box-shadow: 0 4px 20px var(--shadow), 0 1px 3px var(--shadow-strong);
   border: 1px solid hsla(220, 15%, 90%, 0.8);
   flex-shrink: 2;
   display: flex;
   flex-direction: column;
   gap: 8px;
   height: 100%;
   min-width: 420px;
   width: 420px;
   padding: 24px;
   text-align: justify;
   overflow-y: auto;
   scrollbar-width: none;
   transition: 400ms ease;
}

.container-details h1 {
   font-size: 1.4rem;
   color: var(--text);
   font-weight: 700;
   letter-spacing: -0.5px;
}

.container-details > p {
   flex-grow: 1;
   font-size: 0.8rem;
   line-height: 1.2;
   color: var(--muted-text);
}

/* Status Section - Improved Structure */
.details-status {
   display: flex;
   flex-direction: column;
   gap: 0.5rem;
}

.statusGA,
.statusGB {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 0.75rem;
   width: 100%;
}

.details-status .status {
   background: linear-gradient(
      135deg,
      var(--accent) 0%,
      hsl(338, 85%, 52%) 100%
   );
   color: var(--text-light);
   padding: 4px 8px;
   font-weight: 700;
   font-size: 0.65rem;
   border-radius: 6px;
   text-transform: uppercase;
   letter-spacing: 0.5px;
   box-shadow: 0 2px 8px hsla(338, 85%, 58%, 0.25);
   white-space: nowrap;
   flex-shrink: 0;
}

#swap-count,
#status-value {
   font-weight: 600;
   color: var(--text);
   font-size: 0.95rem;
   flex: 1;
   text-align: right;
   min-width: 0;
}

/* Input Container */
.details-input {
   position: relative;
   display: flex;
   flex-direction: column;
   gap: 12px;
   padding: 0;
   min-height: 150px;
}

.group {
   display: flex;
   flex-direction: column;
   gap: 10px;
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.group.selected {
   opacity: 1;
   pointer-events: auto;
}

.input-label {
   font-size: 0.8rem;
   font-weight: 700;
   color: var(--muted-text);
   text-transform: uppercase;
   letter-spacing: 1px;
   margin-bottom: 2px;
}

.group input {
   padding: 14px 16px;
   width: 100%;
   border-radius: 10px;
   border: 2px solid var(--muted-light);
   font-size: 0.95rem;
   background: white;
   transition: all 0.3s ease;
   color: var(--text);
}

.group input:focus {
   outline: none;
   border-color: var(--accent);
   box-shadow: 0 0 0 3px hsla(338, 85%, 58%, 0.1);
   background: white;
}

.group input::placeholder {
   color: var(--muted-text);
   font-size: 0.85rem;
   opacity: 0.6;
}

.group button {
   padding: 14px;
   width: 100%;
   border-radius: 10px;
   border: none;
   background: linear-gradient(
      135deg,
      var(--accent) 0%,
      hsl(338, 85%, 52%) 100%
   );
   color: var(--text-light);
   font-weight: 700;
   font-size: 1rem;
   letter-spacing: 2px;
   text-transform: uppercase;
   cursor: pointer;
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
   box-shadow: 0 4px 12px hsla(338, 85%, 58%, 0.3);
}

.group button:hover {
   transform: translateY(-2px);
   box-shadow: 0 6px 20px hsla(338, 85%, 58%, 0.4);
}

.group button:active {
   transform: translateY(0);
   box-shadow: 0 2px 8px hsla(338, 85%, 58%, 0.3);
}

/* Toggle Button */
.input-btn {
   position: absolute;
   top: -3px;
   right: 0;
   width: 25px;
   height: 25px;
   background: linear-gradient(
      135deg,
      var(--accent) 0%,
      hsl(338, 85%, 52%) 100%
   );
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
   box-shadow: 0 4px 12px hsla(338, 85%, 58%, 0.3);
   z-index: 10;
}

.input-btn:hover {
   transform: translateY(-2px);
   box-shadow: 0 6px 16px hsla(338, 85%, 58%, 0.4);
}

.input-btn svg {
   width: 20px;
   height: 20px;
   fill: white;
   transition: transform 0.3s ease;
}

.input-btn.rotated svg {
   transform: rotate(180deg);
}

/* Dropdown Styles */

.dropdown {
   width: 36px;
   height: 36px;
   fill: var(--text);
   padding: 6px;
   border-radius: 50%;
   background: var(--light);
   box-shadow: 0 4px 12px var(--shadow);
   border: 1px solid hsla(220, 15%, 90%, 0.8);
   position: absolute;
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-btn-1:hover {
   transform: scale(1.05);
   box-shadow: 0 6px 16px var(--shadow-strong);
}
/* dropdown 1 */

.dropdown-btn-1 {
   top: -2rem;
   left: -3.5rem;
   cursor: pointer;
   z-index: 2;
}

.dropdown-btn-1 > svg {
   transition: 200ms ease;
}

.dropdown-btn-1.show > svg {
   transform: rotate(180deg);
}

.container-dropdown {
   z-index: 1;
   position: absolute;
   top: 1.5rem;
   left: -3.5rem;
   display: flex;
   justify-content: center;
   align-items: stretch;
   gap: 0;
   border-radius: 14px;
   box-shadow: 0 8px 24px var(--shadow-strong);
   background: var(--light);
   border: 1px solid hsla(220, 15%, 90%, 0.8);
   overflow: hidden;
   max-height: 0;
   width: 340px;
   min-width: 280px;
   opacity: 0;
   transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.container-dropdown.show {
   opacity: 1;
   max-height: 600px;
}

.sectionA,
.sectionB {
   width: 50%;
   padding: 20px 16px;
   display: flex;
   flex-direction: column;
   gap: 10px;
}

.sectionA {
   border-right: 1px solid var(--muted-light);
}

.section-title {
   text-align: left;
   font-size: 0.75rem;
   color: var(--muted-text);
   font-weight: 700;
   text-transform: uppercase;
   letter-spacing: 1px;
   margin-bottom: 4px;
}

.container-dropdown span:not(:nth-child(1)) {
   text-align: center;
   font-size: 0.9rem;
   font-weight: 600;
   padding: 10px 16px;
   background: white;
   border: 2px solid var(--muted-light);
   border-radius: 10px;
   cursor: pointer;
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
   color: var(--text);
}

.container-dropdown span:not(:nth-child(1)):hover {
   border-color: var(--accent);
   background: hsla(338, 85%, 58%, 0.05);
   transform: translateX(2px);
}

.container-dropdown span:not(:nth-child(1)).selected {
   color: var(--text-light);
   background: linear-gradient(
      135deg,
      var(--accent) 0%,
      hsl(338, 85%, 52%) 100%
   );
   border: 2px solid var(--accent);
   box-shadow: 0 4px 12px hsla(338, 85%, 58%, 0.3);
   transform: translateX(2px);
}

/* dropdown 2 */
.dropdown-btn-2 {
   display: none;
}

/* State Classes */
.current {
   background: linear-gradient(
      135deg,
      var(--current) 0%,
      hsl(12, 90%, 55%) 100%
   ) !important;
   box-shadow: 0 2px 8px hsla(12, 90%, 65%, 0.4) !important;
}

.correct-value {
   background: linear-gradient(
      135deg,
      var(--correct) 0%,
      hsl(142, 70%, 48%) 100%
   ) !important;
   box-shadow: 0 2px 8px hsla(142, 70%, 58%, 0.4) !important;
}

.sorted {
   background: linear-gradient(
      135deg,
      var(--sorted) 0%,
      hsl(215, 85%, 52%) 100%
   ) !important;
   box-shadow: 0 2px 8px hsla(215, 85%, 62%, 0.4) !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
   .container {
      flex-direction: column;
      height: auto;
      max-height: 70vh;
      gap: 0;
      padding: 8px ;
      padding-top: 4rem;
   }

   .container-graph {
      width: 100%;
      min-height: 250px;
      max-height: calc(100vh - 5rem);
      height: auto;
      flex: 1;
      position: relative;
   }

   .graph {
      padding: 4.5rem 1rem 1rem 1rem;
   }

   /* Move status from details to graph container */

   /* Create floating status above graph */
   .container-graph::before {
      content: "";
      position: absolute;
      top: 0.75rem;
      left: 0.75rem;
      right: 0.75rem;
      height: auto;
      z-index: 10;
   }

   /* Floating Status - needs to be moved via JS */
   .statusGA,
   .statusGB {
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
      flex: 1;
      min-width: 0;
   }

   .details-status .status {
      font-size: 0.65rem;
      padding: 4px 8px;
   }

   #swap-count,
   #status-value {
      font-size: 0.85rem;
      text-align: left;
      word-break: break-word;
   }

   /* Container Details - Slide in from Right */
   .container-details {
      position: fixed;
      right: 0;
      top: 0;
      bottom: 0;
      max-width: 400px;
      min-width: 280px;
      height: 100vh;
      transform: translateX(100%);
      opacity: 0;
      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 1.25rem 0 0 1.25rem;
      z-index: 98;
      gap: 1rem;
      padding: 20px;
   }

   .container-details.show {
      transform: translateX(0);
      opacity: 1;
   }

   .container-details > h1 {
      font-size: 2.5rem;
      margin-top: 1rem;
   }

   .container-details > p {
      font-size: 0.9rem;
      line-height: 1.4;
   }

   /* Hide status in details panel on mobile */


   /* Mobile Input Adjustments */
   .group input {
      padding: 12px 14px;
      font-size: 0.9rem;
   }

   .group input::placeholder {
      font-size: 0.75rem;
   }

   .group button {
      padding: 12px;
      font-size: 0.9rem;
      letter-spacing: 1.5px;
   }

   .input-label {
      font-size: 0.8rem;
   }

   /* Dropdown Button 2 - Toggle Details Panel */
   .dropdown-btn-2 {
      display: flex;
      position: fixed;
      bottom: 2rem;
      right: 1.5rem;
      cursor: pointer;
      z-index: 99;
      transform: rotate(-90deg);
   }

   .dropdown-btn-2:hover {
      transform: rotate(-90deg) scale(1.05);
      box-shadow: 0 6px 16px var(--shadow-strong);
   }

   .dropdown-btn-2.show {
      right: calc(400px + 1.5rem);
   }

   .dropdown-btn-2.show > svg {
      transform: rotate(180deg);
   }

   /* Dropdown Adjustments */
   .dropdown-btn-1 {
      left: 1rem;
      top: -2.5rem;
   }

   .container-dropdown {
      top: 1.3rem;
      left: 1rem;
      width: 90vw;
      max-width: 360px;
   }

   .sectionA,
   .sectionB {
      padding: 16px 12px;
   }

   .container-dropdown span:not(:nth-child(1)) {
      font-size: 0.85rem;
      padding: 8px 12px;
   }
   .section-title {
      font-size: 0.7rem;
   }
}

@media (max-width: 480px) {
   .container {
      min-width: 280px;
   }

   .container-details {
      width: 200px;
   }

   .dropdown-btn-2.show {
      right: calc(300px);
   }

   .graph {
      padding: 1rem;
   }

   .points {
      min-width: 35px;
      gap: 6px;
   }

   #details-topic {
      font-size: 1.4rem;
   }

   #text {
      font-size: 0.4rem;
   }

   .container-dropdown {
      width: 150px;
   }

   .sectionA,
   .sectionB {
      width: 100%;
      border-right: none;
   }

   .sectionA span:not([class="section-title"]),
   .sectionB span:not([class="section-title"]) {
      font-size: 0.7rem;
   }

   .sectionA {
      border-bottom: 1px solid var(--muted-light);
   }
}
