.toolsPage {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolsContainer {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.headerAction {
  flex-shrink: 0;

  :global {
    .qwenpaw-switch-inner-unchecked {
      color: #000000 !important;
    }
  }
}

.loading {
  text-align: center;
  padding: 60px;
  color: #999;
}

.toolsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ---- Panel Section (grouped containers) ---- */

.panelSection {
  background: #fafbfc;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 18px;
  margin: 16px;
}

.panelSectionDashed {
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: 12px;
  padding: 18px;
  margin: 0 16px 16px;
}

.panelTitle {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panelDotGreen {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.panelDotGray {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}

.panelCount {
  font-size: 11px;
  color: #10b981;
  font-weight: 400;
  margin-left: auto;
}

.emptyEnabled {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 2px dashed #e5e7eb;
  border-radius: 12px;
  margin-bottom: 24px;
  text-align: center;
}

.emptyEnabled p {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 16px;
}

.availableGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.availableItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #f3f4f6;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.15s ease;
}

.availableItem:hover {
  background: #fff;
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.availableItemName {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  color: #1a1a1a;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.availableItemAction {
  font-size: 11px;
  color: #6366f1;
  font-weight: 500;
  white-space: nowrap;
}

.toolCard {
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--border-radius, 8px);
  background: var(--color-bg-base, #ffffff);
  border: 1px solid var(--color-border-secondary, #eae8e7);
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;

  :global(.qwenpaw-card-body) {
    padding: 0 !important;
  }

  &.enabledCard {
    .statusDot {
      background-color: rgba(20, 184, 166, 1);
    }

    .statusText {
      color: rgba(20, 184, 166, 1);
    }
  }

  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);

  &:hover {
    border-color: var(--color-border, #d9d9d9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
}

.cardHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.toolName {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: rgba(20, 20, 19, 0.88);
  line-height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
}

.toolNameText {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.toolIconFallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.statusContainer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  flex-shrink: 0;
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background-color: #d9d9d9;
}

.statusText {
  font-family: Lato;
  font-size: 12px;
  font-weight: normal;
  line-height: 19px;
  letter-spacing: normal;
  color: rgba(20, 20, 19, 0.45);
}

.toolDescription {
  margin: 4px 0 12px 0;
  color: #666;
  font-size: 12px;
  line-height: 1.5;
  min-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.configStatus {
  margin: 8px 0;
  font-size: 12px;

  .configured {
    color: rgba(20, 184, 166, 1);
    font-weight: 500;
  }

  .notConfigured {
    color: #ff7f16;
    font-weight: 500;
  }
}

.cardFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid #f0f0f0;
}

.toggleButton {
  flex: 1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #666;
  background: transparent;
  border: 1px solid #d9d9d9;
  cursor: pointer;
  transition: all 0.18s ease;

  &:hover:not(:disabled) {
    color: #333;
    border-color: #bfbfbf;
  }

  &:disabled {
    color: #d9d9d9;
    cursor: not-allowed;
  }
}

/* ─── Dark mode ─────────────────────────────────────────────────────────────── */
:global(.dark-mode) {
  .loading {
    color: rgba(255, 255, 255, 0.35);
  }

  /* Tool card */
  .toolCard {
    background: #2d2d2d;
  }

  .toolName {
    color: rgba(255, 255, 255, 0.85);
  }

  .statusDot {
    background-color: rgba(255, 255, 255, 0.2);
  }

  .statusDot.enabled {
    background-color: rgba(20, 184, 166, 1);
  }

  .statusText {
    color: rgba(255, 255, 255, 0.45);
  }

  .statusText.enabled {
    color: rgba(20, 184, 166, 1);
  }

  .toolDescription {
    color: rgba(255, 255, 255, 0.65);
  }

  .cardFooter {
    border-top-color: rgba(255, 255, 255, 0.08);
  }

  /* Panel sections */
  .panelSection {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
  }

  .panelSectionDashed {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.12);
  }

  .panelTitle {
    color: rgba(255, 255, 255, 0.45);
  }

  .panelDotGray {
    background: rgba(255, 255, 255, 0.2);
  }

  .emptyEnabled {
    border-color: rgba(255, 255, 255, 0.12);

    p {
      color: rgba(255, 255, 255, 0.45);
    }
  }

  .availableItem {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);

    &:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: #6366f1;
    }
  }

  .availableItemName {
    color: rgba(255, 255, 255, 0.85);
  }

  .availableItemAction {
    color: #818cf8;
  }

  .toggleButton {
    color: rgba(255, 255, 255, 0.65);
    border-color: rgba(255, 255, 255, 0.2);

    &:hover:not(:disabled) {
      color: rgba(255, 255, 255, 0.85);
      border-color: rgba(255, 255, 255, 0.35);
    }

    &:disabled {
      color: rgba(255, 255, 255, 0.25);
      border-color: rgba(255, 255, 255, 0.1);
    }
  }

  /* Switch component in dark mode */
  .headerAction {
    :global(.qwenpaw-switch) {
      background-color: rgba(255, 255, 255, 0.15);

      &:hover:not(.qwenpaw-switch-disabled) {
        background-color: rgba(255, 255, 255, 0.25);
      }

      &.qwenpaw-switch-disabled {
        background-color: rgba(255, 255, 255, 0.08);
        opacity: 0.65;

        :global(.qwenpaw-switch-inner) {
          color: rgba(255, 255, 255, 0.45);
        }
      }
    }

    :global(.qwenpaw-switch-checked) {
      background-color: #ff7f16;

      &:hover:not(.qwenpaw-switch-disabled) {
        background-color: #ff9d4d;
      }

      &.qwenpaw-switch-disabled {
        background-color: rgba(255, 127, 22, 0.35);
        opacity: 0.65;

        :global(.qwenpaw-switch-inner) {
          color: rgba(255, 255, 255, 0.55);
        }
      }
    }

    :global(.qwenpaw-switch-inner) {
      color: rgba(255, 255, 255, 0.85);
    }
  }
}
